diff --git a/.eslintignore b/.eslintignore index 357d735e8044b..1f22b6074e76e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -9,14 +9,14 @@ bower_components /built_assets /html_docs /src/plugins/data/common/es_query/kuery/ast/_generated_/** -/src/legacy/core_plugins/vis_type_timelion/public/_generated_/** +/src/plugins/vis_type_timelion/public/_generated_/** src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data /src/legacy/ui/public/flot-charts /test/fixtures/scenarios /src/legacy/core_plugins/console/public/webpackShims /src/legacy/core_plugins/console/public/tests/webpackShims /src/legacy/ui/public/utils/decode_geo_hash.js -/src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.* +/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.* /src/core/lib/kbn_internal_native_observable /packages/*/target /packages/eslint-config-kibana diff --git a/.eslintrc.js b/.eslintrc.js index dc2eaa993ce8b..a2b8ae7622d0b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -567,7 +567,7 @@ module.exports = { }, { // typescript only for front and back end - files: ['x-pack/legacy/plugins/siem/**/*.{ts,tsx}'], + files: ['x-pack/{,legacy/}plugins/siem/**/*.{ts,tsx}'], rules: { // This will be turned on after bug fixes are complete // '@typescript-eslint/explicit-member-accessibility': 'warn', @@ -613,7 +613,7 @@ module.exports = { // }, { // typescript and javascript for front and back end - files: ['x-pack/legacy/plugins/siem/**/*.{js,ts,tsx}'], + files: ['x-pack/{,legacy/}plugins/siem/**/*.{js,ts,tsx}'], plugins: ['eslint-plugin-node', 'react'], env: { mocha: true, diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b6c992a621b2b..c32bf8cbaa1c3 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13,8 +13,9 @@ /src/legacy/core_plugins/kibana/public/dev_tools/ @elastic/kibana-app /src/legacy/core_plugins/vis_type_vislib/ @elastic/kibana-app /src/plugins/vis_type_xy/ @elastic/kibana-app +/src/plugins/vis_type_table/ @elastic/kibana-app /src/plugins/kibana_legacy/ @elastic/kibana-app -/src/plugins/timelion/ @elastic/kibana-app +/src/plugins/vis_type_timelion/ @elastic/kibana-app /src/plugins/dashboard/ @elastic/kibana-app /src/plugins/discover/ @elastic/kibana-app /src/plugins/visualize/ @elastic/kibana-app @@ -209,9 +210,12 @@ # Endpoint /x-pack/plugins/endpoint/ @elastic/endpoint-app-team /x-pack/test/api_integration/apis/endpoint/ @elastic/endpoint-app-team +/x-pack/test/endpoint_api_integration_no_ingest/ @elastic/endpoint-app-team /x-pack/test/functional_endpoint/ @elastic/endpoint-app-team /x-pack/test/functional_endpoint_ingest_failure/ @elastic/endpoint-app-team /x-pack/test/functional/es_archives/endpoint/ @elastic/endpoint-app-team +/x-pack/test/plugin_functional/plugins/resolver_test/ @elastic/endpoint-app-team +/x-pack/test/plugin_functional/test_suites/resolver/ @elastic/endpoint-app-team # SIEM /x-pack/legacy/plugins/siem/ @elastic/siem diff --git a/.i18nrc.json b/.i18nrc.json index 70277112136a9..d4286a7bd50e0 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -43,12 +43,12 @@ "src/plugins/telemetry_management_section" ], "tileMap": "src/legacy/core_plugins/tile_map", - "timelion": ["src/legacy/core_plugins/timelion", "src/legacy/core_plugins/vis_type_timelion", "src/plugins/timelion"], + "timelion": ["src/legacy/core_plugins/timelion", "src/plugins/vis_type_timelion"], "uiActions": "src/plugins/ui_actions", "visDefaultEditor": "src/plugins/vis_default_editor", "visTypeMarkdown": "src/plugins/vis_type_markdown", "visTypeMetric": "src/plugins/vis_type_metric", - "visTypeTable": "src/legacy/core_plugins/vis_type_table", + "visTypeTable": "src/plugins/vis_type_table", "visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud", "visTypeTimeseries": ["src/legacy/core_plugins/vis_type_timeseries", "src/plugins/vis_type_timeseries"], "visTypeVega": "src/legacy/core_plugins/vis_type_vega", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5c745f1611cce..e4a9d87bc56fc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,6 +22,7 @@ A high level overview of our contributing guidelines. - [Setting Up SSL](#setting-up-ssl) - [Linting](#linting) - [Internationalization](#internationalization) + - [Localization](#localization) - [Testing and Building](#testing-and-building) - [Debugging server code](#debugging-server-code) - [Instrumenting with Elastic APM](#instrumenting-with-elastic-apm) @@ -408,6 +409,11 @@ ReactDOM.render( There are a number of tools created to support internationalization in Kibana that would allow one to validate internationalized labels, extract them to a `JSON` file or integrate translations back to Kibana. To know more, please read corresponding [readme](src/dev/i18n/README.md) file. +### Localization + +We cannot support accepting contributions to the translations from any source other than the translators we have engaged to do the work. +We are still to develop a proper process to accept any contributed translations. We certainly appreciate that people care enough about the localization effort to want to help improve the quality. We aim to build out a more comprehensive localization process for the future and will notify you once contributions can be supported, but for the time being, we are not able to incorporate suggestions. + ### Testing and Building To ensure that your changes will not break other functionality, please run the test suite and build process before submitting your Pull Request. diff --git a/Jenkinsfile b/Jenkinsfile index 79d3c93006cb6..6646ee15ba1c2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -41,7 +41,7 @@ kibanaPipeline(timeoutMinutes: 135, checkPrChanges: true) { 'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10), 'xpack-accessibility': kibanaPipeline.functionalTestProcess('xpack-accessibility', './test/scripts/jenkins_xpack_accessibility.sh'), 'xpack-siemCypress': { processNumber -> - whenChanged(['x-pack/legacy/plugins/siem/', 'x-pack/test/siem_cypress/']) { + whenChanged(['x-pack/plugins/siem/', 'x-pack/legacy/plugins/siem/', 'x-pack/test/siem_cypress/']) { kibanaPipeline.functionalTestProcess('xpack-siemCypress', './test/scripts/jenkins_siem_cypress.sh')(processNumber) } }, diff --git a/docs/api/saved-objects/create.asciidoc b/docs/api/saved-objects/create.asciidoc index dc010c80fd012..571b57a5ef9c2 100644 --- a/docs/api/saved-objects/create.asciidoc +++ b/docs/api/saved-objects/create.asciidoc @@ -57,12 +57,12 @@ any data that you send to the API is properly formed. [source,sh] -------------------------------------------------- -$ curl -X POST "localhost:5601/api/saved_objects/index-pattern/my-pattern" +$ curl -X POST "localhost:5601/api/saved_objects/index-pattern/my-pattern" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d ' { "attributes": { "title": "my-pattern-*" } -} +}' -------------------------------------------------- // KIBANA diff --git a/docs/api/saved-objects/export.asciidoc b/docs/api/saved-objects/export.asciidoc index e8c762b9543a1..a992d13ed9b9c 100644 --- a/docs/api/saved-objects/export.asciidoc +++ b/docs/api/saved-objects/export.asciidoc @@ -68,10 +68,10 @@ Export all index pattern saved objects: [source,sh] -------------------------------------------------- -$ curl -X POST "localhost:5601/api/saved_objects/_export" +$ curl -X POST "localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d ' { "type": "index-pattern" -} +}' -------------------------------------------------- // KIBANA @@ -79,11 +79,11 @@ Export all index pattern saved objects and exclude the export summary from the s [source,sh] -------------------------------------------------- -$ curl -X POST "localhost:5601/api/saved_objects/_export" +$ curl -X POST "localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d ' { "type": "index-pattern", "excludeExportDetails": true -} +}' -------------------------------------------------- // KIBANA @@ -91,7 +91,7 @@ Export a specific saved object: [source,sh] -------------------------------------------------- -$ curl -X POST "localhost:5601/api/saved_objects/_export" +$ curl -X POST "localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d ' { "objects": [ { @@ -99,7 +99,7 @@ $ curl -X POST "localhost:5601/api/saved_objects/_export" "id": "be3733a0-9efe-11e7-acb3-3dab96693fab" } ] -} +}' -------------------------------------------------- // KIBANA @@ -107,7 +107,7 @@ Export a specific saved object and it's related objects : [source,sh] -------------------------------------------------- -$ curl -X POST "localhost:5601/api/saved_objects/_export" +$ curl -X POST "localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d ' { "objects": [ { @@ -116,6 +116,6 @@ $ curl -X POST "localhost:5601/api/saved_objects/_export" } ], "includeReferencesDeep": true -} +}' -------------------------------------------------- // KIBANA diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md index d8202545f0eae..a8894286de910 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md @@ -25,6 +25,5 @@ This is only internal for now, and will only be public when we expose the regist | [mappings](./kibana-plugin-core-server.savedobjectstype.mappings.md) | SavedObjectsTypeMappingDefinition | The [mapping definition](./kibana-plugin-core-server.savedobjectstypemappingdefinition.md) for the type. | | [migrations](./kibana-plugin-core-server.savedobjectstype.migrations.md) | SavedObjectMigrationMap | An optional map of [migrations](./kibana-plugin-core-server.savedobjectmigrationfn.md) to be used to migrate the type. | | [name](./kibana-plugin-core-server.savedobjectstype.name.md) | string | The name of the type, which is also used as the internal id. | -| [namespaceAgnostic](./kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md) | boolean | Is the type global (true), or not (false). | | [namespaceType](./kibana-plugin-core-server.savedobjectstype.namespacetype.md) | SavedObjectsNamespaceType | The [namespace type](./kibana-plugin-core-server.savedobjectsnamespacetype.md) for the type. | diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md deleted file mode 100644 index e347421590482..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md +++ /dev/null @@ -1,18 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [SavedObjectsType](./kibana-plugin-core-server.savedobjectstype.md) > [namespaceAgnostic](./kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md) - -## SavedObjectsType.namespaceAgnostic property - -> Warning: This API is now obsolete. -> -> Use `namespaceType` instead. -> - -Is the type global (true), or not (false). - -Signature: - -```typescript -namespaceAgnostic?: boolean; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespacetype.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespacetype.md index 69912f9144980..3a3b0f7f3a9a5 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespacetype.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespacetype.md @@ -9,5 +9,5 @@ The [namespace type](./kibana-plugin-core-server.savedobjectsnamespacetype.md) f Signature: ```typescript -namespaceType?: SavedObjectsNamespaceType; +namespaceType: SavedObjectsNamespaceType; ``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md index fc0dab94a0f65..bf29c883e4eb9 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md @@ -88,7 +88,6 @@ | [SavedQuery](./kibana-plugin-plugins-data-public.savedquery.md) | | | [SavedQueryService](./kibana-plugin-plugins-data-public.savedqueryservice.md) | | | [SearchSourceFields](./kibana-plugin-plugins-data-public.searchsourcefields.md) | | -| [SearchStrategyProvider](./kibana-plugin-plugins-data-public.searchstrategyprovider.md) | | | [TabbedAggColumn](./kibana-plugin-plugins-data-public.tabbedaggcolumn.md) | \* | | [TabbedTable](./kibana-plugin-plugins-data-public.tabbedtable.md) | \* | | [TimeRange](./kibana-plugin-plugins-data-public.timerange.md) | | diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.id.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.id.md deleted file mode 100644 index d60ffba6a05ca..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.id.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [SearchStrategyProvider](./kibana-plugin-plugins-data-public.searchstrategyprovider.md) > [id](./kibana-plugin-plugins-data-public.searchstrategyprovider.id.md) - -## SearchStrategyProvider.id property - -Signature: - -```typescript -id: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.isviable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.isviable.md deleted file mode 100644 index aa8ed49051ee9..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.isviable.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [SearchStrategyProvider](./kibana-plugin-plugins-data-public.searchstrategyprovider.md) > [isViable](./kibana-plugin-plugins-data-public.searchstrategyprovider.isviable.md) - -## SearchStrategyProvider.isViable property - -Signature: - -```typescript -isViable: (indexPattern: IndexPattern) => boolean; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.md deleted file mode 100644 index b271a921906a7..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.md +++ /dev/null @@ -1,20 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [SearchStrategyProvider](./kibana-plugin-plugins-data-public.searchstrategyprovider.md) - -## SearchStrategyProvider interface - -Signature: - -```typescript -export interface SearchStrategyProvider -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [id](./kibana-plugin-plugins-data-public.searchstrategyprovider.id.md) | string | | -| [isViable](./kibana-plugin-plugins-data-public.searchstrategyprovider.isviable.md) | (indexPattern: IndexPattern) => boolean | | -| [search](./kibana-plugin-plugins-data-public.searchstrategyprovider.search.md) | (params: SearchStrategySearchParams) => SearchStrategyResponse | | - diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.search.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.search.md deleted file mode 100644 index 6e2561c3b0ad0..0000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.searchstrategyprovider.search.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [SearchStrategyProvider](./kibana-plugin-plugins-data-public.searchstrategyprovider.md) > [search](./kibana-plugin-plugins-data-public.searchstrategyprovider.search.md) - -## SearchStrategyProvider.search property - -Signature: - -```typescript -search: (params: SearchStrategySearchParams) => SearchStrategyResponse; -``` diff --git a/docs/images/add_remote_cluster.png b/docs/images/add_remote_cluster.png index 376b1d8392366..160d29b741c62 100755 Binary files a/docs/images/add_remote_cluster.png and b/docs/images/add_remote_cluster.png differ diff --git a/docs/images/auto_follow_pattern.png b/docs/images/auto_follow_pattern.png index 3bf86458eddd7..f80de9352280f 100755 Binary files a/docs/images/auto_follow_pattern.png and b/docs/images/auto_follow_pattern.png differ diff --git a/docs/images/clone_panel.gif b/docs/images/clone_panel.gif new file mode 100644 index 0000000000000..e521e438d051a Binary files /dev/null and b/docs/images/clone_panel.gif differ diff --git a/docs/images/cross-cluster-replication-list-view.png b/docs/images/cross-cluster-replication-list-view.png new file mode 100755 index 0000000000000..4c45174cff7f1 Binary files /dev/null and b/docs/images/cross-cluster-replication-list-view.png differ diff --git a/docs/images/follower_indices.png b/docs/images/follower_indices.png old mode 100644 new mode 100755 index f103bb3cf2acf..505adeb45ae23 Binary files a/docs/images/follower_indices.png and b/docs/images/follower_indices.png differ diff --git a/docs/images/remote-clusters-list-view.png b/docs/images/remote-clusters-list-view.png new file mode 100755 index 0000000000000..c28379863b74b Binary files /dev/null and b/docs/images/remote-clusters-list-view.png differ diff --git a/docs/images/vega_lite_default.png b/docs/images/vega_lite_default.png new file mode 100644 index 0000000000000..1ce1592d0738c Binary files /dev/null and b/docs/images/vega_lite_default.png differ diff --git a/docs/ingest_manager/index-templates.asciidoc b/docs/ingest_manager/index-templates.asciidoc new file mode 100644 index 0000000000000..e19af63c3116f --- /dev/null +++ b/docs/ingest_manager/index-templates.asciidoc @@ -0,0 +1,7 @@ +# Elasticsearch Index Templates + +## Generation + +* Index templates are generated from `YAML` files contained in the package. +* There is one index template per dataset. +* For the generation of an index template, all `yml` files contained in the package subdirectory `dataset/DATASET_NAME/fields/` are used. diff --git a/docs/ingest_manager/index.asciidoc b/docs/ingest_manager/index.asciidoc index 22afa88c919e4..866935d1fa580 100644 --- a/docs/ingest_manager/index.asciidoc +++ b/docs/ingest_manager/index.asciidoc @@ -199,3 +199,10 @@ The new ingest pipeline is expected to still work with the data coming from olde In case of a breaking change in the data structure, the new ingest pipeline is also expected to deal with this change. In case there are breaking changes which cannot be dealt with in an ingest pipeline, a new package has to be created. Each package lists its minimal required agent version. In case there are agents enrolled with an older version, the user is notified to upgrade these agents as otherwise the new configs cannot be rolled out. + +=== Generated assets + +When a package is installed or upgraded, certain Kibana and Elasticsearch assets are generated from . These follow the naming conventions explained above (see "indexing strategy") and contain configuration for the elastic stack that makes ingesting and displaying data work with as little user interaction as possible. + +* link:index-templates.asciidoc[Elasticsearch Index Templates] +* Kibana Index Patterns diff --git a/docs/management/advanced-options.asciidoc b/docs/management/advanced-options.asciidoc index f62a4d28dfc0d..7081590931a99 100644 --- a/docs/management/advanced-options.asciidoc +++ b/docs/management/advanced-options.asciidoc @@ -217,6 +217,8 @@ might increase the search time. This setting is off by default. Users must opt-i [horizontal] `siem:defaultAnomalyScore`:: The threshold above which Machine Learning job anomalies are displayed in the SIEM app. `siem:defaultIndex`:: A comma-delimited list of Elasticsearch indices from which the SIEM app collects events. +`siem:ipReputationLinks`:: A JSON array containing links for verifying the reputation of an IP address. The links are displayed on +{siem-guide}/siem-ui-overview.html#network-ui[IP detail] pages. `siem:enableNewsFeed`:: Enables the security news feed on the SIEM *Overview* page. `siem:newsFeedUrl`:: The URL from which the security news feed content is diff --git a/docs/management/managing-ccr.asciidoc b/docs/management/managing-ccr.asciidoc new file mode 100644 index 0000000000000..b2db5a80cfe7e --- /dev/null +++ b/docs/management/managing-ccr.asciidoc @@ -0,0 +1,73 @@ +[role="xpack"] +[[managing-cross-cluster-replication]] +== Cross-Cluster Replication + +Use *Cross-Cluster Replication* to reproduce indices in +remote clusters on a local cluster. {ref}/xpack-ccr.html[Cross-cluster replication] +is commonly used to provide remote backups for disaster recovery and for +geo-proximite copies of data. + +To get started, go to *Management > Cross-Cluster Replication*. + +[role="screenshot"] +image::images/cross-cluster-replication-list-view.png[][Cross-cluster replication list view] + +[float] +=== Prerequisites + +* You must have a {ref}/modules-remote-clusters.html[remote cluster]. +* Leader indices must meet {ref}/ccr-requirements.html[these requirements]. +* The Elasticsearch version of the local cluster must be the same as or newer than the remote cluster. +Refer to {ref}/ccr-overview.html[this document] for more information. + +[float] +[[configure-replication]] +=== Configure replication + +Replication requires a leader index, the index being replicated, and a +follower index, which will contain the leader index's replicated data. +The follower index is passive in that it can read requests and searches, +but cannot accept direct writes. Only the leader index is active for direct writes. + +You can configure follower indices in two ways: + +* Create specific follower indices +* Create follower indices from an auto-follow pattern + +[float] +==== Create specific follower indices + +To replicate data from existing indices, or set up local followers on a case-by-case basis, +go to *Follower indices*. When you create the follower index, you must reference the +remote cluster and the leader index that you created in the remote cluster. + +[role="screenshot"] +image::images/follower_indices.png[][UI for adding follower indices] + +[float] +==== Create follower indices from an auto-follow pattern + +To automatically detect and follow new indices when they are created on a remote cluster, +go to *Auto-follow patterns*. Creating an auto-follow pattern is useful when you have +time series data, like event logs, on the remote cluster that is created or rolled over on a daily basis. + +When creating the pattern, you must reference the remote cluster that you +connected to your local cluster. You must also specify a collection of index patterns +that match the indices you want to automatically follow. + +Once you configure an +auto-follow pattern, any time a new index with a name that matches the pattern is +created in the remote cluster, a follower index is automatically configured in the local cluster. + +[role="screenshot"] +image::images/auto_follow_pattern.png[UI for adding an auto-follow pattern] + +[float] +[[manage-replication]] +=== Manage replication + +Use the list views in *Cross-Cluster Replication* to monitor whether the replication is active and +pause and resume replication. You can also edit and remove the follower indices and auto-follow patterns. + +For an example of cross-cluster replication, +refer to https://www.elastic.co/blog/bi-directional-replication-with-elasticsearch-cross-cluster-replication-ccr[Bi-directional replication with Elasticsearch cross-cluster replication]. diff --git a/docs/management/managing-remote-clusters.asciidoc b/docs/management/managing-remote-clusters.asciidoc index 6b69cfef5b768..00ec5c7d2ddea 100644 --- a/docs/management/managing-remote-clusters.asciidoc +++ b/docs/management/managing-remote-clusters.asciidoc @@ -1,67 +1,39 @@ [[working-remote-clusters]] == Remote Clusters -{kib} *Management* provides user interfaces for working with data from remote -clusters and managing the {ccr} process. You can replicate indices from a -leader remote cluster to a follower index in a local cluster. The local follower indices -can be used to provide remote backups for disaster recovery or for geo-proximite copies of data. +Use *Remote Clusters* to establish a unidirectional +connection from your cluster to other clusters. This functionality is +required for {ref}/xpack-ccr.html[cross-cluster replication] and +{ref}/modules-cross-cluster-search.html[cross-cluster search]. -Before using these features, you should be familiar with the following concepts: +To get started, go to *Management > Remote Clusters*. -* {ref}/xpack-ccr.html[{ccr-cap}] -* {ref}/modules-cross-cluster-search.html[{ccs-cap}] -* {ref}/cross-cluster-configuring.html[Cross-cluster security requirements] +[role="screenshot"] +image::images/remote-clusters-list-view.png[Remote Clusters list view, including Add a remote cluster button] [float] [[managing-remote-clusters]] -== Managing remote clusters - -*Remote clusters* helps you manage remote clusters for use with -{ccs} and {ccr}. You can add and remove remote clusters and check their connectivity. +=== Add a remote cluster -Before you use this feature, you should be familiar with the concept of -{ref}/modules-remote-clusters.html[remote clusters]. +A {ref}/modules-remote-clusters.html[remote cluster] connection works by configuring a remote cluster and +connecting to a limited number of nodes, called {ref}/modules-remote-clusters.html#sniff-mode[seed nodes], +in that cluster. +Alternatively, you can define a single proxy address for the remote cluster. -Go to *Management > Elasticsearch > Remote clusters* to create or manage your remotes. +By default, a cross-cluster request, such as a cross-cluster search or +replication request, fails if any cluster in the request is unavailable. +To skip a cluster when its unavailable, +set *Skip if unavailable* to true. -To set up a new remote, click *Add a remote cluster*. Give the cluster a unique name -and define the seed nodes for cluster discovery. You can edit or remove your remote clusters -from the *Remote clusters* list view. +Once you add a remote cluster, you can configure <> +to reproduce indices in the remote cluster on a local cluster. [role="screenshot"] image::images/add_remote_cluster.png[][UI for adding a remote cluster] -Once a remote cluster is registered, you can use the tools under *{ccr-cap}* -to add and manage follower indices on the local cluster, and replicate data from -indices on the remote cluster based on an auto-follow index pattern. - [float] -[[managing-cross-cluster-replication]] -== [xpack]#Managing {ccr}# - -*{ccr-cap}* helps you create and manage the {ccr} process. -If you want to replicate data from existing indices, or set up -local followers on a case-by-case basis, go to *Follower indices*. -If you want to automatically detect and follow new indices when they are created -on a remote cluster, you can do so from *Auto-follow patterns*. - -Creating an auto-follow pattern is useful when you have time-series data, like a logs index, on the -remote cluster that is created or rolled over on a daily basis. Once you have configured an -auto-follow pattern, any time a new index with a name that matches the pattern is -created in the remote cluster, a follower index is automatically configured in the local cluster. - -From the same view, you can also see a list of your saved auto-follow patterns for -a given remote cluster, and monitor whether the replication is active. +[[manage-remote-clusters]] +=== Manage remote clusters -Before you use these features, you should be familiar with the following concepts: - -* {ref}/ccr-requirements.html[Requirements for leader indices] -* {ref}/ccr-auto-follow.html[Automatically following indices] - -To get started, go to *Management > Elasticsearch > {ccr-cap}*. - -[role="screenshot"] -image::images/auto_follow_pattern.png[][UI for adding an auto-follow pattern] - -[role="screenshot"] -image::images/follower_indices.png[][UI for adding follower indices] +From the *Remote Clusters* list view, you can drill down into each cluster and +view its status. You can also edit and delete a cluster. diff --git a/docs/redirects.asciidoc b/docs/redirects.asciidoc index fd835bde83322..a5503969a3ec1 100644 --- a/docs/redirects.asciidoc +++ b/docs/redirects.asciidoc @@ -23,7 +23,7 @@ For more {kib} configuration settings, see <>. [role="exclude",id="uptime-security"] == Uptime security -This page has moved. Please see the new section in the {uptime-guide}/uptime-security.html[Uptime Monitoring Guide]. +This page has moved. Please see the new section in the {heartbeat-ref}/securing-heartbeat.html[Uptime Monitoring Guide]. [role="exclude",id="infra-read-only-access"] == Configure source read-only access diff --git a/docs/settings/ml-settings.asciidoc b/docs/settings/ml-settings.asciidoc index 6528568e86890..b71e1c672756a 100644 --- a/docs/settings/ml-settings.asciidoc +++ b/docs/settings/ml-settings.asciidoc @@ -8,7 +8,6 @@ You do not need to configure any settings to use {kib} {ml-features}. They are enabled by default. -[float] [[general-ml-settings-kb]] ==== General {ml} settings @@ -19,3 +18,11 @@ If set to `false` in `kibana.yml`, the {ml} icon is hidden in this {kib} instance. If `xpack.ml.enabled` is set to `true` in `elasticsearch.yml`, however, you can still use the {ml} APIs. To disable {ml} entirely, see the {ref}/ml-settings.html[{es} {ml} settings]. + +[[data-visualizer-settings]] +==== {data-viz} settings + +`xpack.ml.file_data_visualizer.max_file_size`:: +Sets the file size limit when importing data in the {data-viz}. The default +value is `100MB`. The highest supported value for this setting is `1GB`. + diff --git a/docs/setup/production.asciidoc b/docs/setup/production.asciidoc index eef2b11e53d85..19f9d64d13623 100644 --- a/docs/setup/production.asciidoc +++ b/docs/setup/production.asciidoc @@ -133,7 +133,8 @@ server.port Settings that must be the same: -------- xpack.security.encryptionKey //decrypting session cookies -xpack.reporting.encryptionKey //decrypting reports stored in Elasticsearch +xpack.reporting.encryptionKey //decrypting reports +xpack.encryptedSavedObjects.encryptionKey // decrypting saved objects -------- Separate configuration files can be used from the command line by using the `-c` flag: diff --git a/docs/siem/images/cases-ui.png b/docs/siem/images/cases-ui.png new file mode 100644 index 0000000000000..b513efb664740 Binary files /dev/null and b/docs/siem/images/cases-ui.png differ diff --git a/docs/siem/siem-ui.asciidoc b/docs/siem/siem-ui.asciidoc index 85253daaf2933..985138756622d 100644 --- a/docs/siem/siem-ui.asciidoc +++ b/docs/siem/siem-ui.asciidoc @@ -35,7 +35,7 @@ image::siem/images/network-ui.png[] [float] [[detections-ui]] -=== Detections (Beta) +=== Detections (beta) The Detections feature automatically searches for threats and creates signals when they are detected. Signal detection rules define the conditions @@ -50,6 +50,22 @@ or the Detections API. [role="screenshot"] image::siem/images/detections-ui.png[] +[float] +[[cases-ui]] +=== Cases (beta) + +Cases are used to open and track security issues directly in SIEM. +Cases list the original reporter and all users who contribute to a case +(`participants`). Case comments support Markdown syntax, and allow linking to +saved Timelines. Additionally, you can send cases to external systems from +within SIEM (currently ServiceNow). + +For information about opening, updating, and closing cases, see +{siem-guide}/cases-overview.html[Cases] in the SIEM Guide. + +[role="screenshot"] +image::siem/images/cases-ui.png[] + [float] [[timelines-ui]] === Timeline diff --git a/docs/uptime-guide/index.asciidoc b/docs/uptime-guide/index.asciidoc index 7bbc01bb303f1..09763182fa88f 100644 --- a/docs/uptime-guide/index.asciidoc +++ b/docs/uptime-guide/index.asciidoc @@ -12,4 +12,3 @@ include::install.asciidoc[] include::deployment-arch.asciidoc[] -include::security.asciidoc[] diff --git a/docs/uptime-guide/install.asciidoc b/docs/uptime-guide/install.asciidoc index e7c50bb7604ce..0ed1270ca92ce 100644 --- a/docs/uptime-guide/install.asciidoc +++ b/docs/uptime-guide/install.asciidoc @@ -56,6 +56,11 @@ Additional information is available in {heartbeat-ref}/heartbeat-configuration.h [role="screenshot"] image::images/uptime-setup.png[Installation instructions on the Uptime page in Kibana] +[[setup-security]] +=== Step 4: Setup Security + +Secure your installation by following the {heartbeat-ref}/securing-heartbeat.html[Secure Heartbeat] documentation. + [float] ==== Important considerations diff --git a/docs/uptime-guide/security.asciidoc b/docs/uptime-guide/security.asciidoc deleted file mode 100644 index 0c6fa4c6c4f56..0000000000000 --- a/docs/uptime-guide/security.asciidoc +++ /dev/null @@ -1,60 +0,0 @@ -[[uptime-security]] -== Elasticsearch Security - -If you use Elasticsearch security, you'll need to enable certain privileges for users -that would like to access the Uptime app. For example, create user and support roles to implement the privileges: - -[float] -=== Create a role - -You'll need a role that lets you access the Heartbeat indices, which by default are `heartbeat-*`. -You can create this with the following request: - -["source","sh",subs="attributes,callouts"] ---------------------------------------------------------------- -PUT /_security/role/uptime -{ "indices" : [ - { - "names" : [ - "heartbeat-*" - ], - "privileges" : [ - "read", - "view_index_metadata" - ], - "field_security" : { - "grant" : [ - "*" - ] - }, - "allow_restricted_indices" : false - } - ], - "transient_metadata" : { - "enabled" : true - } -} ---------------------------------------------------------------- -// CONSOLE - -[float] -=== Assign the role to a user - -Next, you'll need to create a user with both the `uptime` role, and another role with sufficient {kibana-ref}/kibana-privileges.html[Kibana privileges], -such as the `kibana_admin` role. -You can do this with the following request: - -["source","sh",subs="attributes,callouts"] ---------------------------------------------------------------- -PUT /_security/user/jacknich -{ - "password" : "j@rV1s", - "roles" : [ "uptime", "kibana_admin" ], - "full_name" : "Jack Nicholson", - "email" : "jacknich@example.com", - "metadata" : { - "intelligence" : 7 - } -} ---------------------------------------------------------------- -// CONSOLE diff --git a/docs/uptime/images/alert-flyout.png b/docs/uptime/images/alert-flyout.png new file mode 100644 index 0000000000000..7fc1e3d9aefe2 Binary files /dev/null and b/docs/uptime/images/alert-flyout.png differ diff --git a/docs/uptime/images/check-history.png b/docs/uptime/images/check-history.png index 6418495eee9ed..91565bf59aa7f 100644 Binary files a/docs/uptime/images/check-history.png and b/docs/uptime/images/check-history.png differ diff --git a/docs/uptime/images/error-list.png b/docs/uptime/images/error-list.png deleted file mode 100644 index 99f017f2945a5..0000000000000 Binary files a/docs/uptime/images/error-list.png and /dev/null differ diff --git a/docs/uptime/images/monitor-charts.png b/docs/uptime/images/monitor-charts.png index dbfa43f47656e..522f34662657e 100644 Binary files a/docs/uptime/images/monitor-charts.png and b/docs/uptime/images/monitor-charts.png differ diff --git a/docs/uptime/images/observability_integrations.png b/docs/uptime/images/observability_integrations.png index d5c612c7589ca..6589c0c5565dd 100644 Binary files a/docs/uptime/images/observability_integrations.png and b/docs/uptime/images/observability_integrations.png differ diff --git a/docs/uptime/images/settings.png b/docs/uptime/images/settings.png new file mode 100644 index 0000000000000..dd36f0a6d702b Binary files /dev/null and b/docs/uptime/images/settings.png differ diff --git a/docs/uptime/images/snapshot-view.png b/docs/uptime/images/snapshot-view.png index 020396d0f3e4c..1fce2e9592c14 100644 Binary files a/docs/uptime/images/snapshot-view.png and b/docs/uptime/images/snapshot-view.png differ diff --git a/docs/uptime/images/status-bar.png b/docs/uptime/images/status-bar.png index e0e9b27555900..8d242789cdccd 100644 Binary files a/docs/uptime/images/status-bar.png and b/docs/uptime/images/status-bar.png differ diff --git a/docs/uptime/index.asciidoc b/docs/uptime/index.asciidoc index 785b9f818f5bf..a355f8ecf4843 100644 --- a/docs/uptime/index.asciidoc +++ b/docs/uptime/index.asciidoc @@ -12,8 +12,10 @@ To get started with Elastic Uptime, refer to {uptime-guide}/install-uptime.html[ * <> * <> +* <> -- include::overview.asciidoc[] include::monitor.asciidoc[] +include::settings.asciidoc[] diff --git a/docs/uptime/monitor.asciidoc b/docs/uptime/monitor.asciidoc index d54fd02c7c069..8a4be1f11a721 100644 --- a/docs/uptime/monitor.asciidoc +++ b/docs/uptime/monitor.asciidoc @@ -5,21 +5,24 @@ The Monitor page will help you get further insight into the performance of a specific network endpoint. You'll see a detailed visualization of the monitor's request duration over time, as well as the `up`/`down` -status over time. +status over time. You can also also detect anomalies in response time data +by configuring Machine Learning jobs on this page. [float] -=== Status bar +=== Status panel [role="screenshot"] image::uptime/images/status-bar.png[Status bar] -The Status bar displays a quick summary of the latest information +The Status panel displays a quick summary of the latest information regarding your monitor. You can view its latest status, click a link to visit the targeted URL, see its most recent request duration, and determine the amount of time that has elapsed since the last check. -You can use the Status bar to get a quick summary of current performance, -beyond simply knowing if the monitor is `up` or `down`. +When two Heartbeat instances are configured in different geographic locations +the map will show each location as a pinpoint on the map, along with the +amount of time elapsed since data was last received from that location. + [float] === Monitor charts @@ -32,12 +35,14 @@ date range. These charts can help you gain insight into how quickly requests are by the targeted endpoint, and give you a sense of how frequently a host or endpoint was down in your selected timespan. -The first chart displays request duration information for your monitor. +The Monitor duration chart displays request duration information for your monitor. The area surrounding the line is the range of request time for the corresponding -bucket. The line is the average time. +bucket. The line is the average time. Anomaly detection using Machine Learning +can be configured in the upper right hand of this panel. When response times change +in an unexpected way the time range in which they occurred will be given filled with a color. -Next, is a graphical representation of the check statuses over time. Hover over -the charts to display crosshairs with more specific numeric data. +The pings over time chart is a graphical representation of the check statuses over time. +Hover over the charts to display crosshairs with more specific numeric data. [role="screenshot"] image::uptime/images/crosshair-example.png[Chart crosshair] @@ -49,6 +54,6 @@ image::uptime/images/crosshair-example.png[Chart crosshair] image::uptime/images/check-history.png[Check history view] The Check history displays the total count of this monitor's checks for the selected -date range. You can additionally filter the checks by `status` to help find recent problems +date range. You can additionally filter the checks by status and location to help find recent problems on a per-check basis. This table can help you gain some insight into more granular details about recent individual data points Heartbeat is logging about your host or endpoint. diff --git a/docs/uptime/overview.asciidoc b/docs/uptime/overview.asciidoc index 098ce12a56991..71c09c968e512 100644 --- a/docs/uptime/overview.asciidoc +++ b/docs/uptime/overview.asciidoc @@ -21,12 +21,12 @@ This control allows you to use automated filter options, as well as input custom text to select specific monitors by field, URL, ID, and other attributes. [float] -=== Snapshot view +=== Snapshot panel [role="screenshot"] image::uptime/images/snapshot-view.png[Snapshot view] -This view is intended to quickly give you a sense of the overall +This panel is intended to quickly give you a sense of the overall status of the environment you're monitoring, or a subset of those monitors. Here, you can see the total number of detected monitors within the selected Uptime date range. In addition to the total, the counts for the number of monitors @@ -49,6 +49,17 @@ way to navigate to a more in-depth visualization for interesting hosts or endpoi This table includes information like the most recent status, when the monitor was last checked, its ID and URL, its IP address, and a dedicated sparkline showing its check status over time. +[float] +=== Creating and managing alerts + +[role="screenshot"] +image::uptime/images/alert-flyout.png[Create alert flyout] + +To receive alerts when a monitor goes down, use the alerting menu at the top of the +overview page. Use a query in the alert flyout to determine which monitors to check +with your alert. If you already have a query in the overview page search bar it will +be carried over into this box. + [float] === Observability integrations @@ -60,14 +71,3 @@ Docker related host information, it will provide links to open the Metrics app o for this host. Additionally, this feature supplies links to simply filter the other views on the host's IP address, to help you quickly determine if these other solutions contain data relevant to your current interest. - -[float] -=== Error list - -[role="screenshot"] -image::uptime/images/error-list.png[Error list] - -The Error list displays aggregations of errors that Heartbeat has logged. Errors are -displayed by Error type, monitor ID, and message. Clicking a monitor's ID will take you -to the corresponding Monitor view, which can provide you richer information about the individual -data points that are resulting in the displayed errors. diff --git a/docs/uptime/settings.asciidoc b/docs/uptime/settings.asciidoc new file mode 100644 index 0000000000000..55da6e802bec6 --- /dev/null +++ b/docs/uptime/settings.asciidoc @@ -0,0 +1,27 @@ +[role="xpack"] +[[uptime-settings]] + +== Settings + +[role="screenshot"] +image::uptime/images/settings.png[Filter bar] + +The Uptime settings page lets you change which Heartbeat indices are displayed +by the uptime app. Users must have the 'all' permission to modify items on this page. +Uptime settings apply to the current space only. Use different settings in different +spaces to segment different uptime use cases and domains. + +As an example, imagine your organization has one team for internal IT services, and another +for public services. Each team operates independently and is only responsible for its +own services. In this scenario, you might set up separate Heartbeat instances for each team, +writing out to index patterns named `it-heartbeat-\*`, and `external-heartbeat-\*`. You would +create separate roles and users for each in Elasticsearch, each with access to their own spaces, +named `it` and `external` respectively. Within each space you would navigate to the settings page +and set the correct index pattern to match only the indices that space is allowed to access. + +Note that the pattern set here only restricts what the Uptime app shows. Users may still be able +to manually query Elasticsearch for data outside this pattern! + +See the <> +and {heartbeat-ref}/securing-heartbeat.html[Heartbeat security] +docs for more information. diff --git a/docs/user/alerting/action-types.asciidoc b/docs/user/alerting/action-types.asciidoc index 2913bf28dd765..49e7bd1d77743 100644 --- a/docs/user/alerting/action-types.asciidoc +++ b/docs/user/alerting/action-types.asciidoc @@ -34,14 +34,23 @@ a| <> [NOTE] ============================================== -Some action types are paid commercial features, while others are free. -For a comparison of the Elastic subscription levels, -see https://www.elastic.co/subscriptions[the subscription page]. +Some action types are paid commercial features, while others are free. +For a comparison of the Elastic subscription levels, +see https://www.elastic.co/subscriptions[the subscription page]. ============================================== +[float] +[[create-connectors]] +=== Connectors + +You can create connectors for actions in <> or via the action API. +For out-of-the-box and standardized connectors, you can <> +before {kib} starts. + include::action-types/email.asciidoc[] include::action-types/index.asciidoc[] include::action-types/pagerduty.asciidoc[] include::action-types/server-log.asciidoc[] include::action-types/slack.asciidoc[] include::action-types/webhook.asciidoc[] +include::pre-configured-connectors.asciidoc[] diff --git a/docs/user/alerting/action-types/pagerduty.asciidoc b/docs/user/alerting/action-types/pagerduty.asciidoc index 50a1f31e4a9ae..da34c6e0855d7 100644 --- a/docs/user/alerting/action-types/pagerduty.asciidoc +++ b/docs/user/alerting/action-types/pagerduty.asciidoc @@ -4,19 +4,142 @@ The PagerDuty action type uses the https://v2.developer.pagerduty.com/docs/events-api-v2[v2 Events API] to trigger, acknowledge, and resolve PagerDuty alerts. +* <> +* <> +* <> + +[float] +[[pagerduty-benefits]] +=== PagerDuty + Elastic integration benefits + +By integrating PagerDuty with alerts, you can: + +* Route your alerts to the right PagerDuty responder within your team, based on your structure, escalation policies, and workflows. +* Automatically generate incidents of different types and severity based on each alert’s context. +* Tailor the incident data to match your needs by easily passing the alerting context from Kibana to PagerDuty. + +[float] +[[pagerduty-how-it-works]] +==== How it works + +{kib} allows you to create alerts to notify you of a significant move +in your dataset. +You can create alerts for all your Observability, Security, and Elastic Stack use cases. +Alerts will trigger a new incident on the corresponding PagerDuty service. + +[float] +==== Requirements + +In the `kibana.yml` configuration file, you must add the <>. +This is required to encrypt parameters that must be secured, for example PagerDuty’s integration key. + +If you have security enabled: + +* You must have +application privileges to access Metrics, APM, Uptime, or SIEM. +* If you are using a self-managed deployment with security, you must have +Transport Security Layer (TLS) enabled for communication <>. +Alerts uses API keys to secure background alert checks and actions, +and API keys require {ref}/configuring-tls.html#tls-http[TLS on the HTTP interface]. + +Although not a requirement, to harden the integrations security you might want to +review the <> that are available to you. + +[float] +[[pagerduty-support]] +==== Support +If you need help with this integration, get in touch with the {kib} team by visiting +https://support.elastic.co[support.elastic.co] or by using the *Ask Elastic* option in the {kib} Help menu. +You can also select the {kib} category at https://discuss.elastic.co/[discuss.elastic.co]. + +[float] +[[pagerduty-integration-walkthrough]] +==== Integration with PagerDuty walkthrough + +[float] +[[pagerduty-in-pagerduty]] +===== In PagerDuty + +. From the *Configuration* menu, select *Services*. +. Add an integration to a service: ++ +* If you are adding your integration to an existing service, +click the name of the service you want to add the integration to. +Then, select the *Integrations* tab and click the *New Integration* button. +* If you are creating a new service for your integration, +go to +https://support.pagerduty.com/docs/services-and-integrations#section-configuring-services-and-integrations[Configuring Services and Integrations] +and follow the steps outlined in the *Create a New Service* section, selecting *Elastic* as the *Integration Type* in step 4. +Continue with the <> section once you have finished these steps. + +. Enter an *Integration Name* in the format Elastic-service-name (for example, Elastic-Alerting or Kibana-APM-Alerting) +and select Elastic from the *Integration Type* menu. +. Click *Add Integration* to save your new integration. ++ +You will be redirected to the *Integrations* tab for your service. An Integration Key is generated on this screen. ++ +[role="screenshot"] +image::user/alerting/images/pagerduty-integration.png[PagerDuty Integrations tab] + +. Save this key, as you will use it when you configure the integration with Elastic in the next section. + +[float] +[[pagerduty-in-elastic]] +===== In Elastic + +. Create a PagerDuty Connector in Kibana. You can: ++ +* Create a connector as part of creating an alert by selecting PagerDuty in the *Actions* +section of the alert configuration and selecting *Add new*. +* Alternatively, create a connector by navigating to *Management* from the {kib} navbar and selecting +*Alerts and Actions*. Then, select the *Connectors* tab, click the *Create connector* button, and select the PagerDuty option. + +. Configure the connector by giving it a name and optionally entering the API URL and Routing Key, or using the defaults. ++ +See <> for how to obtain the endpoint and key information from PagerDuty and +<> for more details. + +. Save the Connector. + +. Create an alert using *Management > Alerts and Actions* or the application of your choice. + +. Set up an action using your PagerDuty connector, by determining: ++ +* The action’s type: Trigger, Resolve, or Acknowledge. +* The event’s severity: Info, warning, error, or critical. +* An array of different fields, including the timestamp, group, class, component, and your dedup key. +Depending on your custom needs, assign them variables from the alerting context. +To see the available context variables, click on the *Add alert variable* icon next +to each corresponding field. For more details on these parameters, see the +<> and the PagerDuty +https://v2.developer.pagerduty.com/v2/docs/send-an-event-events-api-v2[API v2 documentation]. + + +[float] +[[pagerduty-uninstall]] +==== How to uninstall +To remove a PagerDuty connector from an alert, simply remove it +from the *Actions* section of that alert, using the remove (x) icon. +This will disable the integration for the particular alert. + +To delete the connector entirely, go to *Management > Alerts and Actions*. +Select the *Connectors* tab, and then click on the delete icon. +This is an irreversible action and impacts all alerts that use this connector. + + [float] [[pagerduty-connector-configuration]] -==== Connector configuration +=== Connector configuration PagerDuty connectors have the following configuration properties: Name:: The name of the connector. The name is used to identify a connector in the management UI connector listing, or in the connector list when configuring an action. -API URL:: An optional PagerDuty event URL. Defaults to `https://events.pagerduty.com/v2/enqueue`. If you are using the <> setting, make sure the hostname is whitelisted. +API URL:: An optional PagerDuty event URL. Defaults to `https://events.pagerduty.com/v2/enqueue`. If you are using the <> setting, make sure the hostname is whitelisted. Routing Key:: A 32 character PagerDuty Integration Key for an integration on a service or on a global ruleset. [float] [[pagerduty-action-configuration]] -==== Action configuration +=== Action configuration PagerDuty actions have the following properties: @@ -26,8 +149,8 @@ Dedup Key:: All actions sharing this key will be associated with the same Pa Timestamp:: An *optional* https://v2.developer.pagerduty.com/v2/docs/types#datetime[ISO-8601 format date-time], indicating the time the event was detected or generated. Component:: An *optional* value indicating the component of the source machine that is responsible for the event, for example `mysql` or `eth0`. Group:: An *optional* value indicating the logical grouping of components of a service, for example `app-stack`. -Source:: An *optional* value indicating the affected system, preferably a hostname or fully qualified domain name. Defaults to the {kib} saved object id of the action. +Source:: An *optional* value indicating the affected system, preferably a hostname or fully qualified domain name. Defaults to the {kib} saved object id of the action. Summary:: An *optional* text summary of the event, defaults to `No summary provided`. The maximum length is 1024 characters. Class:: An *optional* value indicating the class/type of the event, for example `ping failure` or `cpu load`. -For more details on these properties, see https://v2.developer.pagerduty.com/v2/docs/send-an-event-events-api-v2[PagerDuty v2 event parameters]. \ No newline at end of file +For more details on these properties, see https://v2.developer.pagerduty.com/v2/docs/send-an-event-events-api-v2[PagerDuty v2 event parameters]. diff --git a/docs/user/alerting/images/alert-pre-configured-connectors-dropdown.png b/docs/user/alerting/images/alert-pre-configured-connectors-dropdown.png new file mode 100644 index 0000000000000..4e6c713298626 Binary files /dev/null and b/docs/user/alerting/images/alert-pre-configured-connectors-dropdown.png differ diff --git a/docs/user/alerting/images/alert-pre-configured-slack-connector.png b/docs/user/alerting/images/alert-pre-configured-slack-connector.png new file mode 100644 index 0000000000000..de05e2074ddde Binary files /dev/null and b/docs/user/alerting/images/alert-pre-configured-slack-connector.png differ diff --git a/docs/user/alerting/images/pagerduty-integration.png b/docs/user/alerting/images/pagerduty-integration.png new file mode 100755 index 0000000000000..0a270de866b36 Binary files /dev/null and b/docs/user/alerting/images/pagerduty-integration.png differ diff --git a/docs/user/alerting/images/pre-configured-connectors-managing.png b/docs/user/alerting/images/pre-configured-connectors-managing.png new file mode 100644 index 0000000000000..f97e93175fa36 Binary files /dev/null and b/docs/user/alerting/images/pre-configured-connectors-managing.png differ diff --git a/docs/user/alerting/images/pre-configured-connectors-view-screen.png b/docs/user/alerting/images/pre-configured-connectors-view-screen.png new file mode 100644 index 0000000000000..43ac44e7536d8 Binary files /dev/null and b/docs/user/alerting/images/pre-configured-connectors-view-screen.png differ diff --git a/docs/user/alerting/pre-configured-connectors.asciidoc b/docs/user/alerting/pre-configured-connectors.asciidoc new file mode 100644 index 0000000000000..3db13acfb423e --- /dev/null +++ b/docs/user/alerting/pre-configured-connectors.asciidoc @@ -0,0 +1,88 @@ +[role="xpack"] +[[pre-configured-connectors]] + +== Preconfigured connectors + +You can preconfigure an action connector to have all the information it needs prior to startup +by adding it to the `kibana.yml` file. +Sensitive configuration information, such as credentials, can use the {kib} keystore. + +Preconfigured connectors offer the following capabilities: + +- Require no setup. Configuration and credentials needed to execute an +action are predefined, including the connector name and ID. +- Appear in all spaces because they are not saved objects. +- Cannot be edited or deleted. + +[float] +[[preconfigured-connector-example]] +=== Example of a preconfigured connector + +The following example shows a valid configuration 2 out-of-the box connector. + +[source,console] +------------------------ + xpack.actions.preconfigured: + - id: 'my-slack1' <1> + actionTypeId: .slack <2> + name: 'Slack #xyz' <3> + config: <4> + webhookUrl: 'https://hooks.slack.com/services/abcd/efgh/ijklmnopqrstuvwxyz' + - id: 'webhook-service' + actionTypeId: .webhook + name: 'Email service' + config: + url: 'https://email-alert-service.elastic.co' + method: post + headers: + header1: value1 + header2: value2 + secrets: <5> + user: elastic + password: changeme +------------------------ + +<1> `id` is the action connector identifier. +<2> `actionTypeId` is the action type identifier. +<3> `name` is the name of the preconfigured connector. +<4> `config` is the action type specific to the configuration. +<5> `secrets` is sensitive configuration, such as username, password, and keys. + +[NOTE] +============================================== +Sensitive properties, such as passwords, can also be stored in the {kib} keystore. +============================================== + +[float] +[[pre-configured-connector-alert-form]] +=== Creating an alert with a preconfigured connector + +When attaching an action to an alert, +select from a list of available action types, and +then select the Slack or Webhook type. Those action types were configured previously. +The preconfigured connector is installed and is automatically selected. + +[role="screenshot"] +image::images/alert-pre-configured-slack-connector.png[Create alert with selected Slack action type] + +The dropdown is populated with additional preconfigured Slack connectors. +The `preconfigured` label distinguishes them from space-aware connectors that use saved objects. + +[role="screenshot"] +image::images/alert-pre-configured-connectors-dropdown.png[Dropdown list with pre-cofigured connectors] + +[float] +[[managing-pre-configured-connectors]] +=== Managing preconfigured connectors + +Preconfigured connectors appear in the connector list, regardless of which space the user is in. +They are tagged as “preconfigured” and cannot be deleted. + +[role="screenshot"] +image::images/pre-configured-connectors-managing.png[Connectors managing tab with pre-cofigured] + +Clicking on a preconfigured connector shows the description, but not any of the configuration. +A message indicates that this is a preconfigured connector. + +[role="screenshot"] +image::images/pre-configured-connectors-view-screen.png[Pre-configured connector view details] diff --git a/docs/user/dashboard.asciidoc b/docs/user/dashboard.asciidoc index ab529a533d5e3..de714ae40086b 100644 --- a/docs/user/dashboard.asciidoc +++ b/docs/user/dashboard.asciidoc @@ -98,6 +98,24 @@ to the new dimensions. * To delete a panel, open the panel menu and select *Delete from dashboard.* Deleting a panel from a dashboard does *not* delete the saved visualization or search. +[float] +[[cloning-a-panel]] +=== Clone dashboard elements + +In *Edit* mode, you can clone any panel on a dashboard. + +To clone an existing panel, open the panel menu of the element you wish to clone, then select *Clone panel*. + +* Cloned panels appear beside the original, and will move other panels down to make room if necessary. + +* Clones support all of the original panel's functionality, including renaming, editing, and cloning. + +* All cloned visualizations will appear in the visualization list. + +[role="screenshot"] +image:images/clone_panel.gif[clone panel] + + [float] [[viewing-detailed-information]] === Inspect and edit elements diff --git a/docs/user/management.asciidoc b/docs/user/management.asciidoc index fa34802abe2a9..a4ba320e826b1 100644 --- a/docs/user/management.asciidoc +++ b/docs/user/management.asciidoc @@ -13,7 +13,7 @@ indices, clusters, licenses, UI settings, index patterns, spaces, and more. [cols="50, 50"] |=== -a| <> +a| <> Replicate indices on a remote cluster and copy them to a follower index on a local cluster. This is important for @@ -85,7 +85,8 @@ set the timespan for notification messages, and much more. | <> -Centrally manage your alerts from across {kib}. Create and manage re-usable connectors for triggering actions. +Centrally manage your alerts across {kib}. Create and manage reusable +connectors for triggering actions. | <> @@ -125,6 +126,8 @@ include::{kib-repo-dir}/management/alerting/connector-management.asciidoc[] include::{kib-repo-dir}/management/managing-beats.asciidoc[] +include::{kib-repo-dir}/management/managing-ccr.asciidoc[] + include::{kib-repo-dir}/management/index-lifecycle-policies/intro-to-lifecycle-policies.asciidoc[] include::{kib-repo-dir}/management/index-lifecycle-policies/create-policy.asciidoc[] diff --git a/docs/user/ml/images/ml-data-visualizer-sample.jpg b/docs/user/ml/images/ml-data-visualizer-sample.jpg index 6c2e018932717..ce2bb660d7da1 100644 Binary files a/docs/user/ml/images/ml-data-visualizer-sample.jpg and b/docs/user/ml/images/ml-data-visualizer-sample.jpg differ diff --git a/docs/user/ml/index.asciidoc b/docs/user/ml/index.asciidoc index cca0dc5e4530f..e9ef4a55b2b3a 100644 --- a/docs/user/ml/index.asciidoc +++ b/docs/user/ml/index.asciidoc @@ -4,31 +4,31 @@ [partintro] -- -As datasets increase in size and complexity, the human effort required to +As data sets increase in size and complexity, the human effort required to inspect dashboards or maintain rules for spotting infrastructure problems, cyber attacks, or business issues becomes impractical. Elastic {ml-features} such as {anomaly-detect} and {oldetection} make it easier to notice suspicious activities with minimal human interference. -If you have a basic license, you can use the *Data Visualizer* to learn more -about your data. In particular, if your data is stored in {es} and contains a -time field, you can use the *Data Visualizer* to identify possible fields for -{anomaly-detect}: +{kib} includes a free *{data-viz}* to learn more about your data. In particular, +if your data is stored in {es} and contains a time field, you can use the +*{data-viz}* to identify possible fields for {anomaly-detect}: [role="screenshot"] -image::user/ml/images/ml-data-visualizer-sample.jpg[Data Visualizer for sample flight data] +image::user/ml/images/ml-data-visualizer-sample.jpg[{data-viz} for sample flight data] -experimental[] You can also upload a CSV, NDJSON, or log file (up to 100 MB in -size). The *Data Visualizer* identifies the file format and field mappings. You -can then optionally import that data into an {es} index. +experimental[] You can also upload a CSV, NDJSON, or log file. The *{data-viz}* +identifies the file format and field mappings. You can then optionally import +that data into an {es} index. To change the default file size limit, see +<>. -You need the following permissions to use the Data Visualizer with file upload: +You need the following permissions to use the {data-viz} with file upload: * cluster privileges: `monitor`, `manage_ingest_pipelines` * index privileges: `read`, `manage`, `index` For more information, see {ref}/security-privileges.html[Security privileges] -and {ref}/built-in-roles.html[Built-in roles]. +and {ml-docs}/setup.html[Set up {ml-features}]. -- diff --git a/docs/visualize/vega.asciidoc b/docs/visualize/vega.asciidoc index b8c0d1dbe3dda..e0d9955f0c3db 100644 --- a/docs/visualize/vega.asciidoc +++ b/docs/visualize/vega.asciidoc @@ -1,81 +1,80 @@ [[vega-graph]] -== Vega Graphs -experimental[] +== Vega -You can build https://vega.github.io/vega/examples/[Vega] and -https://vega.github.io/vega-lite/examples/[Vega-Lite] data visualizations -into Kibana, either standalone, or on top of a map. To see Vega in action, -watch this -https://www.youtube.com/watch?v=lQGCipY3th8[short introduction video]. +experimental[] -Currently Vega version 4.3 and Vega-Lite version 2.6 are supported. +Build custom visualizations from multiple data sources using Vega +and Vega-Lite. -NOTE: In Vega it is possible to load data dynamically, e.g. by setting signals as data urls. This is not supported in Kibana as all data is fetched at once prior to passing it to the Vega renderer. +* *Vega* — A declarative format to create visualizations using JSON. + Generate interactive displays using D3. +* *Vega-Lite* — An easier format to use than Vega that enables more rapid + data analysis. Compiles into Vega. -[[vega-quick-demo]] -=== Getting Started with Vega +For more information about Vega and Vega-Lite, refer to +<>. -* To experiment using sample data, first click the {kib} logo in the upper left hand corner -and then click the link next to *Sample Data*. -* Once you have data loaded, go to *Visualize*, click *+*, and select *Vega* to see an example graph. -*Note*: The default graph is written in Vega-Lite, but you can build visualizations -in either language. See <> for more information. -* Try changing `mark` from `line` to `point`, `area`, `bar`, `circle`, -or `square`. Check out the -https://vega.github.io/vega-lite/docs/mark.html#mark-def[Vega-Lite docs] for more information. -* Explore other available https://vega.github.io/vega/examples/[Vega] or -https://vega.github.io/vega-lite/examples/[Vega-Lite] visualizations. -*Note*: You might need to make URLs absolute, for example, replace -`"url": "data/world-110m.json"` with -`"url": "https://vega.github.io/editor/data/world-110m.json"`. -See <>. -* For more information on getting started, check out this https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana[blog post]. +[float] +[[create-vega-viz]] +=== Create Vega visualizations +You create Vega visualizations by using the text editor, which is +preconfigured with the options you need. -[[vega-vs-vegalite]] -=== Vega vs Vega-Lite +[role="screenshot"] +image::images/vega_lite_default.png[] -The Vega visualization in {kib} supports both Vega and Vega-Lite. You can use the -`schema` value to define which language you would like to use and its minimum -required version. +[float] +[[vega-schema]] +==== Change the Vega version -For example: +The default visualization uses Vega-Lite version 2. To use Vega version 4, edit +the `schema`. -* Vega-Lite v2: `$schema: https://vega.github.io/schema/vega-lite/v2.json` -* Vega v4: `$schema: https://vega.github.io/schema/vega/v4.json` +Go to `$schema`, enter `https://vega.github.io/schema/vega/v4.json`, then click +*Update*. -The `schema` URL is only used for identification, and does not need to be accessible by {kib}. +[float] +[[vega-type]] +==== Change the visualization type -Vega-Lite is a simplified version of Vega; it automates some constructions and has -much shorter specifications than Vega. Vega-Lite is automatically converted into -Vega before rendering, but it has some limitations, and there are some visualizations -that can be expressed in Vega that cannot be expressed in Vega-Lite. You can learn more -in the https://vega.github.io/vega-lite/[Vega-Lite documentation]. +The default visualization is a line chart. To change the visualization type, +change the `mark` value. The supported visualization types are listed in the +text editor. -You can use https://vega.github.io/editor/[this editor] to convert Vega-Lite into -Vega. +Go to `mark`, change the value to a different visualization type, then click +*Update*. -When you create a Vega visualization in {kib}, you can edit the `schema` -value in the dev tools to the left of the graph to define which of the two expression -languages you would like to use. +[float] +[[vega-sizing-and-positioning]] +==== Change the layout +By default, Vega visualizations use the `autosize = { type: 'fit', contains: 'padding' }` layout. +`fit` uses all available space, ignores `width` and `height` values, +and respects the padding values. To override this behavior, change the +`autosize` value. [[vega-querying-elasticsearch]] -=== Querying Elasticsearch +=== Query {es} -By default, Vega's https://vega.github.io/vega/docs/data/[data] element -can use embedded and external data with a `"url"` parameter. Kibana adds support for the direct Elasticsearch queries by overloading +experimental[] Vega https://vega.github.io/vega/docs/data/[data] elements +use embedded and external data with a `"url"` parameter. {kib} adds support for +direct {es} queries by overloading the `"url"` value. -Here is an example of an Elasticsearch query that counts the number of documents in all indexes. The query uses *@timestamp* field to filter the time range, and break it into histogram buckets. +NOTE: With Vega, you dynamically load your data by setting signals as data URLs. +Since {kib} is unable to support dynamically loaded data, all data is fetched +before it's passed to the Vega renderer. + +For example, count the number of documents in all indices: [source,yaml] ---- -// An object instead of a string for the url value +// An object instead of a string for the URL value // is treated as a context-aware Elasticsearch query. url: { - // Specify the time filter (upper right corner) with this field + // Specify the time filter. %timefield%: @timestamp // Apply dashboard context filters when set %context%: true @@ -88,8 +87,8 @@ url: { time_buckets: { date_histogram: { // Use date histogram aggregation on @timestamp field - field: @timestamp - // interval value will depend on the daterange picker + field: @timestamp <1> + // interval value will depend on the time filter // Use an integer to set approximate bucket count interval: { %autointerval%: true } // Make sure we get an entire range, even if it has no data @@ -109,7 +108,10 @@ url: { } ---- -The full result has this kind of structure: +<1> `@timestamp` — Filters the time range and breaks it into histogram +buckets. + +The full result includes the following structure: [source,yaml] ---- @@ -118,23 +120,24 @@ The full result has this kind of structure: "time_buckets": { "buckets": [{ "key_as_string": "2015-11-30T22:00:00.000Z", - "key": 1448920800000, + "key": 1448920800000,<1> "doc_count": 28 }, { "key_as_string": "2015-11-30T23:00:00.000Z", - "key": 1448924400000, + "key": 1448924400000, <1> "doc_count": 330 }, ... ---- -Note that `"key"` is a unix timestamp, and can be used without conversions by the +<1> `"key"` — The unix timestamp you can use without conversions by the Vega date expressions. -For most graphs we only need the list of the bucket values, so we use `format: {property: "aggregations.time_buckets.buckets"}` expression to focus on just the data we need. +For most visualizations, you only need the list of bucket values. To focus on +only the data you need, use `format: {property: "aggregations.time_buckets.buckets"}`. -Query may be specified with individual range and dashboard context as -well. This query is equivalent to `"%context%": true, "%timefield%": "@timestamp"`, -except that the timerange is shifted back by 10 minutes: +Specify a query with individual range and dashboard context. The query is +equivalent to `"%context%": true, "%timefield%": "@timestamp"`, +except that the time range is shifted back by 10 minutes: [source,yaml] ---- @@ -185,9 +188,9 @@ on the currently picked range: `"interval": {"%autointerval%": 10}` will try to get about 10-15 data points (buckets). [[vega-esmfiles]] -=== Elastic Map Files +=== Access Elastic Map Service files -It is possible to access Elastic Map Service's files via the same mechanism +experimental[] Access the Elastic Map Service files via the same mechanism: [source,yaml] ---- @@ -203,11 +206,8 @@ url: { format: {property: "features"} ---- -[[vega-with-a-map]] -=== Vega with a Map - -Kibana's default map can be used as a base of the Vega graph. To enable, -the graph must specify `type=map` in the host configuration: +To enable Elastic Maps, the graph must specify `type=map` in the host +configuration: [source,yaml] ---- @@ -247,42 +247,47 @@ the graph must specify `type=map` in the host configuration: } ---- -This visualization will automatically inject a projection called -`"projection"`. Use it to calculate positioning of all geo-aware marks. -Additionally, you may use `latitude`, `longitude`, and `zoom` signals. +The visualization automatically injects a `"projection"`, which you can use to +calculate the position of all geo-aware marks. +Additionally, you can use `latitude`, `longitude`, and `zoom` signals. These signals can be used in the graph, or can be updated to modify the -positioning of the map. +position of the map. + +Vega visualization ignore the `autosize`, `width`, `height`, and `padding` +values, using `fit` model with zero padding. [[vega-debugging]] -=== Debugging +=== Debugging Vega [[vega-browser-debugging-console]] -==== Browser Debugging console +==== Browser debugging console -Use browser debugging tools (e.g. F12 or Ctrl+Shift+J in Chrome) to +experimental[] Use browser debugging tools (for example, F12 or Ctrl+Shift+J in Chrome) to inspect the `VEGA_DEBUG` variable: -* `view` - access to the Vega View object. See https://vega.github.io/vega/docs/api/debugging/[Vega Debugging Guide] - on how to inspect data and signals at runtime. For Vega-Lite, `VEGA_DEBUG.view.data('source_0')` gets the main data set. - For Vega, it uses the data name as defined in your Vega spec. -* `vega_spec` - Vega JSON graph specification after some modifications by Kibana. In case ++ +* `view` — Access to the Vega View object. See https://vega.github.io/vega/docs/api/debugging/[Vega Debugging Guide] +on how to inspect data and signals at runtime. For Vega-Lite, `VEGA_DEBUG.view.data('source_0')` gets the main data set. +For Vega, it uses the data name as defined in your Vega spec. + +* `vega_spec` — Vega JSON graph specification after some modifications by {kib}. In case of Vega-Lite, this is the output of the Vega-Lite compiler. -* `vegalite_spec` - If this is a Vega-Lite graph, JSON specification of the graph before + +* `vegalite_spec` — If this is a Vega-Lite graph, JSON specification of the graph before Vega-Lite compilation. [[vega-data]] ==== Data -If you are using Elasticsearch query, make sure your resulting data is -what you expected. The easiest way to view it is by using "networking" -tab in the browser debugging tools (e.g. F12). Modify the graph slightly +experimental[] If you are using an {es} query, make sure your resulting data is +what you expected. The easiest way to view it is by using the "networking" +tab in the browser debugging tools (for example, F12). Modify the graph slightly so that it makes a search request, and view the response from the server. Another approach is to use -https://www.elastic.co/guide/en/kibana/current/console-kibana.html[Kibana -Dev Tools] tab - place the index name into the first line: -`GET /_search`, and add your query as the following lines -(just the value of the `"query"` field) +https://www.elastic.co/guide/en/kibana/current/console-kibana.html[Dev Tools]. Place the index name into the first line: +`GET /_search`, then add your query as the following lines +(just the value of the `"query"` field). -If you need to share your graph with someone, you may want to copy the +If you need to share your graph with someone, copy the raw data response to https://gist.github.com/[gist.github.com], possibly with a `.json` extension, use the `[raw]` button, and use that url directly in your graph. @@ -292,9 +297,11 @@ to your kibana.yml file. [[vega-notes]] [[vega-useful-links]] -=== Useful Links +=== Resources and examples + +experimental[] To learn more about Vega and Vega-List, refer to the resources and examples. -==== Vega Editor +==== Vega editor The https://vega.github.io/editor/[Vega Editor] includes examples for Vega & Vega-Lite, but does not support any {kib}-specific features like {es} requests and interactive base maps. @@ -308,28 +315,15 @@ The https://vega.github.io/editor/[Vega Editor] includes examples for Vega & Veg * https://vega.github.io/vega/docs/[Docs] * https://vega.github.io/vega/examples/[Examples] -==== Elastic blog posts -* https://www.elastic.co/blog/getting-started-with-vega-visualizations-in-kibana[Getting Started with Vega Visualizations in Kibana] -* https://www.elastic.co/blog/custom-vega-visualizations-in-kibana[Custom Vega Visualizations in Kibana] -* https://www.elastic.co/blog/sankey-visualization-with-vega-in-kibana[Sankey Visualization with Vega in Kibana] - - -[[vega-using-vega-and-vegalite-examples]] -==== Using Vega and Vega-Lite examples - -When using https://vega.github.io/vega/examples/[Vega] and -https://vega.github.io/vega-lite/examples/[VegaLite] examples, you may +TIP: When you use the examples, you may need to modify the "data" section to use absolute URL. For example, replace `"url": "data/world-110m.json"` with -`"url": "https://vega.github.io/editor/data/world-110m.json"`. Also, -regular Vega examples use `"autosize": "pad"` layout model, whereas -Kibana uses `fit`. Remove all `autosize`, `width`, and `height` -values. See link:#sizing-and-positioning[sizing and positioning]. +`"url": "https://vega.github.io/editor/data/world-110m.json"`. [[vega-additional-configuration-options]] ==== Additional configuration options -These options are specific to the Kibana. link:#vega-with-a-map[Map support] has +These options are specific to the {kib}. link:#vega-with-a-map[Map support] has additional configuration options. [source,yaml] @@ -351,21 +345,3 @@ additional configuration options. /* the rest of Vega code */ } ---- - -[[vega-sizing-and-positioning]] -==== Sizing and positioning - -[[vega-and-vegalite]] -===== Vega and Vega-Lite - -By default, Kibana Vega graphs will use -`autosize = { type: 'fit', contains: 'padding' }` layout model for Vega -and Vega-Lite graphs. The `fit` model uses all available space, ignores -`width` and `height` values, but respects the padding values. You may -override this behaviour by specifying a different `autosize` value. - -[[vega-on-a-map]] -===== Vega on a map - -All Vega graphs will ignore `autosize`, `width`, `height`, and `padding` -values, using `fit` model with zero padding. diff --git a/examples/embeddable_examples/server/todo_saved_object.ts b/examples/embeddable_examples/server/todo_saved_object.ts index 0f67c53cfa3e1..58da2014de498 100644 --- a/examples/embeddable_examples/server/todo_saved_object.ts +++ b/examples/embeddable_examples/server/todo_saved_object.ts @@ -22,7 +22,7 @@ import { SavedObjectsType } from 'kibana/server'; export const todoSavedObject: SavedObjectsType = { name: 'todo', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { title: { diff --git a/examples/state_containers_examples/public/todo/app.tsx b/examples/state_containers_examples/public/todo/app.tsx index 319680d07f9bc..f2183613e4a12 100644 --- a/examples/state_containers_examples/public/todo/app.tsx +++ b/examples/state_containers_examples/public/todo/app.tsx @@ -20,7 +20,7 @@ import { AppMountParameters } from 'kibana/public'; import ReactDOM from 'react-dom'; import React from 'react'; -import { createHashHistory, createBrowserHistory } from 'history'; +import { createHashHistory } from 'history'; import { TodoAppPage } from './todo'; export interface AppOptions { @@ -35,13 +35,10 @@ export enum History { } export const renderApp = ( - { appBasePath, element }: AppMountParameters, + { appBasePath, element, history: platformHistory }: AppMountParameters, { appInstanceId, appTitle, historyType }: AppOptions ) => { - const history = - historyType === History.Browser - ? createBrowserHistory({ basename: appBasePath }) - : createHashHistory(); + const history = historyType === History.Browser ? platformHistory : createHashHistory(); ReactDOM.render( = ({ filter }) => { return ( <>
- + All - + Completed - + Not Completed @@ -121,6 +124,7 @@ const TodoApp: React.FC = ({ filter }) => { }); }} label={todo.text} + data-test-subj={`todoCheckbox-${todo.id}`} /> { - const history = createBrowserHistory({ basename: appBasePath }); const kbnUrlStateStorage = createKbnUrlStateStorage({ useHash: false, history }); ReactDOM.render( diff --git a/package.json b/package.json index fe672ef130456..21e9f67e6206a 100644 --- a/package.json +++ b/package.json @@ -119,8 +119,8 @@ "dependencies": { "@babel/core": "^7.9.0", "@babel/register": "^7.9.0", - "@elastic/apm-rum": "^4.6.0", - "@elastic/charts": "18.2.2", + "@elastic/apm-rum": "^5.1.1", + "@elastic/charts": "18.3.0", "@elastic/datemath": "5.0.3", "@elastic/ems-client": "7.8.0", "@elastic/eui": "21.0.1", diff --git a/packages/kbn-config-schema/src/index.ts b/packages/kbn-config-schema/src/index.ts index fc3e3c541846a..5d387f327e58f 100644 --- a/packages/kbn-config-schema/src/index.ts +++ b/packages/kbn-config-schema/src/index.ts @@ -60,6 +60,7 @@ import { export { ObjectType, TypeOf, Type }; export { ByteSizeValue } from './byte_size_value'; export { SchemaTypeError, ValidationError } from './errors'; +export { isConfigSchema } from './typeguards'; function any(options?: TypeOptions) { return new AnyType(options); diff --git a/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts b/packages/kbn-config-schema/src/typeguards/index.ts similarity index 93% rename from src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts rename to packages/kbn-config-schema/src/typeguards/index.ts index 1030e971d6450..e724878eb33e9 100644 --- a/src/legacy/core_plugins/vis_type_table/public/legacy_imports.ts +++ b/packages/kbn-config-schema/src/typeguards/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { npSetup, npStart } from 'ui/new_platform'; +export { isConfigSchema } from './is_config_schema'; diff --git a/packages/kbn-config-schema/src/typeguards/is_config_schema.test.ts b/packages/kbn-config-schema/src/typeguards/is_config_schema.test.ts new file mode 100644 index 0000000000000..e0ef3835ca0a3 --- /dev/null +++ b/packages/kbn-config-schema/src/typeguards/is_config_schema.test.ts @@ -0,0 +1,56 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { schema } from '..'; +import { isConfigSchema } from './is_config_schema'; + +describe('isConfigSchema', () => { + it('returns true for every sub classes of `Type`', () => { + expect(isConfigSchema(schema.any())).toBe(true); + expect(isConfigSchema(schema.arrayOf(schema.string()))).toBe(true); + expect(isConfigSchema(schema.boolean())).toBe(true); + expect(isConfigSchema(schema.buffer())).toBe(true); + expect(isConfigSchema(schema.byteSize())).toBe(true); + expect(isConfigSchema(schema.duration())).toBe(true); + expect(isConfigSchema(schema.literal(''))).toBe(true); + expect(isConfigSchema(schema.mapOf(schema.string(), schema.number()))).toBe(true); + expect(isConfigSchema(schema.nullable(schema.string()))).toBe(true); + expect(isConfigSchema(schema.number())).toBe(true); + expect(isConfigSchema(schema.object({}))).toBe(true); + expect(isConfigSchema(schema.oneOf([schema.string()]))).toBe(true); + expect(isConfigSchema(schema.recordOf(schema.string(), schema.object({})))).toBe(true); + expect(isConfigSchema(schema.string())).toBe(true); + expect(isConfigSchema(schema.stream())).toBe(true); + }); + + it('returns false for every javascript data type', () => { + expect(isConfigSchema('foo')).toBe(false); + expect(isConfigSchema(42)).toBe(false); + expect(isConfigSchema(new Date())).toBe(false); + expect(isConfigSchema(null)).toBe(false); + expect(isConfigSchema(undefined)).toBe(false); + expect(isConfigSchema([1, 2, 3])).toBe(false); + expect(isConfigSchema({ foo: 'bar' })).toBe(false); + expect(isConfigSchema(function() {})).toBe(false); + }); + + it('returns true as long as `__isKbnConfigSchemaType` is true', () => { + expect(isConfigSchema({ __isKbnConfigSchemaType: true })).toBe(true); + }); +}); diff --git a/packages/kbn-config-schema/src/typeguards/is_config_schema.ts b/packages/kbn-config-schema/src/typeguards/is_config_schema.ts new file mode 100644 index 0000000000000..20e68ab2ead25 --- /dev/null +++ b/packages/kbn-config-schema/src/typeguards/is_config_schema.ts @@ -0,0 +1,24 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Type } from '../types'; + +export function isConfigSchema(obj: any): obj is Type { + return obj ? obj.__isKbnConfigSchemaType === true : false; +} diff --git a/packages/kbn-config-schema/src/types/object_type.test.ts b/packages/kbn-config-schema/src/types/object_type.test.ts index 47a0f5f7a5491..5ab59d1c02077 100644 --- a/packages/kbn-config-schema/src/types/object_type.test.ts +++ b/packages/kbn-config-schema/src/types/object_type.test.ts @@ -18,6 +18,7 @@ */ import { schema } from '..'; +import { TypeOf } from './object_type'; test('returns value by default', () => { const type = schema.object({ @@ -350,3 +351,26 @@ test('unknowns = `ignore` affects only own keys', () => { }) ).toThrowErrorMatchingInlineSnapshot(`"[foo.baz]: definition for this key is missing"`); }); + +test('handles optional properties', () => { + const type = schema.object({ + required: schema.string(), + optional: schema.maybe(schema.string()), + }); + + type SchemaType = TypeOf; + + let foo: SchemaType = { + required: 'foo', + }; + foo = { + required: 'hello', + optional: undefined, + }; + foo = { + required: 'hello', + optional: 'bar', + }; + + expect(foo).toBeDefined(); +}); diff --git a/packages/kbn-config-schema/src/types/object_type.ts b/packages/kbn-config-schema/src/types/object_type.ts index 5a50e714a5931..fee2d02c1bfb9 100644 --- a/packages/kbn-config-schema/src/types/object_type.ts +++ b/packages/kbn-config-schema/src/types/object_type.ts @@ -26,9 +26,26 @@ export type Props = Record>; export type TypeOf> = RT['type']; +type OptionalProperties = Pick< + Base, + { + [Key in keyof Base]: undefined extends TypeOf ? Key : never; + }[keyof Base] +>; + +type RequiredProperties = Pick< + Base, + { + [Key in keyof Base]: undefined extends TypeOf ? never : Key; + }[keyof Base] +>; + // Because of https://github.com/Microsoft/TypeScript/issues/14041 // this might not have perfect _rendering_ output, but it will be typed. -export type ObjectResultType

= Readonly<{ [K in keyof P]: TypeOf }>; +export type ObjectResultType

= Readonly< + { [K in keyof OptionalProperties

]?: TypeOf } & + { [K in keyof RequiredProperties

]: TypeOf } +>; interface UnknownOptions { /** @@ -40,9 +57,7 @@ interface UnknownOptions { unknowns?: 'allow' | 'ignore' | 'forbid'; } -export type ObjectTypeOptions

= TypeOptions< - { [K in keyof P]: TypeOf } -> & +export type ObjectTypeOptions

= TypeOptions> & UnknownOptions; export class ObjectType

extends Type> { diff --git a/packages/kbn-config-schema/src/types/type.ts b/packages/kbn-config-schema/src/types/type.ts index 6d5ddf6b24afb..5ca16c61399e7 100644 --- a/packages/kbn-config-schema/src/types/type.ts +++ b/packages/kbn-config-schema/src/types/type.ts @@ -32,6 +32,9 @@ export abstract class Type { // sets the value to `null` while still keeping the type. public readonly type: V = null! as V; + // used for the `isConfigSchema` typeguard + public readonly __isKbnConfigSchemaType = true; + /** * Internal "schema" backed by Joi. * @type {Schema} diff --git a/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts b/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts index d67b957416753..cc564dd4a8387 100644 --- a/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts +++ b/packages/kbn-optimizer/src/optimizer/optimizer_config.test.ts @@ -146,6 +146,7 @@ describe('OptimizerConfig::parseOptions()', () => { /x-pack/plugins, /plugins, /examples, + /x-pack/examples, -extra, ], "profileWebpack": false, diff --git a/packages/kbn-optimizer/src/optimizer/optimizer_config.ts b/packages/kbn-optimizer/src/optimizer/optimizer_config.ts index 1c8ae265bf6bb..7e1514058446b 100644 --- a/packages/kbn-optimizer/src/optimizer/optimizer_config.ts +++ b/packages/kbn-optimizer/src/optimizer/optimizer_config.ts @@ -91,14 +91,14 @@ export class OptimizerConfig { /** * BEWARE: this needs to stay roughly synchronized with - * `src/core/server/config/env.ts` which determins which paths + * `src/core/server/config/env.ts` which determines which paths * should be searched for plugins to load */ const pluginScanDirs = options.pluginScanDirs || [ Path.resolve(repoRoot, 'src/plugins'), ...(oss ? [] : [Path.resolve(repoRoot, 'x-pack/plugins')]), Path.resolve(repoRoot, 'plugins'), - ...(examples ? [Path.resolve('examples')] : []), + ...(examples ? [Path.resolve('examples'), Path.resolve('x-pack/examples')] : []), Path.resolve(repoRoot, '../kibana-extra'), ]; if (!pluginScanDirs.every(p => Path.isAbsolute(p))) { diff --git a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts b/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts index 03075dd4081fd..3a66ba22ccf3d 100644 --- a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts +++ b/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts @@ -30,6 +30,7 @@ import { setupMocha, runTests, Config, + SuiteTracker, } from './lib'; export class FunctionalTestRunner { @@ -52,6 +53,8 @@ export class FunctionalTestRunner { async run() { return await this._run(async (config, coreProviders) => { + SuiteTracker.startTracking(this.lifecycle, this.configFile); + const providers = new ProviderCollection(this.log, [ ...coreProviders, ...readProviderSpec('Service', config.get('services')), diff --git a/packages/kbn-test/src/functional_test_runner/lib/index.ts b/packages/kbn-test/src/functional_test_runner/lib/index.ts index 8940eccad503a..2e534974e1d76 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/index.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/index.ts @@ -23,3 +23,4 @@ export { readConfigFile, Config } from './config'; export { readProviderSpec, ProviderCollection, Provider } from './providers'; export { runTests, setupMocha } from './mocha'; export { FailureMetadata } from './failure_metadata'; +export { SuiteTracker } from './suite_tracker'; diff --git a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts new file mode 100644 index 0000000000000..b6c2c0a6d511d --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.test.ts @@ -0,0 +1,197 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import fs from 'fs'; +import { join, resolve } from 'path'; + +jest.mock('fs'); +jest.mock('@kbn/dev-utils', () => { + return { REPO_ROOT: '/dev/null/root' }; +}); + +import { REPO_ROOT } from '@kbn/dev-utils'; +import { Lifecycle } from './lifecycle'; +import { SuiteTracker } from './suite_tracker'; + +const DEFAULT_TEST_METADATA_PATH = join(REPO_ROOT, 'target', 'test_metadata.json'); +const MOCK_CONFIG_PATH = join('test', 'config.js'); +const MOCK_TEST_PATH = join('test', 'apps', 'test.js'); +const ENVS_TO_RESET = ['TEST_METADATA_PATH']; + +describe('SuiteTracker', () => { + const originalEnvs: Record = {}; + + beforeEach(() => { + for (const env of ENVS_TO_RESET) { + if (env in process.env) { + originalEnvs[env] = process.env[env] || ''; + delete process.env[env]; + } + } + }); + + afterEach(() => { + for (const env of ENVS_TO_RESET) { + delete process.env[env]; + } + + for (const env of Object.keys(originalEnvs)) { + process.env[env] = originalEnvs[env]; + } + + jest.resetAllMocks(); + }); + + let MOCKS: Record; + + const createMock = (overrides = {}) => { + return { + file: resolve(REPO_ROOT, MOCK_TEST_PATH), + title: 'A Test', + suiteTag: MOCK_TEST_PATH, + ...overrides, + }; + }; + + const runLifecycleWithMocks = async (mocks: object[], fn: (objs: any) => any = () => {}) => { + const lifecycle = new Lifecycle(); + const suiteTracker = SuiteTracker.startTracking( + lifecycle, + resolve(REPO_ROOT, MOCK_CONFIG_PATH) + ); + + const ret = { lifecycle, suiteTracker }; + + for (const mock of mocks) { + await lifecycle.beforeTestSuite.trigger(mock); + } + + if (fn) { + fn(ret); + } + + for (const mock of mocks.reverse()) { + await lifecycle.afterTestSuite.trigger(mock); + } + + return ret; + }; + + beforeEach(() => { + MOCKS = { + WITH_TESTS: createMock({ tests: [{}] }), // i.e. a describe with tests in it + WITHOUT_TESTS: createMock(), // i.e. a describe with only other describes in it + }; + }); + + it('collects metadata for a single suite with multiple describe()s', async () => { + const { suiteTracker } = await runLifecycleWithMocks([MOCKS.WITHOUT_TESTS, MOCKS.WITH_TESTS]); + + const suites = suiteTracker.getAllFinishedSuites(); + expect(suites.length).toBe(1); + const suite = suites[0]; + + expect(suite).toMatchObject({ + config: MOCK_CONFIG_PATH, + file: MOCK_TEST_PATH, + tag: MOCK_TEST_PATH, + hasTests: true, + success: true, + }); + }); + + it('writes metadata to a file when cleanup is triggered', async () => { + const { lifecycle, suiteTracker } = await runLifecycleWithMocks([MOCKS.WITH_TESTS]); + await lifecycle.cleanup.trigger(); + + const suites = suiteTracker.getAllFinishedSuites(); + + const call = (fs.writeFileSync as jest.Mock).mock.calls[0]; + expect(call[0]).toEqual(DEFAULT_TEST_METADATA_PATH); + expect(call[1]).toEqual(JSON.stringify(suites, null, 2)); + }); + + it('respects TEST_METADATA_PATH env var for metadata target override', async () => { + process.env.TEST_METADATA_PATH = resolve(REPO_ROOT, '../fake-test-path'); + const { lifecycle } = await runLifecycleWithMocks([MOCKS.WITH_TESTS]); + await lifecycle.cleanup.trigger(); + + expect((fs.writeFileSync as jest.Mock).mock.calls[0][0]).toEqual( + process.env.TEST_METADATA_PATH + ); + }); + + it('identifies suites with tests as leaf suites', async () => { + const root = createMock({ title: 'root', file: join(REPO_ROOT, 'root.js') }); + const parent = createMock({ parent: root }); + const withTests = createMock({ parent, tests: [{}] }); + + const { suiteTracker } = await runLifecycleWithMocks([root, parent, withTests]); + const suites = suiteTracker.getAllFinishedSuites(); + + const finishedRoot = suites.find(s => s.title === 'root'); + const finishedWithTests = suites.find(s => s.title !== 'root'); + + expect(finishedRoot).toBeTruthy(); + expect(finishedRoot?.hasTests).toBeFalsy(); + expect(finishedWithTests?.hasTests).toBe(true); + }); + + describe('with a failing suite', () => { + let root: any; + let parent: any; + let failed: any; + + beforeEach(() => { + root = createMock({ file: join(REPO_ROOT, 'root.js') }); + parent = createMock({ parent: root }); + failed = createMock({ parent, tests: [{}] }); + }); + + it('marks parent suites as not successful when a test fails', async () => { + const { suiteTracker } = await runLifecycleWithMocks( + [root, parent, failed], + async ({ lifecycle }) => { + await lifecycle.testFailure.trigger(Error('test'), { parent: failed }); + } + ); + + const suites = suiteTracker.getAllFinishedSuites(); + expect(suites.length).toBe(2); + for (const suite of suites) { + expect(suite.success).toBeFalsy(); + } + }); + + it('marks parent suites as not successful when a test hook fails', async () => { + const { suiteTracker } = await runLifecycleWithMocks( + [root, parent, failed], + async ({ lifecycle }) => { + await lifecycle.testHookFailure.trigger(Error('test'), { parent: failed }); + } + ); + + const suites = suiteTracker.getAllFinishedSuites(); + expect(suites.length).toBe(2); + for (const suite of suites) { + expect(suite.success).toBeFalsy(); + } + }); + }); +}); diff --git a/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts new file mode 100644 index 0000000000000..8967251ea78de --- /dev/null +++ b/packages/kbn-test/src/functional_test_runner/lib/suite_tracker.ts @@ -0,0 +1,147 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import fs from 'fs'; +import { dirname, relative, resolve } from 'path'; + +import { REPO_ROOT } from '@kbn/dev-utils'; + +import { Lifecycle } from './lifecycle'; + +export interface SuiteInProgress { + startTime?: Date; + endTime?: Date; + success?: boolean; +} + +export interface SuiteWithMetadata { + config: string; + file: string; + tag: string; + title: string; + startTime: Date; + endTime: Date; + duration: number; + success: boolean; + hasTests: boolean; +} + +const getTestMetadataPath = () => { + return process.env.TEST_METADATA_PATH || resolve(REPO_ROOT, 'target', 'test_metadata.json'); +}; + +export class SuiteTracker { + finishedSuitesByConfig: Record> = {}; + inProgressSuites: Map = new Map(); + + static startTracking(lifecycle: Lifecycle, configPath: string): SuiteTracker { + const suiteTracker = new SuiteTracker(lifecycle, configPath); + return suiteTracker; + } + + getTracked(suite: object): SuiteInProgress { + if (!this.inProgressSuites.has(suite)) { + this.inProgressSuites.set(suite, { success: undefined } as SuiteInProgress); + } + return this.inProgressSuites.get(suite)!; + } + + constructor(lifecycle: Lifecycle, configPathAbsolute: string) { + if (fs.existsSync(getTestMetadataPath())) { + fs.unlinkSync(getTestMetadataPath()); + } else { + fs.mkdirSync(dirname(getTestMetadataPath()), { recursive: true }); + } + + const config = relative(REPO_ROOT, configPathAbsolute); + + lifecycle.beforeTestSuite.add(suite => { + const tracked = this.getTracked(suite); + tracked.startTime = new Date(); + }); + + // If a test fails, we want to make sure all of the ancestors, all the way up to the root, get marked as failed + // This information is not available on the mocha objects without traversing all descendants of a given node + const handleFailure = (_: any, test: any) => { + let parent = test.parent; + + // Infinite loop protection, just in case + for (let i = 0; i < 500 && parent; i++) { + if (this.inProgressSuites.has(parent)) { + this.getTracked(parent).success = false; + } + parent = parent.parent; + } + }; + + lifecycle.testFailure.add(handleFailure); + lifecycle.testHookFailure.add(handleFailure); + + lifecycle.afterTestSuite.add(suite => { + const tracked = this.getTracked(suite); + tracked.endTime = new Date(); + + // The suite ended without any children failing, so we can mark it as successful + if (typeof tracked.success === 'undefined') { + tracked.success = true; + } + + let duration = tracked.endTime.getTime() - (tracked.startTime || new Date()).getTime(); + duration = Math.floor(duration / 1000); + + const file = relative(REPO_ROOT, suite.file); + + this.finishedSuitesByConfig[config] = this.finishedSuitesByConfig[config] || {}; + + // This will get called multiple times for a test file that has multiple describes in it or similar + // This is okay, because the last one that fires is always the root of the file, which is is the one we ultimately want + this.finishedSuitesByConfig[config][file] = { + ...tracked, + duration, + config, + file, + tag: suite.suiteTag, + title: suite.title, + hasTests: !!( + (suite.tests && suite.tests.length) || + // The below statement is so that `hasTests` will bubble up nested describes in the same file + (this.finishedSuitesByConfig[config][file] && + this.finishedSuitesByConfig[config][file].hasTests) + ), + } as SuiteWithMetadata; + }); + + lifecycle.cleanup.add(() => { + const suites = this.getAllFinishedSuites(); + + fs.writeFileSync(getTestMetadataPath(), JSON.stringify(suites, null, 2)); + }); + } + + getAllFinishedSuites() { + const flattened: SuiteWithMetadata[] = []; + for (const byFile of Object.values(this.finishedSuitesByConfig)) { + for (const suite of Object.values(byFile)) { + flattened.push(suite); + } + } + + flattened.sort((a, b) => b.duration - a.duration); + return flattened; + } +} diff --git a/packages/kbn-ui-shared-deps/package.json b/packages/kbn-ui-shared-deps/package.json index 7c5d6a62a11ca..c8614b1df9d5d 100644 --- a/packages/kbn-ui-shared-deps/package.json +++ b/packages/kbn-ui-shared-deps/package.json @@ -9,7 +9,7 @@ "kbn:watch": "node scripts/build --watch" }, "dependencies": { - "@elastic/charts": "18.2.2", + "@elastic/charts": "18.3.0", "@elastic/eui": "21.0.1", "@kbn/i18n": "1.0.0", "abortcontroller-polyfill": "^1.4.0", diff --git a/src/legacy/core_plugins/vis_type_timelion/public/legacy_imports.ts b/scripts/prettier_on_changed.js similarity index 87% rename from src/legacy/core_plugins/vis_type_timelion/public/legacy_imports.ts rename to scripts/prettier_on_changed.js index e7612b288fb24..f9598110f91fd 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/legacy_imports.ts +++ b/scripts/prettier_on_changed.js @@ -17,5 +17,5 @@ * under the License. */ -export { npSetup, npStart } from 'ui/new_platform'; -export { PluginsStart } from 'ui/new_platform/new_platform'; +require('../src/setup_node_env/babel_register'); +require('../src/dev/run_prettier_on_changed'); diff --git a/src/cli/cluster/cluster_manager.ts b/src/cli/cluster/cluster_manager.ts index 44b6c39556afd..a87e2aa11f2c0 100644 --- a/src/cli/cluster/cluster_manager.ts +++ b/src/cli/cluster/cluster_manager.ts @@ -263,7 +263,7 @@ export class ClusterManager { ...pluginInternalDirsIgnore, fromRoot('src/legacy/server/sass/__tmp__'), fromRoot('x-pack/legacy/plugins/reporting/.chromium'), - fromRoot('x-pack/legacy/plugins/siem/cypress'), + fromRoot('x-pack/plugins/siem/cypress'), fromRoot('x-pack/legacy/plugins/apm/e2e'), fromRoot('x-pack/legacy/plugins/apm/scripts'), fromRoot('x-pack/legacy/plugins/canvas/canvas_plugin_src'), // prevents server from restarting twice for Canvas plugin changes, diff --git a/src/core/server/config/env.test.ts b/src/core/server/config/env.test.ts index c244012e34469..0fffcc44781d9 100644 --- a/src/core/server/config/env.test.ts +++ b/src/core/server/config/env.test.ts @@ -164,6 +164,17 @@ test('pluginSearchPaths contains examples plugins path if --run-examples flag is expect(env.pluginSearchPaths).toContain('/some/home/dir/examples'); }); +test('pluginSearchPaths contains x-pack/examples plugins path if --run-examples flag is true', () => { + const env = new Env( + '/some/home/dir', + getEnvOptions({ + cliArgs: { runExamples: true }, + }) + ); + + expect(env.pluginSearchPaths).toContain('/some/home/dir/x-pack/examples'); +}); + test('pluginSearchPaths does not contains examples plugins path if --run-examples flag is false', () => { const env = new Env( '/some/home/dir', @@ -174,3 +185,14 @@ test('pluginSearchPaths does not contains examples plugins path if --run-example expect(env.pluginSearchPaths).not.toContain('/some/home/dir/examples'); }); + +test('pluginSearchPaths does not contains x-pack/examples plugins path if --run-examples flag is false', () => { + const env = new Env( + '/some/home/dir', + getEnvOptions({ + cliArgs: { runExamples: false }, + }) + ); + + expect(env.pluginSearchPaths).not.toContain('/some/home/dir/x-pack/examples'); +}); diff --git a/src/core/server/config/env.ts b/src/core/server/config/env.ts index 05a8f40a09a88..d8068c5b383fa 100644 --- a/src/core/server/config/env.ts +++ b/src/core/server/config/env.ts @@ -109,7 +109,9 @@ export class Env { resolve(this.homeDir, 'src', 'plugins'), ...(options.cliArgs.oss ? [] : [resolve(this.homeDir, 'x-pack', 'plugins')]), resolve(this.homeDir, 'plugins'), - ...(options.cliArgs.runExamples ? [resolve(this.homeDir, 'examples')] : []), + ...(options.cliArgs.runExamples + ? [resolve(this.homeDir, 'examples'), resolve(this.homeDir, 'x-pack', 'examples')] + : []), resolve(this.homeDir, '..', 'kibana-extra'), ]; diff --git a/src/core/server/http/router/router.ts b/src/core/server/http/router/router.ts index b4e7fc2a989b6..69402a74eda5f 100644 --- a/src/core/server/http/router/router.ts +++ b/src/core/server/http/router/router.ts @@ -20,7 +20,7 @@ import { Request, ResponseObject, ResponseToolkit } from 'hapi'; import Boom from 'boom'; -import { Type } from '@kbn/config-schema'; +import { isConfigSchema } from '@kbn/config-schema'; import { Logger } from '../../logging'; import { KibanaRequest } from './request'; import { KibanaResponseFactory, kibanaResponseFactory, IKibanaResponse } from './response'; @@ -139,7 +139,7 @@ function routeSchemasFromRouteConfig( if (route.validate !== false) { Object.entries(route.validate).forEach(([key, schema]) => { - if (!(schema instanceof Type || typeof schema === 'function')) { + if (!(isConfigSchema(schema) || typeof schema === 'function')) { throw new Error( `Expected a valid validation logic declared with '@kbn/config-schema' package or a RouteValidationFunction at key: [${key}].` ); diff --git a/src/core/server/http/router/validator/validator.ts b/src/core/server/http/router/validator/validator.ts index 97dd2bc894f81..a2299b47ae253 100644 --- a/src/core/server/http/router/validator/validator.ts +++ b/src/core/server/http/router/validator/validator.ts @@ -17,7 +17,14 @@ * under the License. */ -import { ValidationError, Type, schema, ObjectType } from '@kbn/config-schema'; +import { + ValidationError, + Type, + schema, + ObjectType, + TypeOf, + isConfigSchema, +} from '@kbn/config-schema'; import { Stream } from 'stream'; import { RouteValidationError } from './validator_error'; @@ -85,7 +92,7 @@ type RouteValidationResultType | undefined> = T extends RouteValidationFunction ? ReturnType['value'] : T extends Type - ? ReturnType + ? TypeOf : undefined >; @@ -170,7 +177,7 @@ export class RouteValidator

{ * @internal */ public getParams(data: unknown, namespace?: string): Readonly

{ - return this.validate(this.config.params, this.options.unsafe?.params, data, namespace); + return this.validate(this.config.params, this.options.unsafe?.params, data, namespace) as P; } /** @@ -178,7 +185,7 @@ export class RouteValidator

{ * @internal */ public getQuery(data: unknown, namespace?: string): Readonly { - return this.validate(this.config.query, this.options.unsafe?.query, data, namespace); + return this.validate(this.config.query, this.options.unsafe?.query, data, namespace) as Q; } /** @@ -186,7 +193,7 @@ export class RouteValidator

{ * @internal */ public getBody(data: unknown, namespace?: string): Readonly { - return this.validate(this.config.body, this.options.unsafe?.body, data, namespace); + return this.validate(this.config.body, this.options.unsafe?.body, data, namespace) as B; } /** @@ -236,7 +243,7 @@ export class RouteValidator

{ data?: unknown, namespace?: string ): RouteValidationResultType { - if (validationRule instanceof Type) { + if (isConfigSchema(validationRule)) { return validationRule.validate(data, {}, namespace); } else if (typeof validationRule === 'function') { return this.validateFunction(validationRule, data, namespace); diff --git a/src/core/server/legacy/legacy_service.test.mocks.ts b/src/core/server/legacy/legacy_service.test.mocks.ts index 451a75ced7ae2..9ad554d63add0 100644 --- a/src/core/server/legacy/legacy_service.test.mocks.ts +++ b/src/core/server/legacy/legacy_service.test.mocks.ts @@ -30,6 +30,11 @@ export const findLegacyPluginSpecsMock = jest.fn().mockImplementation((settings: uiExports: {}, navLinks: [], })); -jest.doMock('./plugins/find_legacy_plugin_specs.ts', () => ({ +jest.doMock('./plugins/find_legacy_plugin_specs', () => ({ findLegacyPluginSpecs: findLegacyPluginSpecsMock, })); + +export const logLegacyThirdPartyPluginDeprecationWarningMock = jest.fn(); +jest.doMock('./plugins/log_legacy_plugins_warning', () => ({ + logLegacyThirdPartyPluginDeprecationWarning: logLegacyThirdPartyPluginDeprecationWarningMock, +})); diff --git a/src/core/server/legacy/legacy_service.test.ts b/src/core/server/legacy/legacy_service.test.ts index 0c4e58f6a8da1..a75f7dda302c2 100644 --- a/src/core/server/legacy/legacy_service.test.ts +++ b/src/core/server/legacy/legacy_service.test.ts @@ -22,7 +22,10 @@ jest.mock('../../../cli/cluster/cluster_manager'); jest.mock('./config/legacy_deprecation_adapters', () => ({ convertLegacyDeprecationProvider: (provider: any) => Promise.resolve(provider), })); -import { findLegacyPluginSpecsMock } from './legacy_service.test.mocks'; +import { + findLegacyPluginSpecsMock, + logLegacyThirdPartyPluginDeprecationWarningMock, +} from './legacy_service.test.mocks'; import { BehaviorSubject, throwError } from 'rxjs'; @@ -476,6 +479,38 @@ describe('#discoverPlugins()', () => { expect(configService.addDeprecationProvider).toHaveBeenCalledWith('', 'providerA'); expect(configService.addDeprecationProvider).toHaveBeenCalledWith('', 'providerB'); }); + + it(`logs deprecations for legacy third party plugins`, async () => { + const pluginSpecs = [ + { getId: () => 'pluginA', getDeprecationsProvider: () => undefined }, + { getId: () => 'pluginB', getDeprecationsProvider: () => undefined }, + ]; + findLegacyPluginSpecsMock.mockImplementation( + settings => + Promise.resolve({ + pluginSpecs, + pluginExtendedConfig: settings, + disabledPluginSpecs: [], + uiExports: {}, + navLinks: [], + }) as any + ); + + const legacyService = new LegacyService({ + coreId, + env, + logger, + configService: configService as any, + }); + + await legacyService.discoverPlugins(); + + expect(logLegacyThirdPartyPluginDeprecationWarningMock).toHaveBeenCalledTimes(1); + expect(logLegacyThirdPartyPluginDeprecationWarningMock).toHaveBeenCalledWith({ + specs: pluginSpecs, + log: expect.any(Object), + }); + }); }); test('Sets the server.uuid property on the legacy configuration', async () => { diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts index fd3ebfe120599..b95362e1ea26e 100644 --- a/src/core/server/legacy/legacy_service.ts +++ b/src/core/server/legacy/legacy_service.ts @@ -28,7 +28,7 @@ import { DevConfig, DevConfigType, config as devConfig } from '../dev'; import { BasePathProxyServer, HttpConfig, HttpConfigType, config as httpConfig } from '../http'; import { Logger } from '../logging'; import { PathConfigType } from '../path'; -import { findLegacyPluginSpecs } from './plugins'; +import { findLegacyPluginSpecs, logLegacyThirdPartyPluginDeprecationWarning } from './plugins'; import { convertLegacyDeprecationProvider } from './config'; import { ILegacyInternals, @@ -133,6 +133,11 @@ export class LegacyService implements CoreService { this.coreContext.env.packageInfo ); + logLegacyThirdPartyPluginDeprecationWarning({ + specs: pluginSpecs, + log: this.log, + }); + this.legacyPlugins = { pluginSpecs, disabledPluginSpecs, diff --git a/src/core/server/legacy/plugins/index.ts b/src/core/server/legacy/plugins/index.ts index a6d55e1da7839..7ec5dbc1983ab 100644 --- a/src/core/server/legacy/plugins/index.ts +++ b/src/core/server/legacy/plugins/index.ts @@ -18,3 +18,4 @@ */ export { findLegacyPluginSpecs } from './find_legacy_plugin_specs'; +export { logLegacyThirdPartyPluginDeprecationWarning } from './log_legacy_plugins_warning'; diff --git a/src/core/server/legacy/plugins/log_legacy_plugins_warning.test.ts b/src/core/server/legacy/plugins/log_legacy_plugins_warning.test.ts new file mode 100644 index 0000000000000..1790b096a71ae --- /dev/null +++ b/src/core/server/legacy/plugins/log_legacy_plugins_warning.test.ts @@ -0,0 +1,90 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { loggerMock } from '../../logging/logger.mock'; +import { logLegacyThirdPartyPluginDeprecationWarning } from './log_legacy_plugins_warning'; +import { LegacyPluginSpec } from '../types'; + +const createPluginSpec = ({ id, path }: { id: string; path: string }): LegacyPluginSpec => { + return { + getId: () => id, + getExpectedKibanaVersion: () => 'kibana', + getConfigPrefix: () => 'plugin.config', + getDeprecationsProvider: () => undefined, + getPack: () => ({ + getPath: () => path, + }), + }; +}; + +describe('logLegacyThirdPartyPluginDeprecationWarning', () => { + let log: ReturnType; + + beforeEach(() => { + log = loggerMock.create(); + }); + + it('logs warning for third party plugins', () => { + logLegacyThirdPartyPluginDeprecationWarning({ + specs: [createPluginSpec({ id: 'plugin', path: '/some-external-path' })], + log, + }); + expect(log.warn).toHaveBeenCalledTimes(1); + expect(log.warn.mock.calls[0]).toMatchInlineSnapshot(` + Array [ + "Some installed third party plugin(s) [plugin] are using the legacy plugin format and will no longer work in a future Kibana release. Please refer to https://www.elastic.co/guide/en/kibana/master/breaking-changes-8.0.html for a list of breaking changes and https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md for documentation on how to migrate legacy plugins.", + ] + `); + }); + + it('lists all the deprecated plugins and only log once', () => { + logLegacyThirdPartyPluginDeprecationWarning({ + specs: [ + createPluginSpec({ id: 'pluginA', path: '/abs/path/to/pluginA' }), + createPluginSpec({ id: 'pluginB', path: '/abs/path/to/pluginB' }), + createPluginSpec({ id: 'pluginC', path: '/abs/path/to/pluginC' }), + ], + log, + }); + expect(log.warn).toHaveBeenCalledTimes(1); + expect(log.warn.mock.calls[0]).toMatchInlineSnapshot(` + Array [ + "Some installed third party plugin(s) [pluginA, pluginB, pluginC] are using the legacy plugin format and will no longer work in a future Kibana release. Please refer to https://www.elastic.co/guide/en/kibana/master/breaking-changes-8.0.html for a list of breaking changes and https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md for documentation on how to migrate legacy plugins.", + ] + `); + }); + + it('does not log warning for internal legacy plugins', () => { + logLegacyThirdPartyPluginDeprecationWarning({ + specs: [ + createPluginSpec({ + id: 'plugin', + path: '/absolute/path/to/kibana/src/legacy/core_plugins', + }), + createPluginSpec({ + id: 'plugin', + path: '/absolute/path/to/kibana/x-pack', + }), + ], + log, + }); + + expect(log.warn).not.toHaveBeenCalled(); + }); +}); diff --git a/src/core/server/legacy/plugins/log_legacy_plugins_warning.ts b/src/core/server/legacy/plugins/log_legacy_plugins_warning.ts new file mode 100644 index 0000000000000..f9c3dcbf554cb --- /dev/null +++ b/src/core/server/legacy/plugins/log_legacy_plugins_warning.ts @@ -0,0 +1,52 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { Logger } from '../../logging'; +import { LegacyPluginSpec } from '../types'; + +const internalPaths = ['/src/legacy/core_plugins', '/x-pack']; + +const breakingChangesUrl = + 'https://www.elastic.co/guide/en/kibana/master/breaking-changes-8.0.html'; +const migrationGuideUrl = 'https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md'; + +export const logLegacyThirdPartyPluginDeprecationWarning = ({ + specs, + log, +}: { + specs: LegacyPluginSpec[]; + log: Logger; +}) => { + const thirdPartySpecs = specs.filter(isThirdPartyPluginSpec); + if (thirdPartySpecs.length > 0) { + const pluginIds = thirdPartySpecs.map(spec => spec.getId()); + log.warn( + `Some installed third party plugin(s) [${pluginIds.join( + ', ' + )}] are using the legacy plugin format and will no longer work in a future Kibana release. ` + + `Please refer to ${breakingChangesUrl} for a list of breaking changes ` + + `and ${migrationGuideUrl} for documentation on how to migrate legacy plugins.` + ); + } +}; + +const isThirdPartyPluginSpec = (spec: LegacyPluginSpec): boolean => { + const pluginPath = spec.getPack().getPath(); + return !internalPaths.some(internalPath => pluginPath.indexOf(internalPath) > -1); +}; diff --git a/src/core/server/legacy/types.ts b/src/core/server/legacy/types.ts index 38cb9e6835ce9..2567ca790e04f 100644 --- a/src/core/server/legacy/types.ts +++ b/src/core/server/legacy/types.ts @@ -98,6 +98,7 @@ export interface LegacyPluginSpec { getExpectedKibanaVersion: () => string; getConfigPrefix: () => string; getDeprecationsProvider: () => LegacyConfigDeprecationProvider | undefined; + getPack: () => LegacyPluginPack; } /** diff --git a/src/core/server/plugins/plugin.ts b/src/core/server/plugins/plugin.ts index 7c67ab7a48df1..d7cfaa14d2343 100644 --- a/src/core/server/plugins/plugin.ts +++ b/src/core/server/plugins/plugin.ts @@ -21,7 +21,7 @@ import { join } from 'path'; import typeDetect from 'type-detect'; import { Subject } from 'rxjs'; import { first } from 'rxjs/operators'; -import { Type } from '@kbn/config-schema'; +import { isConfigSchema } from '@kbn/config-schema'; import { Logger } from '../logging'; import { @@ -150,7 +150,7 @@ export class PluginWrapper< } const configDescriptor = pluginDefinition.config; - if (!(configDescriptor.schema instanceof Type)) { + if (!isConfigSchema(configDescriptor.schema)) { throw new Error('Configuration schema expected to be an instance of Type'); } return configDescriptor; diff --git a/src/core/server/saved_objects/migrations/core/build_index_map.test.ts b/src/core/server/saved_objects/migrations/core/build_index_map.test.ts index 44add4e977006..2c710d4eaa079 100644 --- a/src/core/server/saved_objects/migrations/core/build_index_map.test.ts +++ b/src/core/server/saved_objects/migrations/core/build_index_map.test.ts @@ -26,7 +26,7 @@ const createRegistry = (...types: Array>) => { types.forEach(type => registry.registerType({ name: 'unknown', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, migrations: {}, @@ -41,7 +41,7 @@ test('mappings without index pattern goes to default index', () => { kibanaIndexName: '.kibana', registry: createRegistry({ name: 'type1', - namespaceAgnostic: false, + namespaceType: 'single', }), indexMap: { type1: { @@ -73,7 +73,7 @@ test(`mappings with custom index pattern doesn't go to default index`, () => { kibanaIndexName: '.kibana', registry: createRegistry({ name: 'type1', - namespaceAgnostic: false, + namespaceType: 'single', indexPattern: '.other_kibana', }), indexMap: { @@ -106,7 +106,7 @@ test('creating a script gets added to the index pattern', () => { kibanaIndexName: '.kibana', registry: createRegistry({ name: 'type1', - namespaceAgnostic: false, + namespaceType: 'single', indexPattern: '.other_kibana', convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`, }), @@ -141,12 +141,12 @@ test('throws when two scripts are defined for an index pattern', () => { const registry = createRegistry( { name: 'type1', - namespaceAgnostic: false, + namespaceType: 'single', convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`, }, { name: 'type2', - namespaceAgnostic: false, + namespaceType: 'single', convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`, } ); diff --git a/src/core/server/saved_objects/migrations/core/document_migrator.test.ts b/src/core/server/saved_objects/migrations/core/document_migrator.test.ts index ef3f546b5e574..64270c677ff20 100644 --- a/src/core/server/saved_objects/migrations/core/document_migrator.test.ts +++ b/src/core/server/saved_objects/migrations/core/document_migrator.test.ts @@ -32,7 +32,7 @@ const createRegistry = (...types: Array>) => { types.forEach(type => registry.registerType({ name: 'unknown', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, migrations: {}, diff --git a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.mock.ts b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.mock.ts index 257b32c1e4c23..3f5c0c3876615 100644 --- a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.mock.ts +++ b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.mock.ts @@ -27,7 +27,7 @@ const defaultSavedObjectTypes: SavedObjectsType[] = [ { name: 'testtype', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { name: { type: 'keyword' }, diff --git a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts index 336eeff99f47b..cda0e86f15bdf 100644 --- a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts +++ b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts @@ -28,8 +28,8 @@ const createRegistry = (types: Array>) => { types.forEach(type => registry.registerType({ name: 'unknown', - namespaceAgnostic: false, hidden: false, + namespaceType: 'single', mappings: { properties: {} }, migrations: {}, ...type, @@ -120,7 +120,7 @@ function mockOptions(): KibanaMigratorOptions { { name: 'testtype', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { name: { type: 'keyword' }, @@ -131,7 +131,7 @@ function mockOptions(): KibanaMigratorOptions { { name: 'testtype2', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', indexPattern: 'other-index', mappings: { properties: { diff --git a/src/core/server/saved_objects/routes/integration_tests/test_utils.ts b/src/core/server/saved_objects/routes/integration_tests/test_utils.ts index 82a889f75d3c1..23e0285201dc7 100644 --- a/src/core/server/saved_objects/routes/integration_tests/test_utils.ts +++ b/src/core/server/saved_objects/routes/integration_tests/test_utils.ts @@ -49,7 +49,7 @@ export const createExportableType = (name: string): SavedObjectsType => { return { name, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: {}, }, diff --git a/src/core/server/saved_objects/saved_objects_type_registry.test.ts b/src/core/server/saved_objects/saved_objects_type_registry.test.ts index 84337474f3ee3..f82822f90f489 100644 --- a/src/core/server/saved_objects/saved_objects_type_registry.test.ts +++ b/src/core/server/saved_objects/saved_objects_type_registry.test.ts @@ -183,14 +183,6 @@ describe('SavedObjectTypeRegistry', () => { expectResult(false, { namespaceType: 'single' }); expectResult(false, { namespaceType: undefined }); }); - - // deprecated test cases - it(`returns true when namespaceAgnostic is true`, () => { - expectResult(true, { namespaceAgnostic: true, namespaceType: 'agnostic' }); - expectResult(true, { namespaceAgnostic: true, namespaceType: 'multiple' }); - expectResult(true, { namespaceAgnostic: true, namespaceType: 'single' }); - expectResult(true, { namespaceAgnostic: true, namespaceType: undefined }); - }); }); describe('#isSingleNamespace', () => { @@ -213,14 +205,6 @@ describe('SavedObjectTypeRegistry', () => { expectResult(false, { namespaceType: 'agnostic' }); expectResult(false, { namespaceType: 'multiple' }); }); - - // deprecated test cases - it(`returns false when namespaceAgnostic is true`, () => { - expectResult(false, { namespaceAgnostic: true, namespaceType: 'agnostic' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: 'multiple' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: 'single' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: undefined }); - }); }); describe('#isMultiNamespace', () => { @@ -243,14 +227,6 @@ describe('SavedObjectTypeRegistry', () => { expectResult(false, { namespaceType: 'single' }); expectResult(false, { namespaceType: undefined }); }); - - // deprecated test cases - it(`returns false when namespaceAgnostic is true`, () => { - expectResult(false, { namespaceAgnostic: true, namespaceType: 'agnostic' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: 'multiple' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: 'single' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: undefined }); - }); }); describe('#isHidden', () => { diff --git a/src/core/server/saved_objects/saved_objects_type_registry.ts b/src/core/server/saved_objects/saved_objects_type_registry.ts index be3fdb86a994c..740313a53d1e2 100644 --- a/src/core/server/saved_objects/saved_objects_type_registry.ts +++ b/src/core/server/saved_objects/saved_objects_type_registry.ts @@ -72,11 +72,7 @@ export class SavedObjectTypeRegistry { * resolves to `false` if the type is not registered */ public isNamespaceAgnostic(type: string) { - return ( - this.types.get(type)?.namespaceType === 'agnostic' || - this.types.get(type)?.namespaceAgnostic || - false - ); + return this.types.get(type)?.namespaceType === 'agnostic'; } /** @@ -84,6 +80,7 @@ export class SavedObjectTypeRegistry { * resolves to `true` if the type is not registered */ public isSingleNamespace(type: string) { + // in the case we somehow registered a type with an invalid `namespaceType`, treat it as single-namespace return !this.isNamespaceAgnostic(type) && !this.isMultiNamespace(type); } @@ -92,7 +89,7 @@ export class SavedObjectTypeRegistry { * resolves to `false` if the type is not registered */ public isMultiNamespace(type: string) { - return !this.isNamespaceAgnostic(type) && this.types.get(type)?.namespaceType === 'multiple'; + return this.types.get(type)?.namespaceType === 'multiple'; } /** diff --git a/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts b/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts index a6b580e9b3461..ea881805e1ae6 100644 --- a/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts +++ b/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts @@ -32,7 +32,7 @@ describe('SavedObjectsRepository#createRepository', () => { typeRegistry.registerType({ name: 'nsAgnosticType', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { name: { type: 'keyword' }, @@ -44,7 +44,7 @@ describe('SavedObjectsRepository#createRepository', () => { typeRegistry.registerType({ name: 'nsType', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', indexPattern: 'beats', mappings: { properties: { @@ -56,7 +56,7 @@ describe('SavedObjectsRepository#createRepository', () => { typeRegistry.registerType({ name: 'hiddenType', hidden: true, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { name: { type: 'keyword' }, diff --git a/src/core/server/saved_objects/types.ts b/src/core/server/saved_objects/types.ts index 9efc82603b179..b50c6dc9a1abf 100644 --- a/src/core/server/saved_objects/types.ts +++ b/src/core/server/saved_objects/types.ts @@ -202,15 +202,10 @@ export interface SavedObjectsType { * See {@link SavedObjectsServiceStart.createInternalRepository | createInternalRepository}. */ hidden: boolean; - /** - * Is the type global (true), or not (false). - * @deprecated Use `namespaceType` instead. - */ - namespaceAgnostic?: boolean; /** * The {@link SavedObjectsNamespaceType | namespace type} for the type. */ - namespaceType?: SavedObjectsNamespaceType; + namespaceType: SavedObjectsNamespaceType; /** * If defined, the type instances will be stored in the given index instead of the default one. */ diff --git a/src/core/server/saved_objects/utils.test.ts b/src/core/server/saved_objects/utils.test.ts index 64bdf1771decc..033aeea7c018d 100644 --- a/src/core/server/saved_objects/utils.test.ts +++ b/src/core/server/saved_objects/utils.test.ts @@ -421,14 +421,6 @@ describe('convertTypesToLegacySchema', () => { namespaceType: 'multiple', mappings: { properties: {} }, }, - // deprecated test case - { - name: 'typeD', - hidden: false, - namespaceAgnostic: true, - namespaceType: 'multiple', // if namespaceAgnostic and namespaceType are both set, namespaceAgnostic takes precedence - mappings: { properties: {} }, - }, ]; expect(convertTypesToLegacySchema(types)).toEqual({ typeA: { @@ -448,12 +440,6 @@ describe('convertTypesToLegacySchema', () => { isNamespaceAgnostic: false, multiNamespace: true, }, - // deprecated test case - typeD: { - hidden: false, - isNamespaceAgnostic: true, - multiNamespace: false, - }, }); }); }); diff --git a/src/core/server/saved_objects/utils.ts b/src/core/server/saved_objects/utils.ts index 5348963812629..af7c08d1fbfcc 100644 --- a/src/core/server/saved_objects/utils.ts +++ b/src/core/server/saved_objects/utils.ts @@ -82,8 +82,8 @@ export const convertTypesToLegacySchema = ( return { ...schema, [type.name]: { - isNamespaceAgnostic: type.namespaceAgnostic || type.namespaceType === 'agnostic', - multiNamespace: !type.namespaceAgnostic && type.namespaceType === 'multiple', + isNamespaceAgnostic: type.namespaceType === 'agnostic', + multiNamespace: type.namespaceType === 'multiple', hidden: type.hidden, indexPattern: type.indexPattern, convertToAliasScript: type.convertToAliasScript, diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index e2af94437c9f3..7ca5c75f19e8f 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -2263,9 +2263,7 @@ export interface SavedObjectsType { mappings: SavedObjectsTypeMappingDefinition; migrations?: SavedObjectMigrationMap; name: string; - // @deprecated - namespaceAgnostic?: boolean; - namespaceType?: SavedObjectsNamespaceType; + namespaceType: SavedObjectsNamespaceType; } // @public @@ -2470,11 +2468,11 @@ export const validBodyOutput: readonly ["data", "stream"]; // Warnings were encountered during analysis: // // src/core/server/http/router/response.ts:316:3 - (ae-forgotten-export) The symbol "KibanaResponse" needs to be exported by the entry point index.d.ts -// src/core/server/legacy/types.ts:162:3 - (ae-forgotten-export) The symbol "VarsProvider" needs to be exported by the entry point index.d.ts -// src/core/server/legacy/types.ts:163:3 - (ae-forgotten-export) The symbol "VarsReplacer" needs to be exported by the entry point index.d.ts -// src/core/server/legacy/types.ts:164:3 - (ae-forgotten-export) The symbol "LegacyNavLinkSpec" needs to be exported by the entry point index.d.ts -// src/core/server/legacy/types.ts:165:3 - (ae-forgotten-export) The symbol "LegacyAppSpec" needs to be exported by the entry point index.d.ts -// src/core/server/legacy/types.ts:166:16 - (ae-forgotten-export) The symbol "LegacyPluginSpec" needs to be exported by the entry point index.d.ts +// src/core/server/legacy/types.ts:163:3 - (ae-forgotten-export) The symbol "VarsProvider" needs to be exported by the entry point index.d.ts +// src/core/server/legacy/types.ts:164:3 - (ae-forgotten-export) The symbol "VarsReplacer" needs to be exported by the entry point index.d.ts +// src/core/server/legacy/types.ts:165:3 - (ae-forgotten-export) The symbol "LegacyNavLinkSpec" needs to be exported by the entry point index.d.ts +// src/core/server/legacy/types.ts:166:3 - (ae-forgotten-export) The symbol "LegacyAppSpec" needs to be exported by the entry point index.d.ts +// src/core/server/legacy/types.ts:167:16 - (ae-forgotten-export) The symbol "LegacyPluginSpec" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:230:3 - (ae-forgotten-export) The symbol "KibanaConfigType" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:230:3 - (ae-forgotten-export) The symbol "SharedGlobalConfigKeys" needs to be exported by the entry point index.d.ts // src/core/server/plugins/types.ts:232:3 - (ae-forgotten-export) The symbol "PathConfigType" needs to be exported by the entry point index.d.ts diff --git a/src/core/server/ui_settings/saved_objects/ui_settings.ts b/src/core/server/ui_settings/saved_objects/ui_settings.ts index 031315bec0dab..1bea65ddee924 100644 --- a/src/core/server/ui_settings/saved_objects/ui_settings.ts +++ b/src/core/server/ui_settings/saved_objects/ui_settings.ts @@ -22,7 +22,7 @@ import { SavedObjectsType } from '../../saved_objects'; export const uiSettingsType: SavedObjectsType = { name: 'config', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { // we don't want to allow `true` in the public `SavedObjectsTypeMappingDefinition` type, however // this is needed for the config that is kinda a special type. To avoid adding additional internal types diff --git a/src/dev/build/tasks/os_packages/docker_generator/resources/bin/kibana-docker b/src/dev/build/tasks/os_packages/docker_generator/resources/bin/kibana-docker index 36617921c708c..73607ac24449c 100755 --- a/src/dev/build/tasks/os_packages/docker_generator/resources/bin/kibana-docker +++ b/src/dev/build/tasks/os_packages/docker_generator/resources/bin/kibana-docker @@ -195,6 +195,7 @@ kibana_vars=( xpack.reporting.capture.viewport.width xpack.reporting.capture.zoom xpack.reporting.csv.checkForFormulas + xpack.reporting.csv.escapeFormulaValues xpack.reporting.csv.enablePanelActionDownload xpack.reporting.csv.useByteOrderMarkEncoding xpack.reporting.csv.maxSizeBytes diff --git a/src/dev/eslint/index.js b/src/dev/eslint/index.ts similarity index 100% rename from src/dev/eslint/index.js rename to src/dev/eslint/index.ts diff --git a/src/dev/eslint/lint_files.js b/src/dev/eslint/lint_files.ts similarity index 90% rename from src/dev/eslint/lint_files.js rename to src/dev/eslint/lint_files.ts index a76edeb2eb865..80c493233f39a 100644 --- a/src/dev/eslint/lint_files.js +++ b/src/dev/eslint/lint_files.ts @@ -19,7 +19,8 @@ import { CLIEngine } from 'eslint'; -import { createFailError } from '@kbn/dev-utils'; +import { createFailError, ToolingLog } from '@kbn/dev-utils'; +import { File } from '../file'; import { REPO_ROOT } from '../constants'; /** @@ -30,7 +31,7 @@ import { REPO_ROOT } from '../constants'; * @param {Array} files * @return {undefined} */ -export function lintFiles(log, files, { fix } = {}) { +export function lintFiles(log: ToolingLog, files: File[], { fix }: { fix?: boolean } = {}) { const cli = new CLIEngine({ cache: true, cwd: REPO_ROOT, diff --git a/src/dev/eslint/pick_files_to_lint.js b/src/dev/eslint/pick_files_to_lint.ts similarity index 88% rename from src/dev/eslint/pick_files_to_lint.js rename to src/dev/eslint/pick_files_to_lint.ts index e3212c00d9e0d..b96781fc3a611 100644 --- a/src/dev/eslint/pick_files_to_lint.js +++ b/src/dev/eslint/pick_files_to_lint.ts @@ -16,9 +16,11 @@ * specific language governing permissions and limitations * under the License. */ - import { CLIEngine } from 'eslint'; +import { ToolingLog } from '@kbn/dev-utils'; +import { File } from '../file'; + /** * Filters a list of files to only include lintable files. * @@ -26,8 +28,8 @@ import { CLIEngine } from 'eslint'; * @param {Array} files * @return {Array} */ -export function pickFilesToLint(log, files) { - const cli = new CLIEngine(); +export function pickFilesToLint(log: ToolingLog, files: File[]) { + const cli = new CLIEngine({}); return files.filter(file => { if (!file.isJs() && !file.isTypescript()) { diff --git a/src/dev/run_prettier_on_changed.ts b/src/dev/run_prettier_on_changed.ts new file mode 100644 index 0000000000000..deca4fa1be3ce --- /dev/null +++ b/src/dev/run_prettier_on_changed.ts @@ -0,0 +1,87 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import execa from 'execa'; +// @ts-ignore +import SimpleGit from 'simple-git'; +import { run } from '@kbn/dev-utils'; +import dedent from 'dedent'; +import Util from 'util'; + +import pkg from '../../package.json'; +import { REPO_ROOT } from './constants'; +import { File } from './file'; +import * as Eslint from './eslint'; + +run(async function getChangedFiles({ log }) { + const simpleGit = new SimpleGit(REPO_ROOT); + + const getStatus = Util.promisify(simpleGit.status.bind(simpleGit)); + const gitStatus = await getStatus(); + + if (gitStatus.files.length > 0) { + throw new Error( + dedent(`You should run prettier formatter on a clean branch. + Found not committed changes to: + ${gitStatus.files.map((f: { path: string }) => f.path).join('\n')}`) + ); + } + + const revParse = Util.promisify(simpleGit.revparse.bind(simpleGit)); + const currentBranch = await revParse(['--abbrev-ref', 'HEAD']); + const headBranch = pkg.branch; + + const diff = Util.promisify(simpleGit.diff.bind(simpleGit)); + + const changedFileStatuses: string = await diff([ + '--name-status', + `${headBranch}...${currentBranch}`, + ]); + + const changedFiles = changedFileStatuses + .split('\n') + // Ignore blank lines + .filter(line => line.trim().length > 0) + // git diff --name-status outputs lines with two OR three parts + // separated by a tab character + .map(line => line.trim().split('\t')) + .map(([status, ...paths]) => { + // ignore deleted files + if (status === 'D') { + return undefined; + } + + // the status is always in the first column + // .. If the file is edited the line will only have two columns + // .. If the file is renamed it will have three columns + // .. In any case, the last column is the CURRENT path to the file + return new File(paths[paths.length - 1]); + }) + .filter((file): file is File => Boolean(file)); + + const pathsToLint = Eslint.pickFilesToLint(log, changedFiles).map(f => f.getAbsolutePath()); + + if (pathsToLint.length > 0) { + log.debug('[prettier] run on %j files: ', pathsToLint.length, pathsToLint); + } + + while (pathsToLint.length > 0) { + await execa('npx', ['prettier@2.0.4', '--write', ...pathsToLint.splice(0, 100)]); + } +}); diff --git a/src/dev/storybook/aliases.ts b/src/dev/storybook/aliases.ts index 8ed64f004c9be..43114b2edccfc 100644 --- a/src/dev/storybook/aliases.ts +++ b/src/dev/storybook/aliases.ts @@ -24,6 +24,6 @@ export const storybookAliases = { drilldowns: 'x-pack/plugins/drilldowns/scripts/storybook.js', embeddable: 'src/plugins/embeddable/scripts/storybook.js', infra: 'x-pack/legacy/plugins/infra/scripts/storybook.js', - siem: 'x-pack/legacy/plugins/siem/scripts/storybook.js', + siem: 'x-pack/plugins/siem/scripts/storybook.js', ui_actions: 'x-pack/plugins/advanced_ui_actions/scripts/storybook.js', }; diff --git a/src/dev/typescript/projects.ts b/src/dev/typescript/projects.ts index 34756912fc247..01d8a30b598c1 100644 --- a/src/dev/typescript/projects.ts +++ b/src/dev/typescript/projects.ts @@ -27,7 +27,7 @@ export const PROJECTS = [ new Project(resolve(REPO_ROOT, 'test/tsconfig.json'), { name: 'kibana/test' }), new Project(resolve(REPO_ROOT, 'x-pack/tsconfig.json')), new Project(resolve(REPO_ROOT, 'x-pack/test/tsconfig.json'), { name: 'x-pack/test' }), - new Project(resolve(REPO_ROOT, 'x-pack/legacy/plugins/siem/cypress/tsconfig.json'), { + new Project(resolve(REPO_ROOT, 'x-pack/plugins/siem/cypress/tsconfig.json'), { name: 'siem/cypress', }), new Project(resolve(REPO_ROOT, 'x-pack/legacy/plugins/apm/e2e/tsconfig.json'), { @@ -44,6 +44,9 @@ export const PROJECTS = [ ...glob .sync('examples/*/tsconfig.json', { cwd: REPO_ROOT }) .map(path => new Project(resolve(REPO_ROOT, path))), + ...glob + .sync('x-pack/examples/*/tsconfig.json', { cwd: REPO_ROOT }) + .map(path => new Project(resolve(REPO_ROOT, path))), ...glob .sync('test/plugin_functional/plugins/*/tsconfig.json', { cwd: REPO_ROOT }) .map(path => new Project(resolve(REPO_ROOT, path))), diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js b/src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/agg_table.js similarity index 94% rename from src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js rename to src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/agg_table.js index a23407a599ae2..b212ecf578dd1 100644 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table.js +++ b/src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/agg_table.js @@ -22,11 +22,18 @@ import moment from 'moment'; import ngMock from 'ng_mock'; import expect from '@kbn/expect'; import sinon from 'sinon'; -import { npStart } from '../../legacy_imports'; +import './legacy'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { npStart } from 'ui/new_platform'; import { round } from 'lodash'; -import { getAngularModule } from '../../get_inner_angular'; -import { initTableVisLegacyModule } from '../../table_vis_legacy_module'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInnerAngular } from '../../../../../../plugins/vis_type_table/public/get_inner_angular'; + +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { initTableVisLegacyModule } from '../../../../../../plugins/vis_type_table/public/table_vis_legacy_module'; import { tabifiedData } from './tabified_data'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { configureAppAngularModule } from '../../../../../../plugins/kibana_legacy/public/angular'; describe('Table Vis - AggTable Directive', function() { let $rootScope; @@ -34,7 +41,8 @@ describe('Table Vis - AggTable Directive', function() { let settings; const initLocalAngular = () => { - const tableVisModule = getAngularModule('kibana/table_vis', npStart.core); + const tableVisModule = getInnerAngular('kibana/table_vis', npStart.core); + configureAppAngularModule(tableVisModule, npStart.core, true); initTableVisLegacyModule(tableVisModule); }; diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js b/src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/agg_table_group.js similarity index 81% rename from src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js rename to src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/agg_table_group.js index 40a0993ccb017..3cd7de393d66a 100644 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/agg_table_group.js +++ b/src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/agg_table_group.js @@ -20,17 +20,24 @@ import $ from 'jquery'; import ngMock from 'ng_mock'; import expect from '@kbn/expect'; -import { npStart } from '../../legacy_imports'; -import { getAngularModule } from '../../get_inner_angular'; -import { initTableVisLegacyModule } from '../../table_vis_legacy_module'; +import './legacy'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInnerAngular } from '../../../../../../plugins/vis_type_table/public/get_inner_angular'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { initTableVisLegacyModule } from '../../../../../../plugins/vis_type_table/public/table_vis_legacy_module'; import { tabifiedData } from './tabified_data'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { npStart } from 'ui/new_platform'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { configureAppAngularModule } from '../../../../../../plugins/kibana_legacy/public/angular'; describe('Table Vis - AggTableGroup Directive', function() { let $rootScope; let $compile; const initLocalAngular = () => { - const tableVisModule = getAngularModule('kibana/table_vis', npStart.core); + const tableVisModule = getInnerAngular('kibana/table_vis', npStart.core); + configureAppAngularModule(tableVisModule, npStart.core, true); initTableVisLegacyModule(tableVisModule); }; diff --git a/src/legacy/core_plugins/vis_type_table/public/legacy.ts b/src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/legacy.ts similarity index 69% rename from src/legacy/core_plugins/vis_type_table/public/legacy.ts rename to src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/legacy.ts index 3d5f8c1b3efe9..c6467a5beae68 100644 --- a/src/legacy/core_plugins/vis_type_table/public/legacy.ts +++ b/src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/legacy.ts @@ -16,19 +16,23 @@ * specific language governing permissions and limitations * under the License. */ - import { PluginInitializerContext } from 'kibana/public'; -import { npSetup, npStart } from './legacy_imports'; -import { plugin } from '.'; - -import { TablePluginSetupDependencies } from './plugin'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { npStart, npSetup } from 'ui/new_platform'; +import { + TableVisPlugin, + TablePluginSetupDependencies, + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../../plugins/vis_type_table/public/plugin'; const plugins: Readonly = { expressions: npSetup.plugins.expressions, visualizations: npSetup.plugins.visualizations, }; -const pluginInstance = plugin({} as PluginInitializerContext); +const pluginInstance = new TableVisPlugin({} as PluginInitializerContext); export const setup = pluginInstance.setup(npSetup.core, plugins); -export const start = pluginInstance.start(npStart.core, { data: npStart.plugins.data }); +export const start = pluginInstance.start(npStart.core, { + data: npStart.plugins.data, +}); diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/tabified_data.js b/src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/tabified_data.js similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/agg_table/__tests__/tabified_data.js rename to src/legacy/core_plugins/kibana/public/__tests__/vis_type_table/tabified_data.js diff --git a/src/legacy/core_plugins/kibana/public/discover/build_services.ts b/src/legacy/core_plugins/kibana/public/discover/build_services.ts index a3a99a0ded523..c56e50f3b27ff 100644 --- a/src/legacy/core_plugins/kibana/public/discover/build_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/build_services.ts @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { createHashHistory, History } from 'history'; +import { History } from 'history'; import { Capabilities, @@ -51,7 +51,7 @@ export interface DiscoverServices { data: DataPublicPluginStart; docLinks: DocLinksStart; DocViewer: DocViewerComponent; - history: History; + history: () => History; theme: ChartsPluginStart['theme']; filterManager: FilterManager; indexPatterns: IndexPatternsContract; @@ -67,7 +67,8 @@ export interface DiscoverServices { } export async function buildServices( core: CoreStart, - plugins: DiscoverStartPlugins + plugins: DiscoverStartPlugins, + getHistory: () => History ): Promise { const services = { savedObjectsClient: core.savedObjects.client, @@ -77,6 +78,7 @@ export async function buildServices( overlays: core.overlays, }; const savedObjectService = createSavedSearchesLoader(services); + return { addBasePath: core.http.basePath.prepend, capabilities: core.application.capabilities, @@ -85,11 +87,11 @@ export async function buildServices( data: plugins.data, docLinks: core.docLinks, DocViewer: plugins.discover.docViews.DocViewer, - history: createHashHistory(), theme: plugins.charts.theme, filterManager: plugins.data.query.filterManager, getSavedSearchById: async (id: string) => savedObjectService.get(id), getSavedSearchUrlById: async (id: string) => savedObjectService.urlFor(id), + history: getHistory, indexPatterns: plugins.data.indexPatterns, inspector: plugins.inspector, // @ts-ignore diff --git a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts index 0a81ca0222b0a..156267bdfa87e 100644 --- a/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts +++ b/src/legacy/core_plugins/kibana/public/discover/kibana_services.ts @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +import { createHashHistory } from 'history'; import { DiscoverServices } from './build_services'; import { createGetterSetter } from '../../../../../plugins/kibana_utils/public'; import { search } from '../../../../../plugins/data/public'; @@ -52,6 +53,11 @@ export const [getUrlTracker, setUrlTracker] = createGetterSetter<{ setTrackedUrl: (url: string) => void; }>('urlTracker'); +/** + * Makes sure discover and context are using one instance of history + */ +export const getHistory = _.once(() => createHashHistory()); + export const { getRequestInspectorStats, getResponseInspectorStats, tabifyAggResponse } = search; export { unhashUrl, diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js index 5b03b313e4e3e..032ec7af09a30 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context.js @@ -81,6 +81,7 @@ function ContextAppRouteController($routeParams, $scope, $route) { defaultStepSize: getServices().uiSettings.get('context:defaultSize'), timeFieldName: indexPattern.timeFieldName, storeInSessionStorage: getServices().uiSettings.get('state:storeInSessionStorage'), + history: getServices().history(), }); this.state = { ...appState.getState() }; this.anchorId = $routeParams.id; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_state.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_state.ts index ed59143b163f6..b46995d44d826 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_state.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/context_state.ts @@ -17,7 +17,7 @@ * under the License. */ import _ from 'lodash'; -import { createBrowserHistory, History } from 'history'; +import { History } from 'history'; import { createStateContainer, createKbnUrlStateStorage, @@ -71,9 +71,9 @@ interface GetStateParams { */ storeInSessionStorage?: boolean; /** - * Browser history used for testing + * History instance to use */ - history?: History; + history: History; } interface GetStateReturn { @@ -126,7 +126,7 @@ export function getState({ }: GetStateParams): GetStateReturn { const stateStorage = createKbnUrlStateStorage({ useHash: storeInSessionStorage, - history: history ? history : createBrowserHistory(), + history, }); const globalStateInitial = stateStorage.get(GLOBAL_STATE_URL_KEY) as GlobalState; diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js index 72276a38f6ac2..567cfda45cc0d 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/discover.js @@ -57,8 +57,7 @@ const { core, chrome, data, - docTitle, - history, + history: getHistory, indexPatterns, filterManager, share, @@ -117,6 +116,7 @@ app.config($routeProvider => { reloadOnSearch: false, resolve: { savedObjects: function($route, Promise) { + const history = getHistory(); const savedSearchId = $route.current.params.id; return ensureDefaultIndexPattern(core, data, history).then(() => { const { appStateContainer } = getState({ history }); @@ -205,6 +205,8 @@ function discoverController( return isDefaultType($scope.indexPattern) ? $scope.indexPattern.timeFieldName : undefined; }; + const history = getHistory(); + const { appStateContainer, startSync: startStateSync, @@ -214,6 +216,7 @@ function discoverController( isAppStateDirty, kbnUrlStateStorage, getPreviousAppState, + resetInitialAppState, } = getState({ defaultAppState: getStateDefaults(), storeInSessionStorage: config.get('state:storeInSessionStorage'), @@ -373,6 +376,8 @@ function discoverController( // If the save wasn't successful, put the original values back. if (!response.id || response.error) { savedSearch.title = currentTitle; + } else { + resetInitialAppState(); } return response; }); @@ -758,7 +763,7 @@ function discoverController( } else { // Update defaults so that "reload saved query" functions correctly setAppState(getStateDefaults()); - docTitle.change(savedSearch.lastSavedTitle); + chrome.docTitle.change(savedSearch.lastSavedTitle); } } }); diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/discover_field.test.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/discover_field.test.tsx index 9a6bd65813d18..fdae2c0c16c9f 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/discover_field.test.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/discover_field.test.tsx @@ -31,11 +31,11 @@ import { IndexPatternField } from '../../../../../../../../plugins/data/public'; jest.mock('../../../kibana_services', () => ({ getServices: () => ({ - history: { + history: () => ({ location: { search: '', }, - }, + }), capabilities: { visualize: { show: true, diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/discover_sidebar.test.tsx b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/discover_sidebar.test.tsx index 0df14515adc6d..29451c075bcad 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/discover_sidebar.test.tsx +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/discover_sidebar.test.tsx @@ -36,11 +36,11 @@ import { SavedObject } from '../../../../../../../../core/types'; jest.mock('../../../kibana_services', () => ({ getServices: () => ({ - history: { + history: () => ({ location: { search: '', }, - }, + }), capabilities: { visualize: { show: true, diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/lib/visualize_url_utils.ts b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/lib/visualize_url_utils.ts index d146d212055b7..968ceeeab73a5 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/lib/visualize_url_utils.ts +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/components/sidebar/lib/visualize_url_utils.ts @@ -125,7 +125,7 @@ export function getVisualizeUrl( services: DiscoverServices ) { const aggsTermSize = services.uiSettings.get('discover:aggs:terms:size'); - const urlParams = parse(services.history.location.search) as Record; + const urlParams = parse(services.history().location.search) as Record; if ( (field.type === KBN_FIELD_TYPES.GEO_POINT || field.type === KBN_FIELD_TYPES.GEO_SHAPE) && diff --git a/src/legacy/core_plugins/kibana/public/discover/plugin.ts b/src/legacy/core_plugins/kibana/public/discover/plugin.ts index d05e96ccaaf0b..42883abe98171 100644 --- a/src/legacy/core_plugins/kibana/public/discover/plugin.ts +++ b/src/legacy/core_plugins/kibana/public/discover/plugin.ts @@ -31,7 +31,7 @@ import { registerFeature } from './np_ready/register_feature'; import './kibana_services'; import { EmbeddableStart, EmbeddableSetup } from '../../../../../plugins/embeddable/public'; import { getInnerAngularModule, getInnerAngularModuleEmbeddable } from './get_inner_angular'; -import { setAngularModule, setServices, setUrlTracker } from './kibana_services'; +import { getHistory, setAngularModule, setServices, setUrlTracker } from './kibana_services'; import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public'; import { ChartsPluginStart } from '../../../../../plugins/charts/public'; import { buildServices } from './build_services'; @@ -98,6 +98,10 @@ export class DiscoverPlugin implements Plugin { stop: stopUrlTracker, setActiveUrl: setTrackedUrl, } = createKbnUrlTracker({ + // we pass getter here instead of plain `history`, + // so history is lazily created (when app is mounted) + // this prevents redundant `#` when not in discover app + getHistory, baseUrl: core.http.basePath.prepend('/app/kibana'), defaultSubUrl: '#/discover', storageKey: `lastUrl:${core.http.basePath.get()}:discover`, @@ -174,7 +178,7 @@ export class DiscoverPlugin implements Plugin { if (this.servicesInitialized) { return { core, plugins }; } - const services = await buildServices(core, plugins); + const services = await buildServices(core, plugins, getHistory); setServices(services); this.servicesInitialized = true; diff --git a/src/legacy/core_plugins/kibana/public/kibana.js b/src/legacy/core_plugins/kibana/public/kibana.js index 20c46765dcb30..ea0d5ad3790b1 100644 --- a/src/legacy/core_plugins/kibana/public/kibana.js +++ b/src/legacy/core_plugins/kibana/public/kibana.js @@ -49,8 +49,9 @@ import { showAppRedirectNotification } from '../../../../plugins/kibana_legacy/p import 'leaflet'; import { localApplicationService } from './local_application_service'; -npSetup.plugins.kibanaLegacy.forwardApp('doc', 'discover', { keepPrefix: true }); -npSetup.plugins.kibanaLegacy.forwardApp('context', 'discover', { keepPrefix: true }); +npSetup.plugins.kibanaLegacy.registerLegacyAppAlias('doc', 'discover', { keepPrefix: true }); +npSetup.plugins.kibanaLegacy.registerLegacyAppAlias('context', 'discover', { keepPrefix: true }); + localApplicationService.attachToAngular(routes); routes.enable(); diff --git a/src/legacy/core_plugins/kibana/public/local_application_service/local_application_service.ts b/src/legacy/core_plugins/kibana/public/local_application_service/local_application_service.ts index 14564cfd9ee78..f38c410e6832f 100644 --- a/src/legacy/core_plugins/kibana/public/local_application_service/local_application_service.ts +++ b/src/legacy/core_plugins/kibana/public/local_application_service/local_application_service.ts @@ -98,14 +98,29 @@ export class LocalApplicationService { } }); - npStart.plugins.kibanaLegacy.getForwards().forEach(({ legacyAppId, newAppId, keepPrefix }) => { - angularRouteManager.when(matchAllWithPrefix(legacyAppId), { - resolveRedirectTo: ($location: ILocationService) => { - const url = $location.url(); - return `/${newAppId}${keepPrefix ? url : url.replace(legacyAppId, '')}`; + npStart.plugins.kibanaLegacy.getForwards().forEach(forwardDefinition => { + angularRouteManager.when(matchAllWithPrefix(forwardDefinition.legacyAppId), { + outerAngularWrapperRoute: true, + reloadOnSearch: false, + reloadOnUrl: false, + template: '', + controller($location: ILocationService) { + const newPath = forwardDefinition.rewritePath($location.url()); + npStart.core.application.navigateToApp(forwardDefinition.newAppId, { path: newPath }); }, }); }); + + npStart.plugins.kibanaLegacy + .getLegacyAppAliases() + .forEach(({ legacyAppId, newAppId, keepPrefix }) => { + angularRouteManager.when(matchAllWithPrefix(legacyAppId), { + resolveRedirectTo: ($location: ILocationService) => { + const url = $location.url(); + return `/${newAppId}${keepPrefix ? url : url.replace(legacyAppId, '')}`; + }, + }); + }); } } diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.js.snap deleted file mode 100644 index 59b275c7708a4..0000000000000 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.js.snap +++ /dev/null @@ -1,205 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`CreateIndexPatternWizard defaults to the loading state 1`] = ` - -

-
- -
- - -`; - -exports[`CreateIndexPatternWizard renders index pattern step when there are indices 1`] = ` - -
-
- -
- -
-`; - -exports[`CreateIndexPatternWizard renders the empty state when there are no indices 1`] = ` - -
-
- -
- -
-`; - -exports[`CreateIndexPatternWizard renders time field step when step is set to 2 1`] = ` - -
-
- -
- -
-`; - -exports[`CreateIndexPatternWizard renders when there are no indices but there are remote clusters 1`] = ` - -
-
- -
- -
-`; - -exports[`CreateIndexPatternWizard shows system indices even if there are no other indices if the include system indices is toggled 1`] = ` - -
-
- -
- -
-`; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap new file mode 100644 index 0000000000000..09a06bd8827ce --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap @@ -0,0 +1,312 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CreateIndexPatternWizard defaults to the loading state 1`] = ` + +
+
+ +
+ +
+`; + +exports[`CreateIndexPatternWizard renders index pattern step when there are indices 1`] = ` + +
+
+ +
+ +
+`; + +exports[`CreateIndexPatternWizard renders the empty state when there are no indices 1`] = ` + +
+
+ +
+ +
+`; + +exports[`CreateIndexPatternWizard renders time field step when step is set to 2 1`] = ` + +
+
+ +
+ +
+`; + +exports[`CreateIndexPatternWizard renders when there are no indices but there are remote clusters 1`] = ` + +
+
+ +
+ +
+`; + +exports[`CreateIndexPatternWizard shows system indices even if there are no other indices if the include system indices is toggled 1`] = ` + +
+
+ +
+ +
+`; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx index 648bf7f8f9738..d8f677b7f6089 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/step_index_pattern.tsx @@ -48,7 +48,7 @@ interface StepIndexPatternProps { esService: DataPublicPluginStart['search']['__LEGACY']['esClient']; savedObjectsClient: SavedObjectsClient; indexPatternCreationType: IndexPatternCreationConfig; - goToNextStep: () => void; + goToNextStep: (query: string) => void; initialQuery?: string; uiSettings: IUiSettingsClient; } diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.test.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.test.tsx similarity index 55% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.test.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.test.tsx index 941f87d4d9fd2..45af98661eda3 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.test.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.test.tsx @@ -21,17 +21,12 @@ import React from 'react'; import { shallow } from 'enzyme'; import { CreateIndexPatternWizard } from './create_index_pattern_wizard'; -const mockIndexPatternCreationType = { - getIndexPatternType: () => 'default', - getIndexPatternName: () => 'name', - getIsBeta: () => false, - checkIndicesForErrors: () => false, - getShowSystemIndices: () => false, - renderPrompt: () => {}, - getIndexPatternMappings: () => { - return {}; - }, -}; +import { coreMock } from '../../../../../../../../core/public/mocks'; +import { dataPluginMock } from '../../../../../../../../plugins/data/public/mocks'; +import { IndexPatternCreationConfig } from '../../../../../../../../plugins/index_pattern_management/public'; +import { IndexPattern } from '../../../../../../../../plugins/data/public'; +import { SavedObjectsClient } from '../../../../../../../../core/public'; + jest.mock('./components/step_index_pattern', () => ({ StepIndexPattern: 'StepIndexPattern' })); jest.mock('./components/step_time_field', () => ({ StepTimeField: 'StepTimeField' })); jest.mock('./components/header', () => ({ Header: 'Header' })); @@ -46,39 +41,36 @@ jest.mock('ui/chrome', () => ({ addBasePath: () => {}, })); -const loadingDataDocUrl = ''; +const { savedObjects, overlays, uiSettings } = coreMock.createStart(); +const { indexPatterns, search } = dataPluginMock.createStartContract(); +const mockIndexPatternCreationType = new IndexPatternCreationConfig({ + type: 'default', + name: 'name', +}); + const initialQuery = ''; const services = { - es: {}, - indexPatterns: {}, - savedObjectsClient: {}, - config: {}, - changeUrl: () => {}, - scopeApply: () => {}, - + es: search.__LEGACY.esClient, + indexPatterns, + savedObjectsClient: savedObjects.client as SavedObjectsClient, + uiSettings, + changeUrl: jest.fn(), + openConfirm: overlays.openConfirm, indexPatternCreationType: mockIndexPatternCreationType, }; describe('CreateIndexPatternWizard', () => { - it(`defaults to the loading state`, async () => { + test(`defaults to the loading state`, () => { const component = shallow( - + ); expect(component).toMatchSnapshot(); }); - it('renders the empty state when there are no indices', async () => { + test('renders the empty state when there are no indices', async () => { const component = shallow( - + ); component.setState({ @@ -91,13 +83,9 @@ describe('CreateIndexPatternWizard', () => { expect(component).toMatchSnapshot(); }); - it('renders when there are no indices but there are remote clusters', async () => { + test('renders when there are no indices but there are remote clusters', async () => { const component = shallow( - + ); component.setState({ @@ -110,13 +98,9 @@ describe('CreateIndexPatternWizard', () => { expect(component).toMatchSnapshot(); }); - it('shows system indices even if there are no other indices if the include system indices is toggled', async () => { + test('shows system indices even if there are no other indices if the include system indices is toggled', async () => { const component = shallow( - + ); component.setState({ @@ -129,13 +113,9 @@ describe('CreateIndexPatternWizard', () => { expect(component).toMatchSnapshot(); }); - it('renders index pattern step when there are indices', async () => { + test('renders index pattern step when there are indices', async () => { const component = shallow( - + ); component.setState({ @@ -147,13 +127,9 @@ describe('CreateIndexPatternWizard', () => { expect(component).toMatchSnapshot(); }); - it('renders time field step when step is set to 2', async () => { + test('renders time field step when step is set to 2', async () => { const component = shallow( - + ); component.setState({ @@ -166,37 +142,30 @@ describe('CreateIndexPatternWizard', () => { expect(component).toMatchSnapshot(); }); - it('invokes the provided services when creating an index pattern', async () => { - const get = jest.fn(); - const set = jest.fn(); + test('invokes the provided services when creating an index pattern', async () => { const create = jest.fn().mockImplementation(() => 'id'); const clear = jest.fn(); - const changeUrl = jest.fn(); - - const component = shallow( - ({ - create, - }), - clearCache: clear, - }, - changeUrl, - indexPatternCreationType: mockIndexPatternCreationType, - }} - /> + services.indexPatterns.clearCache = clear; + const indexPattern = ({ + id: '1', + title: 'my-fake-index-pattern', + timeFieldName: 'timestamp', + fields: [], + create, + } as unknown) as IndexPattern; + services.indexPatterns.make = async () => { + return indexPattern; + }; + + const component = shallow( + ); component.setState({ indexPattern: 'foo' }); - await component.instance().createIndexPattern(null, 'id'); - expect(get).toBeCalled(); + await component.instance().createIndexPattern(undefined, 'id'); + expect(services.uiSettings.get).toBeCalled(); expect(create).toBeCalled(); expect(clear).toBeCalledWith('id'); - expect(changeUrl).toBeCalledWith(`/management/kibana/index_patterns/id`); + expect(services.changeUrl).toBeCalledWith(`/management/kibana/index_patterns/id`); }); }); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.tsx similarity index 63% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.tsx index 1a93188edd6cc..4166d48349d35 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/create_index_pattern_wizard.tsx @@ -17,11 +17,11 @@ * under the License. */ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; +import React, { ReactElement, Component } from 'react'; -import { EuiGlobalToastList } from '@elastic/eui'; +import { EuiGlobalToastList, EuiGlobalToastListToast } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; import { StepIndexPattern } from './components/step_index_pattern'; import { StepTimeField } from './components/step_time_field'; @@ -31,41 +31,61 @@ import { EmptyState } from './components/empty_state'; import { MAX_SEARCH_SIZE } from './constants'; import { ensureMinimumTime, getIndices } from './lib'; -import { i18n } from '@kbn/i18n'; - -export class CreateIndexPatternWizard extends Component { - static propTypes = { - initialQuery: PropTypes.string, - services: PropTypes.shape({ - es: PropTypes.object.isRequired, - indexPatterns: PropTypes.object.isRequired, - savedObjectsClient: PropTypes.object.isRequired, - indexPatternCreationType: PropTypes.object.isRequired, - config: PropTypes.object.isRequired, - changeUrl: PropTypes.func.isRequired, - openConfirm: PropTypes.func.isRequired, - }).isRequired, +import { + SavedObjectsClient, + IUiSettingsClient, + OverlayStart, +} from '../../../../../../../../core/public'; +import { DataPublicPluginStart } from '../../../../../../../../plugins/data/public'; +import { IndexPatternCreationConfig } from '../../../../../../../../plugins/index_pattern_management/public'; +import { MatchedIndex } from './types'; + +interface CreateIndexPatternWizardProps { + initialQuery: string; + services: { + indexPatternCreationType: IndexPatternCreationConfig; + es: DataPublicPluginStart['search']['__LEGACY']['esClient']; + indexPatterns: DataPublicPluginStart['indexPatterns']; + savedObjectsClient: SavedObjectsClient; + uiSettings: IUiSettingsClient; + changeUrl: (url: string) => void; + openConfirm: OverlayStart['openConfirm']; }; +} - constructor(props) { - super(props); - this.indexPatternCreationType = this.props.services.indexPatternCreationType; - this.state = { - step: 1, - indexPattern: '', - allIndices: [], - remoteClustersExist: false, - isInitiallyLoadingIndices: true, - isIncludingSystemIndices: false, - toasts: [], - }; - } +interface CreateIndexPatternWizardState { + step: number; + indexPattern: string; + allIndices: MatchedIndex[]; + remoteClustersExist: boolean; + isInitiallyLoadingIndices: boolean; + isIncludingSystemIndices: boolean; + toasts: EuiGlobalToastListToast[]; +} + +export class CreateIndexPatternWizard extends Component< + CreateIndexPatternWizardProps, + CreateIndexPatternWizardState +> { + state = { + step: 1, + indexPattern: '', + allIndices: [], + remoteClustersExist: false, + isInitiallyLoadingIndices: true, + isIncludingSystemIndices: false, + toasts: [], + }; async UNSAFE_componentWillMount() { this.fetchData(); } - catchAndWarn = async (asyncFn, errorValue, errorMsg) => { + catchAndWarn = async ( + asyncFn: Promise, + errorValue: [] | string[], + errorMsg: ReactElement + ) => { try { return await asyncFn; } catch (errors) { @@ -109,22 +129,26 @@ export class CreateIndexPatternWizard extends Component { // query local and remote indices, updating state independently ensureMinimumTime( this.catchAndWarn( - getIndices(services.es, this.indexPatternCreationType, `*`, MAX_SEARCH_SIZE), + getIndices(services.es, services.indexPatternCreationType, `*`, MAX_SEARCH_SIZE), [], indicesFailMsg ) - ).then(allIndices => this.setState({ allIndices, isInitiallyLoadingIndices: false })); + ).then((allIndices: MatchedIndex[]) => + this.setState({ allIndices, isInitiallyLoadingIndices: false }) + ); this.catchAndWarn( // if we get an error from remote cluster query, supply fallback value that allows user entry. // ['a'] is fallback value - getIndices(services.es, this.indexPatternCreationType, `*:*`, 1), + getIndices(services.es, services.indexPatternCreationType, `*:*`, 1), ['a'], clustersFailMsg - ).then(remoteIndices => this.setState({ remoteClustersExist: !!remoteIndices.length })); + ).then((remoteIndices: string[] | MatchedIndex[]) => + this.setState({ remoteClustersExist: !!remoteIndices.length }) + ); }; - createIndexPattern = async (timeFieldName, indexPatternId) => { + createIndexPattern = async (timeFieldName: string | undefined, indexPatternId: string) => { const { services } = this.props; const { indexPattern } = this.state; @@ -134,13 +158,13 @@ export class CreateIndexPatternWizard extends Component { id: indexPatternId, title: indexPattern, timeFieldName, - ...this.indexPatternCreationType.getIndexPatternMappings(), + ...services.indexPatternCreationType.getIndexPatternMappings(), }); const createdId = await emptyPattern.create(); if (!createdId) { const confirmMessage = i18n.translate('kbn.management.indexPattern.titleExistsLabel', { - values: { title: this.title }, + values: { title: emptyPattern.title }, defaultMessage: "An index pattern with the title '{title}' already exists.", }); @@ -157,15 +181,15 @@ export class CreateIndexPatternWizard extends Component { } } - if (!services.config.get('defaultIndex')) { - await services.config.set('defaultIndex', createdId); + if (!services.uiSettings.get('defaultIndex')) { + await services.uiSettings.set('defaultIndex', createdId); } services.indexPatterns.clearCache(createdId); services.changeUrl(`/management/kibana/index_patterns/${createdId}`); }; - goToTimeFieldStep = indexPattern => { + goToTimeFieldStep = (indexPattern: string) => { this.setState({ step: 2, indexPattern }); }; @@ -174,22 +198,23 @@ export class CreateIndexPatternWizard extends Component { }; onChangeIncludingSystemIndices = () => { - this.setState(state => ({ - isIncludingSystemIndices: !state.isIncludingSystemIndices, + this.setState(prevState => ({ + isIncludingSystemIndices: !prevState.isIncludingSystemIndices, })); }; renderHeader() { const { isIncludingSystemIndices } = this.state; + const { services } = this.props; return (
); } @@ -208,7 +233,7 @@ export class CreateIndexPatternWizard extends Component { return ; } - const hasDataIndices = allIndices.some(({ name }) => !name.startsWith('.')); + const hasDataIndices = allIndices.some(({ name }: MatchedIndex) => !name.startsWith('.')); if (!hasDataIndices && !isIncludingSystemIndices && !remoteClustersExist) { return ; } @@ -222,7 +247,7 @@ export class CreateIndexPatternWizard extends Component { isIncludingSystemIndices={isIncludingSystemIndices} esService={services.es} savedObjectsClient={services.savedObjectsClient} - indexPatternCreationType={this.indexPatternCreationType} + indexPatternCreationType={services.indexPatternCreationType} goToNextStep={this.goToTimeFieldStep} uiSettings={services.uiSettings} /> @@ -237,7 +262,7 @@ export class CreateIndexPatternWizard extends Component { indexPatternsService={services.indexPatterns} goToPreviousStep={this.goToIndexPatternStep} createIndexPattern={this.createIndexPattern} - indexPatternCreationType={this.indexPatternCreationType} + indexPatternCreationType={services.indexPatternCreationType} /> ); } @@ -245,9 +270,9 @@ export class CreateIndexPatternWizard extends Component { return null; } - removeToast = removedToast => { + removeToast = (id: string) => { this.setState(prevState => ({ - toasts: prevState.toasts.filter(toast => toast.id !== removedToast.id), + toasts: prevState.toasts.filter(toast => toast.id !== id), })); }; @@ -263,7 +288,9 @@ export class CreateIndexPatternWizard extends Component {
{ + this.removeToast(id); + }} toastLifeTimeMs={6000} /> diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js index 47cb773258cb4..ed1fc026c560c 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/index.js @@ -36,17 +36,15 @@ uiRoutes.when('/management/kibana/index_pattern', { $routeParams.type ); const services = { - config: npStart.core.uiSettings, + uiSettings: npStart.core.uiSettings, es: npStart.plugins.data.search.__LEGACY.esClient, indexPatterns: npStart.plugins.data.indexPatterns, - $http: npStart.core.http, savedObjectsClient: npStart.core.savedObjects.client, indexPatternCreationType, changeUrl: url => { $scope.$evalAsync(() => kbnUrl.changePath(url)); }, openConfirm: npStart.core.overlays.openConfirm, - uiSettings: npStart.core.uiSettings, }; const initialQuery = $routeParams.id ? decodeURIComponent($routeParams.id) : undefined; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/lib/get_indices.test.ts b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/lib/get_indices.test.ts index 40583af7177fe..b1500f8303b66 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/lib/get_indices.test.ts +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/lib/get_indices.test.ts @@ -20,7 +20,7 @@ import { getIndices } from './get_indices'; import { IndexPatternCreationConfig } from '../../../../../../../../../plugins/index_pattern_management/public'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LegacyApiCaller } from '../../../../../../../../../plugins/data/public/search'; +import { LegacyApiCaller } from '../../../../../../../../../plugins/data/public/search/legacy'; export const successfulResponse = { hits: { diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/constants.ts b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/constants.ts new file mode 100644 index 0000000000000..56da031eb4ee8 --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/constants.ts @@ -0,0 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export const TAB_INDEXED_FIELDS = 'indexedFields'; +export const TAB_SCRIPTED_FIELDS = 'scriptedFields'; +export const TAB_SOURCE_FILTERS = 'sourceFilters'; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.html b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field.html similarity index 100% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.html rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field.html diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.js deleted file mode 100644 index 95d6cb6878e53..0000000000000 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.js +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { IndexPatternField } from '../../../../../../../../../plugins/data/public'; -import { RegistryFieldFormatEditorsProvider } from 'ui/registry/field_format_editors'; -import { docTitle } from 'ui/doc_title'; -import { KbnUrlProvider } from 'ui/url'; -import uiRoutes from 'ui/routes'; -import { toastNotifications } from 'ui/notify'; -import { npStart } from 'ui/new_platform'; - -import template from './create_edit_field.html'; -import { getEditFieldBreadcrumbs, getCreateFieldBreadcrumbs } from '../../breadcrumbs'; - -import React from 'react'; -import { render, unmountComponentAtNode } from 'react-dom'; -import { FieldEditor } from 'ui/field_editor'; -import { I18nContext } from 'ui/i18n'; -import { i18n } from '@kbn/i18n'; - -import { IndexHeader } from '../index_header'; - -const REACT_FIELD_EDITOR_ID = 'reactFieldEditor'; -const renderFieldEditor = ( - $scope, - indexPattern, - field, - { getConfig, $http, fieldFormatEditors, redirectAway } -) => { - $scope.$$postDigest(() => { - const node = document.getElementById(REACT_FIELD_EDITOR_ID); - if (!node) { - return; - } - - render( - - - - , - node - ); - }); -}; - -const destroyFieldEditor = () => { - const node = document.getElementById(REACT_FIELD_EDITOR_ID); - node && unmountComponentAtNode(node); -}; - -uiRoutes - .when('/management/kibana/index_patterns/:indexPatternId/field/:fieldName*', { - mode: 'edit', - k7Breadcrumbs: getEditFieldBreadcrumbs, - }) - .when('/management/kibana/index_patterns/:indexPatternId/create-field/', { - mode: 'create', - k7Breadcrumbs: getCreateFieldBreadcrumbs, - }) - .defaults(/management\/kibana\/index_patterns\/[^\/]+\/(field|create-field)(\/|$)/, { - template, - mapBreadcrumbs($route, breadcrumbs) { - const { indexPattern } = $route.current.locals; - return breadcrumbs.map(crumb => { - if (crumb.id !== indexPattern.id) { - return crumb; - } - - return { - ...crumb, - display: indexPattern.title, - }; - }); - }, - resolve: { - indexPattern: function($route, Promise, redirectWhenMissing) { - const { indexPatterns } = npStart.plugins.data; - return Promise.resolve(indexPatterns.get($route.current.params.indexPatternId)).catch( - redirectWhenMissing('/management/kibana/index_patterns') - ); - }, - }, - controllerAs: 'fieldSettings', - controller: function FieldEditorPageController( - $scope, - $route, - $timeout, - $http, - Private, - config - ) { - const getConfig = (...args) => config.get(...args); - const fieldFormatEditors = Private(RegistryFieldFormatEditorsProvider); - const kbnUrl = Private(KbnUrlProvider); - - this.mode = $route.current.mode; - this.indexPattern = $route.current.locals.indexPattern; - - if (this.mode === 'edit') { - const fieldName = $route.current.params.fieldName; - this.field = this.indexPattern.fields.getByName(fieldName); - - if (!this.field) { - const message = i18n.translate('kbn.management.editIndexPattern.scripted.noFieldLabel', { - defaultMessage: - "'{indexPatternTitle}' index pattern doesn't have a scripted field called '{fieldName}'", - values: { indexPatternTitle: this.indexPattern.title, fieldName }, - }); - toastNotifications.add(message); - - kbnUrl.redirectToRoute(this.indexPattern, 'edit'); - return; - } - } else if (this.mode === 'create') { - this.field = new IndexPatternField(this.indexPattern, { - scripted: true, - type: 'number', - }); - } else { - const errorMessage = i18n.translate( - 'kbn.management.editIndexPattern.scripted.unknownModeErrorMessage', - { - defaultMessage: 'unknown fieldSettings mode {mode}', - values: { mode: this.mode }, - } - ); - throw new Error(errorMessage); - } - - const fieldName = - this.field.name || - i18n.translate('kbn.management.editIndexPattern.scripted.newFieldPlaceholder', { - defaultMessage: 'New Scripted Field', - }); - docTitle.change([fieldName, this.indexPattern.title]); - - renderFieldEditor($scope, this.indexPattern, this.field, { - getConfig, - $http, - fieldFormatEditors, - redirectAway: () => { - $timeout(() => { - kbnUrl.changeToRoute( - this.indexPattern, - this.field.scripted ? 'scriptedFields' : 'indexedFields' - ); - }); - }, - }); - - $scope.$on('$destroy', () => { - destroyFieldEditor(); - }); - }, - }); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx new file mode 100644 index 0000000000000..4839870f0f3c8 --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx @@ -0,0 +1,111 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React from 'react'; +import { withRouter, RouteComponentProps } from 'react-router-dom'; +// @ts-ignore +import { FieldEditor } from 'ui/field_editor'; + +import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { IndexHeader } from '../index_header'; +import { IndexPattern, IndexPatternField } from '../../../../../../../../../plugins/data/public'; +import { ChromeDocTitle, NotificationsStart } from '../../../../../../../../../core/public'; +import { TAB_SCRIPTED_FIELDS, TAB_INDEXED_FIELDS } from '../constants'; + +interface CreateEditFieldProps extends RouteComponentProps { + indexPattern: IndexPattern; + mode?: string; + fieldName?: string; + fieldFormatEditors: any; + getConfig: (name: string) => any; + services: { + notifications: NotificationsStart; + docTitle: ChromeDocTitle; + http: Function; + }; +} + +const newFieldPlaceholder = i18n.translate( + 'kbn.management.editIndexPattern.scripted.newFieldPlaceholder', + { + defaultMessage: 'New Scripted Field', + } +); + +export const CreateEditField = withRouter( + ({ + indexPattern, + mode, + fieldName, + fieldFormatEditors, + getConfig, + services, + history, + }: CreateEditFieldProps) => { + const field = + mode === 'edit' && fieldName + ? indexPattern.fields.getByName(fieldName) + : new IndexPatternField(indexPattern, { + scripted: true, + type: 'number', + }); + + const url = `/management/kibana/index_patterns/${indexPattern.id}`; + + if (mode === 'edit') { + if (!field) { + const message = i18n.translate('kbn.management.editIndexPattern.scripted.noFieldLabel', { + defaultMessage: + "'{indexPatternTitle}' index pattern doesn't have a scripted field called '{fieldName}'", + values: { indexPatternTitle: indexPattern.title, fieldName }, + }); + services.notifications.toasts.addWarning(message); + history.push(url); + } + } + + const docFieldName = field?.name || newFieldPlaceholder; + + services.docTitle.change([docFieldName, indexPattern.title]); + + const redirectAway = () => { + history.push(`${url}?_a=(tab:${field?.scripted ? TAB_SCRIPTED_FIELDS : TAB_INDEXED_FIELDS})`); + }; + + return ( + + + + + + + + + ); + } +); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/index.ts similarity index 93% rename from src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/index.js rename to src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/index.ts index 890a3b2622577..473a8f5b57c82 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/index.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/index.ts @@ -17,4 +17,4 @@ * under the License. */ -import './create_edit_field'; +export { CreateEditField } from './create_edit_field'; diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js index 69184a513f53a..3239a17f109e4 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js @@ -18,15 +18,18 @@ */ import _ from 'lodash'; +import { HashRouter } from 'react-router-dom'; import { IndexHeader } from './index_header'; -import './create_edit_field'; +import { CreateEditField } from './create_edit_field'; import { docTitle } from 'ui/doc_title'; import { KbnUrlProvider } from 'ui/url'; import { IndicesEditSectionsProvider } from './edit_sections'; import { fatalError, toastNotifications } from 'ui/notify'; +import { RegistryFieldFormatEditorsProvider } from 'ui/registry/field_format_editors'; import uiRoutes from 'ui/routes'; import { uiModules } from 'ui/modules'; import template from './edit_index_pattern.html'; +import createEditFieldtemplate from './create_edit_field.html'; import { fieldWildcardMatcher } from '../../../../../../../../plugins/kibana_utils/public'; import { subscribeWithScope } from '../../../../../../../../plugins/kibana_legacy/public'; import React from 'react'; @@ -37,8 +40,12 @@ import { ScriptedFieldsTable } from './scripted_fields_table'; import { i18n } from '@kbn/i18n'; import { I18nContext } from 'ui/i18n'; import { npStart } from 'ui/new_platform'; - -import { getEditBreadcrumbs } from '../breadcrumbs'; +import { + getEditBreadcrumbs, + getEditFieldBreadcrumbs, + getCreateFieldBreadcrumbs, +} from '../breadcrumbs'; +import { TAB_INDEXED_FIELDS, TAB_SCRIPTED_FIELDS, TAB_SOURCE_FILTERS } from './constants'; import { createEditIndexPatternPageStateContainer } from './edit_index_pattern_state_container'; const REACT_SOURCE_FILTERS_DOM_ELEMENT_ID = 'reactSourceFiltersTable'; @@ -46,10 +53,6 @@ const REACT_INDEXED_FIELDS_DOM_ELEMENT_ID = 'reactIndexedFieldsTable'; const REACT_SCRIPTED_FIELDS_DOM_ELEMENT_ID = 'reactScriptedFieldsTable'; const REACT_INDEX_HEADER_DOM_ELEMENT_ID = 'reactIndexHeader'; -const TAB_INDEXED_FIELDS = 'indexedFields'; -const TAB_SCRIPTED_FIELDS = 'scriptedFields'; -const TAB_SOURCE_FILTERS = 'sourceFilters'; - const EDIT_FIELD_PATH = '/management/kibana/index_patterns/{{indexPattern.id}}/field/{{name}}'; function updateSourceFiltersTable($scope) { @@ -425,3 +428,84 @@ uiModules renderIndexHeader($scope, config); }); + +// routes for create edit field. Will be removed after migartion all component to react. +const REACT_FIELD_EDITOR_ID = 'reactFieldEditor'; +const renderCreateEditField = ($scope, $route, getConfig, $http, fieldFormatEditors) => { + $scope.$$postDigest(() => { + const node = document.getElementById(REACT_FIELD_EDITOR_ID); + if (!node) { + return; + } + + render( + + + + + , + node + ); + }); +}; + +const destroyCreateEditField = () => { + const node = document.getElementById(REACT_FIELD_EDITOR_ID); + node && unmountComponentAtNode(node); +}; + +uiRoutes + .when('/management/kibana/index_patterns/:indexPatternId/field/:fieldName*', { + mode: 'edit', + k7Breadcrumbs: getEditFieldBreadcrumbs, + }) + .when('/management/kibana/index_patterns/:indexPatternId/create-field/', { + mode: 'create', + k7Breadcrumbs: getCreateFieldBreadcrumbs, + }) + .defaults(/management\/kibana\/index_patterns\/[^\/]+\/(field|create-field)(\/|$)/, { + template: createEditFieldtemplate, + mapBreadcrumbs($route, breadcrumbs) { + const { indexPattern } = $route.current.locals; + return breadcrumbs.map(crumb => { + if (crumb.id !== indexPattern.id) { + return crumb; + } + + return { + ...crumb, + display: indexPattern.title, + }; + }); + }, + resolve: { + indexPattern: function($route, Promise, redirectWhenMissing) { + const { indexPatterns } = npStart.plugins.data; + return Promise.resolve(indexPatterns.get($route.current.params.indexPatternId)).catch( + redirectWhenMissing('/management/kibana/index_patterns') + ); + }, + }, + controllerAs: 'fieldSettings', + controller: function FieldEditorPageController($scope, $route, $http, Private, config) { + const getConfig = (...args) => config.get(...args); + const fieldFormatEditors = Private(RegistryFieldFormatEditorsProvider); + + renderCreateEditField($scope, $route, getConfig, $http, fieldFormatEditors); + + $scope.$on('$destroy', () => { + destroyCreateEditField(); + }); + }, + }); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index_header/index_header.tsx b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index_header/index_header.tsx index 866d10ecb0e19..deac85d9a32e9 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index_header/index_header.tsx +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index_header/index_header.tsx @@ -30,8 +30,8 @@ import { import { IIndexPattern } from '../../../../../../../../../plugins/data/public'; interface IndexHeaderProps { - defaultIndex: string; indexPattern: IIndexPattern; + defaultIndex?: string; setDefault?: () => void; refreshFields?: () => void; deleteIndexPattern?: () => void; @@ -77,7 +77,7 @@ export function IndexHeader({ )} - +

{indexPattern.title}

diff --git a/src/legacy/core_plugins/timelion/public/app.js b/src/legacy/core_plugins/timelion/public/app.js index c15318d29e761..7f5c7d4664af8 100644 --- a/src/legacy/core_plugins/timelion/public/app.js +++ b/src/legacy/core_plugins/timelion/public/app.js @@ -27,10 +27,11 @@ import { fatalError, toastNotifications } from 'ui/notify'; import { timefilter } from 'ui/timefilter'; import { npStart } from 'ui/new_platform'; import { getSavedSheetBreadcrumbs, getCreateBreadcrumbs } from './breadcrumbs'; -import { getTimezone } from '../../vis_type_timelion/public'; +import { getTimezone } from '../../../../plugins/vis_type_timelion/public'; import 'uiExports/savedObjectTypes'; +require('ui/i18n'); require('ui/autoload/all'); // TODO: remove ui imports completely (move to plugins) @@ -57,7 +58,7 @@ require('plugins/timelion/directives/timelion_options_sheet'); document.title = 'Timelion - Kibana'; -const app = require('ui/modules').get('apps/timelion', []); +const app = require('ui/modules').get('apps/timelion', ['i18n', 'ngSanitize']); require('ui/routes').enable(); diff --git a/src/legacy/core_plugins/timelion/public/directives/timelion_expression_input.js b/src/legacy/core_plugins/timelion/public/directives/timelion_expression_input.js index 57262fda55e48..35ac883e5d99c 100644 --- a/src/legacy/core_plugins/timelion/public/directives/timelion_expression_input.js +++ b/src/legacy/core_plugins/timelion/public/directives/timelion_expression_input.js @@ -43,7 +43,7 @@ import _ from 'lodash'; import $ from 'jquery'; import PEG from 'pegjs'; -import grammar from 'raw-loader!../../../../../plugins/timelion/common/chain.peg'; +import grammar from 'raw-loader!../../../../../plugins/vis_type_timelion/common/chain.peg'; import timelionExpressionInputTemplate from './timelion_expression_input.html'; import { SUGGESTION_TYPE, @@ -52,7 +52,7 @@ import { insertAtLocation, } from './timelion_expression_input_helpers'; import { comboBoxKeyCodes } from '@elastic/eui'; -import { getArgValueSuggestions } from '../../../vis_type_timelion/public/helpers/arg_value_suggestions'; +import { npStart } from 'ui/new_platform'; const Parser = PEG.generate(grammar); @@ -68,7 +68,7 @@ export function TimelionExpInput($http, $timeout) { replace: true, template: timelionExpressionInputTemplate, link: function(scope, elem) { - const argValueSuggestions = getArgValueSuggestions(); + const argValueSuggestions = npStart.plugins.visTypeTimelion.getArgValueSuggestions(); const expressionInput = elem.find('[data-expression-input]'); const functionReference = {}; let suggestibleFunctionLocation = {}; diff --git a/src/legacy/core_plugins/timelion/public/panels/timechart/schema.ts b/src/legacy/core_plugins/timelion/public/panels/timechart/schema.ts index cd40cbfa89ffe..34b389f5ff4ce 100644 --- a/src/legacy/core_plugins/timelion/public/panels/timechart/schema.ts +++ b/src/legacy/core_plugins/timelion/public/panels/timechart/schema.ts @@ -17,7 +17,8 @@ * under the License. */ -import '../../../../vis_type_timelion/public/flot'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import '../../../../../../plugins/vis_type_timelion/public/flot'; import _ from 'lodash'; import $ from 'jquery'; import moment from 'moment-timezone'; @@ -28,11 +29,14 @@ import { calculateInterval, DEFAULT_TIME_FORMAT, // @ts-ignore -} from '../../../../../../plugins/timelion/common/lib'; -import { tickFormatters } from '../../../../vis_type_timelion/public/helpers/tick_formatters'; +} from '../../../../../../plugins/vis_type_timelion/common/lib'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { tickFormatters } from '../../../../../../plugins/vis_type_timelion/public/helpers/tick_formatters'; import { TimelionVisualizationDependencies } from '../../plugin'; -import { xaxisFormatterProvider } from '../../../../vis_type_timelion/public/helpers/xaxis_formatter'; -import { generateTicksProvider } from '../../../../vis_type_timelion/public/helpers/tick_generator'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { xaxisFormatterProvider } from '../../../../../../plugins/vis_type_timelion/public/helpers/xaxis_formatter'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { generateTicksProvider } from '../../../../../../plugins/vis_type_timelion/public/helpers/tick_generator'; const DEBOUNCE_DELAY = 50; diff --git a/src/legacy/core_plugins/vis_type_table/index.ts b/src/legacy/core_plugins/vis_type_table/index.ts deleted file mode 100644 index 04ca9da7de32b..0000000000000 --- a/src/legacy/core_plugins/vis_type_table/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { resolve } from 'path'; -import { Legacy } from 'kibana'; - -import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types'; - -const tableVisPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => - new Plugin({ - id: 'table_vis', - require: ['kibana', 'elasticsearch'], - publicDir: resolve(__dirname, 'public'), - uiExports: { - styleSheetPaths: resolve(__dirname, 'public/index.scss'), - hacks: [resolve(__dirname, 'public/legacy')], - injectDefaultVars: server => ({}), - }, - init: (server: Legacy.Server) => ({}), - config(Joi: any) { - return Joi.object({ - enabled: Joi.boolean().default(true), - }).default(); - }, - } as Legacy.PluginSpecOptions); - -// eslint-disable-next-line import/no-default-export -export default tableVisPluginInitializer; diff --git a/src/legacy/core_plugins/vis_type_table/package.json b/src/legacy/core_plugins/vis_type_table/package.json deleted file mode 100644 index 2809b0e047836..0000000000000 --- a/src/legacy/core_plugins/vis_type_table/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "table_vis", - "version": "kibana" -} diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/_index.scss b/src/legacy/core_plugins/vis_type_table/public/agg_table/_index.scss deleted file mode 100644 index b19d4a887a7f3..0000000000000 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'agg_table'; diff --git a/src/legacy/core_plugins/vis_type_table/public/paginated_table/_index.scss b/src/legacy/core_plugins/vis_type_table/public/paginated_table/_index.scss deleted file mode 100644 index 9473b847d3c2b..0000000000000 --- a/src/legacy/core_plugins/vis_type_table/public/paginated_table/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import './table_cell_filter'; diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts b/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts deleted file mode 100644 index 43816121bc23b..0000000000000 --- a/src/legacy/core_plugins/vis_type_table/public/table_vis_type.ts +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { i18n } from '@kbn/i18n'; -import { AggGroupNames } from '../../../../plugins/data/public'; -import { Schemas } from '../../../../plugins/vis_default_editor/public'; -import { Vis } from '../../../../plugins/visualizations/public'; -import { tableVisResponseHandler } from './table_vis_response_handler'; -// @ts-ignore -import tableVisTemplate from './table_vis.html'; -import { TableOptions } from './components/table_vis_options'; -import { TableVisualizationController } from './vis_controller'; - -export const tableVisTypeDefinition = { - type: 'table', - name: 'table', - title: i18n.translate('visTypeTable.tableVisTitle', { - defaultMessage: 'Data Table', - }), - icon: 'visTable', - description: i18n.translate('visTypeTable.tableVisDescription', { - defaultMessage: 'Display values in a table', - }), - visualization: TableVisualizationController, - visConfig: { - defaults: { - perPage: 10, - showPartialRows: false, - showMetricsAtAllLevels: false, - sort: { - columnIndex: null, - direction: null, - }, - showTotal: false, - totalFunc: 'sum', - percentageCol: '', - }, - template: tableVisTemplate, - }, - editorConfig: { - optionsTemplate: TableOptions, - schemas: new Schemas([ - { - group: AggGroupNames.Metrics, - name: 'metric', - title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.metricTitle', { - defaultMessage: 'Metric', - }), - aggFilter: ['!geo_centroid', '!geo_bounds'], - aggSettings: { - top_hits: { - allowStrings: true, - }, - }, - min: 1, - defaults: [{ type: 'count', schema: 'metric' }], - }, - { - group: AggGroupNames.Buckets, - name: 'bucket', - title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.bucketTitle', { - defaultMessage: 'Split rows', - }), - aggFilter: ['!filter'], - }, - { - group: AggGroupNames.Buckets, - name: 'split', - title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.splitTitle', { - defaultMessage: 'Split table', - }), - min: 0, - max: 1, - aggFilter: ['!filter'], - }, - ]), - }, - responseHandler: tableVisResponseHandler, - hierarchicalData: (vis: Vis) => { - return Boolean(vis.params.showPartialRows || vis.params.showMetricsAtAllLevels); - }, -}; diff --git a/src/legacy/core_plugins/vis_type_table/public/vis_controller.ts b/src/legacy/core_plugins/vis_type_table/public/vis_controller.ts deleted file mode 100644 index 5bb730d2f9b10..0000000000000 --- a/src/legacy/core_plugins/vis_type_table/public/vis_controller.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import angular, { IModule, auto, IRootScopeService, IScope, ICompileService } from 'angular'; -import $ from 'jquery'; - -import { VisParams, ExprVis } from '../../../../plugins/visualizations/public'; -import { npStart } from './legacy_imports'; -import { getAngularModule } from './get_inner_angular'; -import { initTableVisLegacyModule } from './table_vis_legacy_module'; - -const innerAngularName = 'kibana/table_vis'; - -export class TableVisualizationController { - private tableVisModule: IModule | undefined; - private injector: auto.IInjectorService | undefined; - el: JQuery; - vis: ExprVis; - $rootScope: IRootScopeService | null = null; - $scope: (IScope & { [key: string]: any }) | undefined; - $compile: ICompileService | undefined; - - constructor(domeElement: Element, vis: ExprVis) { - this.el = $(domeElement); - this.vis = vis; - } - - getInjector() { - if (!this.injector) { - const mountpoint = document.createElement('div'); - mountpoint.setAttribute('style', 'height: 100%; width: 100%;'); - this.injector = angular.bootstrap(mountpoint, [innerAngularName]); - this.el.append(mountpoint); - } - - return this.injector; - } - - initLocalAngular() { - if (!this.tableVisModule) { - this.tableVisModule = getAngularModule(innerAngularName, npStart.core); - initTableVisLegacyModule(this.tableVisModule); - } - } - - async render(esResponse: object, visParams: VisParams) { - this.initLocalAngular(); - - return new Promise(async (resolve, reject) => { - if (!this.$rootScope) { - const $injector = this.getInjector(); - this.$rootScope = $injector.get('$rootScope'); - this.$compile = $injector.get('$compile'); - } - const updateScope = () => { - if (!this.$scope) { - return; - } - this.$scope.vis = this.vis; - this.$scope.visState = { params: visParams }; - this.$scope.esResponse = esResponse; - - this.$scope.visParams = visParams; - this.$scope.renderComplete = resolve; - this.$scope.renderFailed = reject; - this.$scope.resize = Date.now(); - this.$scope.$apply(); - }; - - if (!this.$scope && this.$compile) { - this.$scope = this.$rootScope.$new(); - this.$scope.uiState = this.vis.getUiState(); - updateScope(); - this.el.find('div').append(this.$compile(this.vis.type!.visConfig.template)(this.$scope)); - this.$scope.$apply(); - } else { - updateScope(); - } - }); - } - - destroy() { - if (this.$rootScope) { - this.$rootScope.$destroy(); - this.$rootScope = null; - } - } -} diff --git a/src/legacy/core_plugins/vis_type_timelion/index.ts b/src/legacy/core_plugins/vis_type_timelion/index.ts deleted file mode 100644 index 7bca5154c84fd..0000000000000 --- a/src/legacy/core_plugins/vis_type_timelion/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { resolve } from 'path'; -import { Legacy } from 'kibana'; - -import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types'; - -const timelionVisPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => - new Plugin({ - id: 'timelion_vis', - require: ['kibana', 'elasticsearch'], - publicDir: resolve(__dirname, 'public'), - uiExports: { - styleSheetPaths: resolve(__dirname, 'public/index.scss'), - hacks: [resolve(__dirname, 'public/legacy')], - injectDefaultVars: server => ({}), - }, - init: (server: Legacy.Server) => ({}), - config(Joi: any) { - return Joi.object({ - enabled: Joi.boolean().default(true), - }).default(); - }, - }); - -// eslint-disable-next-line import/no-default-export -export default timelionVisPluginInitializer; diff --git a/src/legacy/core_plugins/vis_type_timelion/package.json b/src/legacy/core_plugins/vis_type_timelion/package.json deleted file mode 100644 index 9b09f98ce6caf..0000000000000 --- a/src/legacy/core_plugins/vis_type_timelion/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "timelion_vis", - "version": "kibana" -} diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/_index.scss b/src/legacy/core_plugins/vis_type_timelion/public/components/_index.scss deleted file mode 100644 index 1d887f43ff9a1..0000000000000 --- a/src/legacy/core_plugins/vis_type_timelion/public/components/_index.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import './panel'; -@import './timelion_expression_input'; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/legacy.ts b/src/legacy/core_plugins/vis_type_timelion/public/legacy.ts deleted file mode 100644 index f8de9f94dcedf..0000000000000 --- a/src/legacy/core_plugins/vis_type_timelion/public/legacy.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { PluginInitializerContext } from 'kibana/public'; - -import { npSetup, npStart } from './legacy_imports'; -import { TimelionVisSetupDependencies } from './plugin'; -import { plugin } from '.'; - -const setupPlugins: Readonly = { - expressions: npSetup.plugins.expressions, - data: npSetup.plugins.data, - visualizations: npSetup.plugins.visualizations, -}; - -const pluginInstance = plugin({} as PluginInitializerContext); - -export const setup = pluginInstance.setup(npSetup.core, setupPlugins); -export const start = pluginInstance.start(npStart.core, npStart.plugins); diff --git a/src/legacy/server/logging/log_reporter.js b/src/legacy/server/logging/log_reporter.js index 6e62a5ee284e3..b784d03a5b86e 100644 --- a/src/legacy/server/logging/log_reporter.js +++ b/src/legacy/server/logging/log_reporter.js @@ -30,7 +30,7 @@ import { LogInterceptor } from './log_interceptor'; // thrown every time we start the server. // In order to keep using the legacy logger until we remove it I'm just adding // a new hard limit here. -process.stdout.setMaxListeners(15); +process.stdout.setMaxListeners(25); export function getLoggerStream({ events, config }) { const squeeze = new Squeeze(events); diff --git a/src/legacy/ui/public/i18n/index.tsx b/src/legacy/ui/public/i18n/index.tsx index 4d0f5d3a5bd56..c918554563fcb 100644 --- a/src/legacy/ui/public/i18n/index.tsx +++ b/src/legacy/ui/public/i18n/index.tsx @@ -44,7 +44,7 @@ export function wrapInI18nContext

(ComponentToWrap: React.ComponentType

) { } uiModules - .get('i18n') + .get('i18n', ['ngSanitize']) .provider('i18n', I18nProvider) .filter('i18n', i18nFilter) .directive('i18nId', i18nDirective); diff --git a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js index f577a29ce90b9..f14f26613ef01 100644 --- a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js +++ b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js @@ -242,6 +242,7 @@ export const npSetup = { }, kibanaLegacy: { registerLegacyApp: () => {}, + registerLegacyAppAlias: () => {}, forwardApp: () => {}, config: { defaultAppId: 'home', @@ -362,6 +363,7 @@ export const npStart = { kibanaLegacy: { getApps: () => [], getForwards: () => [], + getLegacyAppAliases: () => [], config: { defaultAppId: 'home', }, diff --git a/src/legacy/ui/public/new_platform/new_platform.ts b/src/legacy/ui/public/new_platform/new_platform.ts index 80fb837258d4c..5ae2e2348aaa1 100644 --- a/src/legacy/ui/public/new_platform/new_platform.ts +++ b/src/legacy/ui/public/new_platform/new_platform.ts @@ -69,6 +69,7 @@ import { VisualizationsSetup, VisualizationsStart, } from '../../../../plugins/visualizations/public'; +import { VisTypeTimelionPluginStart } from '../../../../plugins/vis_type_timelion/public'; import { MapsLegacyPluginSetup } from '../../../../plugins/maps_legacy/public'; export interface PluginsSetup { @@ -116,6 +117,7 @@ export interface PluginsStart { telemetry?: TelemetryPluginStart; dashboard: DashboardStart; savedObjectsManagement: SavedObjectsManagementPluginStart; + visTypeTimelion: VisTypeTimelionPluginStart; indexPatternManagement: IndexPatternManagementStart; } diff --git a/src/plugins/console/server/__tests__/proxy_route/proxy_fallback.test.ts b/src/plugins/console/server/__tests__/proxy_route/proxy_fallback.test.ts new file mode 100644 index 0000000000000..b226bad11a01a --- /dev/null +++ b/src/plugins/console/server/__tests__/proxy_route/proxy_fallback.test.ts @@ -0,0 +1,64 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { duration } from 'moment'; +import { getProxyRouteHandlerDeps } from './mocks'; + +import { kibanaResponseFactory } from '../../../../../core/server'; +import { createHandler } from '../../routes/api/console/proxy/create_handler'; +import * as requestModule from '../../lib/proxy_request'; + +describe('Console Proxy Route', () => { + afterEach(async () => { + jest.resetAllMocks(); + }); + + describe('fallback behaviour', () => { + it('falls back to all configured endpoints regardless of error', async () => { + // Describe a situation where all three configured nodes reject + (requestModule.proxyRequest as jest.Mock).mockRejectedValueOnce(new Error('ECONNREFUSED')); + (requestModule.proxyRequest as jest.Mock).mockRejectedValueOnce(new Error('EHOSTUNREACH')); + (requestModule.proxyRequest as jest.Mock).mockRejectedValueOnce(new Error('ESOCKETTIMEDOUT')); + + const handler = createHandler( + getProxyRouteHandlerDeps({ + readLegacyESConfig: () => ({ + requestTimeout: duration(30000), + customHeaders: {}, + requestHeadersWhitelist: [], + hosts: ['http://localhost:9201', 'http://localhost:9202', 'http://localhost:9203'], + }), + }) + ); + + const response = await handler( + {} as any, + { + headers: {}, + query: { method: 'get', path: 'test' }, + } as any, + kibanaResponseFactory + ); + + expect(response.status).toBe(502); + // Return the message from the ES node we attempted last. + expect(response.payload.message).toBe('ESOCKETTIMEDOUT'); + }); + }); +}); diff --git a/src/plugins/console/server/lib/spec_definitions/json/overrides/cluster.put_settings.json b/src/plugins/console/server/lib/spec_definitions/json/overrides/cluster.put_settings.json index 408b01c4cb8f5..0da2c130b47cf 100644 --- a/src/plugins/console/server/lib/spec_definitions/json/overrides/cluster.put_settings.json +++ b/src/plugins/console/server/lib/spec_definitions/json/overrides/cluster.put_settings.json @@ -59,7 +59,61 @@ } }, "transient": { - "__scope_link": ".persistent" + "cluster": { + "routing": { + "allocation.enable": { + "__one_of": ["all", "primaries", "new_primaries", "none"] + }, + "allocation.disk.threshold_enabled": { "__one_of": [false, true] }, + "allocation.disk.watermark.low": "85%", + "allocation.disk.watermark.high": "90%", + "allocation.disk.reroute_interval": "60s", + "allocation.exclude": { + "_ip": "", + "_name": "", + "_host": "", + "_id": "" + }, + "allocation.include": { + "_ip": "", + "_name": "", + "_host": "", + "_id": "" + }, + "allocation.require": { + "_ip": "", + "_name": "", + "_host": "", + "_id": "" + }, + "allocation.awareness.attributes": [], + "allocation.awareness.force": { + "*": { + "values": [] + } + }, + "allocation.allow_rebalance": { + "__one_of": [ + "always", + "indices_primaries_active", + "indices_all_active" + ] + }, + "allocation.cluster_concurrent_rebalance": 2, + "allocation.node_initial_primaries_recoveries": 4, + "allocation.node_concurrent_recoveries": 2, + "allocation.same_shard.host": { "__one_of": [false, true] } + } + }, + "indices": { + "breaker": { + "total.limit": "70%", + "fielddata.limit": "60%", + "fielddata.overhead": 1.03, + "request.limit": "40%", + "request.overhead": 1.0 + } + } } } } diff --git a/src/plugins/console/server/routes/api/console/proxy/create_handler.ts b/src/plugins/console/server/routes/api/console/proxy/create_handler.ts index 50a9fcf03c209..9446289ff03ea 100644 --- a/src/plugins/console/server/routes/api/console/proxy/create_handler.ts +++ b/src/plugins/console/server/routes/api/console/proxy/create_handler.ts @@ -175,10 +175,9 @@ export const createHandler = ({ break; } catch (e) { + // If we reached here it means we hit a lower level network issue than just, for e.g., a 500. + // We try contacting another node in that case. log.error(e); - if (e.code !== 'ECONNREFUSED') { - return response.internalError(e); - } if (idx === hosts.length - 1) { log.warn(`Could not connect to any configured ES node [${hosts.join(', ')}]`); return response.customError({ diff --git a/src/plugins/dashboard/public/application/actions/clone_panel_action.test.tsx b/src/plugins/dashboard/public/application/actions/clone_panel_action.test.tsx new file mode 100644 index 0000000000000..17943333d25b0 --- /dev/null +++ b/src/plugins/dashboard/public/application/actions/clone_panel_action.test.tsx @@ -0,0 +1,155 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { isErrorEmbeddable, IContainer } from '../../embeddable_plugin'; +import { DashboardContainer, DashboardPanelState } from '../embeddable'; +import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers'; +import { + CONTACT_CARD_EMBEDDABLE, + ContactCardEmbeddableFactory, + ContactCardEmbeddable, + ContactCardEmbeddableInput, + ContactCardEmbeddableOutput, +} from '../../embeddable_plugin_test_samples'; +import { coreMock } from '../../../../../core/public/mocks'; +import { CoreStart } from 'kibana/public'; +import { ClonePanelAction } from '.'; + +// eslint-disable-next-line +import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks'; + +const { setup, doStart } = embeddablePluginMock.createInstance(); +setup.registerEmbeddableFactory( + CONTACT_CARD_EMBEDDABLE, + new ContactCardEmbeddableFactory((() => null) as any, {} as any) +); +const start = doStart(); + +let container: DashboardContainer; +let embeddable: ContactCardEmbeddable; +let coreStart: CoreStart; +beforeEach(async () => { + coreStart = coreMock.createStart(); + coreStart.savedObjects.client = { + ...coreStart.savedObjects.client, + get: jest.fn().mockImplementation(() => ({ attributes: { title: 'Holy moly' } })), + find: jest.fn().mockImplementation(() => ({ total: 15 })), + create: jest.fn().mockImplementation(() => ({ id: 'brandNewSavedObject' })), + }; + + const options = { + ExitFullScreenButton: () => null, + SavedObjectFinder: () => null, + application: {} as any, + embeddable: start, + inspector: {} as any, + notifications: {} as any, + overlays: coreStart.overlays, + savedObjectMetaData: {} as any, + uiActions: {} as any, + }; + const input = getSampleDashboardInput({ + panels: { + '123': getSampleDashboardPanel({ + explicitInput: { firstName: 'Kibanana', id: '123' }, + type: CONTACT_CARD_EMBEDDABLE, + }), + }, + }); + container = new DashboardContainer(input, options); + + const contactCardEmbeddable = await container.addNewEmbeddable< + ContactCardEmbeddableInput, + ContactCardEmbeddableOutput, + ContactCardEmbeddable + >(CONTACT_CARD_EMBEDDABLE, { + firstName: 'Kibana', + }); + + if (isErrorEmbeddable(contactCardEmbeddable)) { + throw new Error('Failed to create embeddable'); + } else { + embeddable = contactCardEmbeddable; + } +}); + +test('Clone adds a new embeddable', async () => { + const dashboard = embeddable.getRoot() as IContainer; + const originalPanelCount = Object.keys(dashboard.getInput().panels).length; + const originalPanelKeySet = new Set(Object.keys(dashboard.getInput().panels)); + const action = new ClonePanelAction(coreStart); + await action.execute({ embeddable }); + expect(Object.keys(container.getInput().panels).length).toEqual(originalPanelCount + 1); + const newPanelId = Object.keys(container.getInput().panels).find( + key => !originalPanelKeySet.has(key) + ); + expect(newPanelId).toBeDefined(); + const newPanel = container.getInput().panels[newPanelId!]; + expect(newPanel.type).toEqual(embeddable.type); +}); + +test('Clones an embeddable without a saved object ID', async () => { + const dashboard = embeddable.getRoot() as IContainer; + const panel = dashboard.getInput().panels[embeddable.id] as DashboardPanelState; + const action = new ClonePanelAction(coreStart); + // @ts-ignore + const newPanel = await action.cloneEmbeddable(panel, embeddable.type); + expect(newPanel.type).toEqual(embeddable.type); +}); + +test('Clones an embeddable with a saved object ID', async () => { + const dashboard = embeddable.getRoot() as IContainer; + const panel = dashboard.getInput().panels[embeddable.id] as DashboardPanelState; + panel.explicitInput.savedObjectId = 'holySavedObjectBatman'; + const action = new ClonePanelAction(coreStart); + // @ts-ignore + const newPanel = await action.cloneEmbeddable(panel, embeddable.type); + expect(coreStart.savedObjects.client.get).toHaveBeenCalledTimes(1); + expect(coreStart.savedObjects.client.find).toHaveBeenCalledTimes(1); + expect(coreStart.savedObjects.client.create).toHaveBeenCalledTimes(1); + expect(newPanel.type).toEqual(embeddable.type); +}); + +test('Gets a unique title ', async () => { + coreStart.savedObjects.client.find = jest.fn().mockImplementation(({ search }) => { + if (search === '"testFirstTitle"') return { total: 1 }; + else if (search === '"testSecondTitle"') return { total: 41 }; + else if (search === '"testThirdTitle"') return { total: 90 }; + }); + const action = new ClonePanelAction(coreStart); + // @ts-ignore + expect(await action.getUniqueTitle('testFirstTitle', embeddable.type)).toEqual( + 'testFirstTitle (copy)' + ); + // @ts-ignore + expect(await action.getUniqueTitle('testSecondTitle (copy 39)', embeddable.type)).toEqual( + 'testSecondTitle (copy 40)' + ); + // @ts-ignore + expect(await action.getUniqueTitle('testSecondTitle (copy 20)', embeddable.type)).toEqual( + 'testSecondTitle (copy 40)' + ); + // @ts-ignore + expect(await action.getUniqueTitle('testThirdTitle', embeddable.type)).toEqual( + 'testThirdTitle (copy 89)' + ); + // @ts-ignore + expect(await action.getUniqueTitle('testThirdTitle (copy 10000)', embeddable.type)).toEqual( + 'testThirdTitle (copy 89)' + ); +}); diff --git a/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx b/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx new file mode 100644 index 0000000000000..4d15e7e899fa8 --- /dev/null +++ b/src/plugins/dashboard/public/application/actions/clone_panel_action.tsx @@ -0,0 +1,158 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { i18n } from '@kbn/i18n'; +import { CoreStart } from 'src/core/public'; +import uuid from 'uuid'; +import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin'; +import { ViewMode, PanelState, IEmbeddable } from '../../embeddable_plugin'; +import { SavedObject } from '../../../../saved_objects/public'; +import { PanelNotFoundError, EmbeddableInput } from '../../../../embeddable/public'; +import { + placePanelBeside, + IPanelPlacementBesideArgs, +} from '../embeddable/panel/dashboard_panel_placement'; +import { DashboardPanelState, DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '..'; + +export const ACTION_CLONE_PANEL = 'clonePanel'; + +export interface ClonePanelActionContext { + embeddable: IEmbeddable; +} + +export class ClonePanelAction implements ActionByType { + public readonly type = ACTION_CLONE_PANEL; + public readonly id = ACTION_CLONE_PANEL; + public order = 11; + + constructor(private core: CoreStart) {} + + public getDisplayName({ embeddable }: ClonePanelActionContext) { + if (!embeddable.getRoot() || !embeddable.getRoot().isContainer) { + throw new IncompatibleActionError(); + } + return i18n.translate('dashboard.panel.clonePanel', { + defaultMessage: 'Clone panel', + }); + } + + public getIconType({ embeddable }: ClonePanelActionContext) { + if (!embeddable.getRoot() || !embeddable.getRoot().isContainer) { + throw new IncompatibleActionError(); + } + return 'copy'; + } + + public async isCompatible({ embeddable }: ClonePanelActionContext) { + return Boolean( + embeddable.getInput()?.viewMode !== ViewMode.VIEW && + embeddable.getRoot() && + embeddable.getRoot().isContainer && + embeddable.getRoot().type === DASHBOARD_CONTAINER_TYPE + ); + } + + public async execute({ embeddable }: ClonePanelActionContext) { + if (!embeddable.getRoot() || !embeddable.getRoot().isContainer) { + throw new IncompatibleActionError(); + } + + const dashboard = embeddable.getRoot() as DashboardContainer; + const panelToClone = dashboard.getInput().panels[embeddable.id] as DashboardPanelState; + if (!panelToClone) { + throw new PanelNotFoundError(); + } + + dashboard.showPlaceholderUntil( + this.cloneEmbeddable(panelToClone, embeddable.type), + placePanelBeside, + { + width: panelToClone.gridData.w, + height: panelToClone.gridData.h, + currentPanels: dashboard.getInput().panels, + placeBesideId: panelToClone.explicitInput.id, + } as IPanelPlacementBesideArgs + ); + } + + private async getUniqueTitle(rawTitle: string, embeddableType: string): Promise { + const clonedTag = i18n.translate('dashboard.panel.title.clonedTag', { + defaultMessage: 'copy', + }); + const cloneRegex = new RegExp(`\\(${clonedTag}\\)`, 'g'); + const cloneNumberRegex = new RegExp(`\\(${clonedTag} [0-9]+\\)`, 'g'); + const baseTitle = rawTitle + .replace(cloneNumberRegex, '') + .replace(cloneRegex, '') + .trim(); + + const similarSavedObjects = await this.core.savedObjects.client.find({ + type: embeddableType, + perPage: 0, + fields: ['title'], + searchFields: ['title'], + search: `"${baseTitle}"`, + }); + const similarBaseTitlesCount: number = similarSavedObjects.total - 1; + + return similarBaseTitlesCount <= 0 + ? baseTitle + ` (${clonedTag})` + : baseTitle + ` (${clonedTag} ${similarBaseTitlesCount})`; + } + + private async cloneEmbeddable( + panelToClone: DashboardPanelState, + embeddableType: string + ): Promise> { + const panelState: PanelState = { + type: embeddableType, + explicitInput: { + ...panelToClone.explicitInput, + id: uuid.v4(), + }, + }; + let newTitle: string = ''; + if (panelToClone.explicitInput.savedObjectId) { + // Fetch existing saved object + const savedObjectToClone = await this.core.savedObjects.client.get( + embeddableType, + panelToClone.explicitInput.savedObjectId + ); + + // Clone the saved object + newTitle = await this.getUniqueTitle(savedObjectToClone.attributes.title, embeddableType); + const clonedSavedObject = await this.core.savedObjects.client.create( + embeddableType, + { + ..._.cloneDeep(savedObjectToClone.attributes), + title: newTitle, + }, + { references: _.cloneDeep(savedObjectToClone.references) } + ); + panelState.explicitInput.savedObjectId = clonedSavedObject.id; + } + this.core.notifications.toasts.addSuccess({ + title: i18n.translate('dashboard.panel.clonedToast', { + defaultMessage: 'Cloned panel', + }), + 'data-test-subj': 'addObjectToContainerSuccess', + }); + return panelState; + } +} diff --git a/src/plugins/dashboard/public/application/actions/index.ts b/src/plugins/dashboard/public/application/actions/index.ts index 23c26dbd280f8..d7a84fb79f6af 100644 --- a/src/plugins/dashboard/public/application/actions/index.ts +++ b/src/plugins/dashboard/public/application/actions/index.ts @@ -27,3 +27,8 @@ export { ReplacePanelActionContext, ACTION_REPLACE_PANEL, } from './replace_panel_action'; +export { + ClonePanelAction, + ClonePanelActionContext, + ACTION_CLONE_PANEL, +} from './clone_panel_action'; diff --git a/src/plugins/dashboard/public/application/dashboard_state_manager.ts b/src/plugins/dashboard/public/application/dashboard_state_manager.ts index 13ba3c6d0b60d..b03ea95069a3d 100644 --- a/src/plugins/dashboard/public/application/dashboard_state_manager.ts +++ b/src/plugins/dashboard/public/application/dashboard_state_manager.ts @@ -34,6 +34,7 @@ import { FilterUtils } from './lib/filter_utils'; import { DashboardAppState, DashboardAppStateDefaults, + DashboardAppStateInUrl, DashboardAppStateTransitions, SavedDashboardPanel, } from '../types'; @@ -165,11 +166,12 @@ export class DashboardStateManager { }); // setup state syncing utils. state container will be synced with url into `this.STATE_STORAGE_KEY` query param - this.stateSyncRef = syncState({ + this.stateSyncRef = syncState({ storageKey: this.STATE_STORAGE_KEY, stateContainer: { ...this.stateContainer, - set: (state: DashboardAppState | null) => { + get: () => this.toUrlState(this.stateContainer.get()), + set: (state: DashboardAppStateInUrl | null) => { // sync state required state container to be able to handle null // overriding set() so it could handle null coming from url if (state) { @@ -558,9 +560,9 @@ export class DashboardStateManager { */ private saveState({ replace }: { replace: boolean }): boolean { // schedules setting current state to url - this.kbnUrlStateStorage.set( + this.kbnUrlStateStorage.set( this.STATE_STORAGE_KEY, - this.stateContainer.get() + this.toUrlState(this.stateContainer.get()) ); // immediately forces scheduled updates and changes location return this.kbnUrlStateStorage.flush({ replace }); @@ -620,4 +622,13 @@ export class DashboardStateManager { const current = _.omit(this.stateContainer.get(), propsToIgnore); return !_.isEqual(initial, current); } + + private toUrlState(state: DashboardAppState): DashboardAppStateInUrl { + if (state.viewMode === ViewMode.VIEW) { + const { panels, ...stateWithoutPanels } = state; + return stateWithoutPanels; + } + + return state; + } } diff --git a/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx b/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx index 50089f1f061f4..8346fd900caef 100644 --- a/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx +++ b/src/plugins/dashboard/public/application/embeddable/dashboard_container.tsx @@ -23,6 +23,7 @@ import { I18nProvider } from '@kbn/i18n/react'; import { RefreshInterval, TimeRange, Query, Filter } from 'src/plugins/data/public'; import { CoreStart } from 'src/core/public'; import { Start as InspectorStartContract } from 'src/plugins/inspector/public'; +import uuid from 'uuid'; import { UiActionsStart } from '../../ui_actions_plugin'; import { Container, @@ -32,6 +33,7 @@ import { EmbeddableFactory, IEmbeddable, EmbeddableStart, + PanelState, } from '../../embeddable_plugin'; import { DASHBOARD_CONTAINER_TYPE } from './dashboard_constants'; import { createPanelState } from './panel'; @@ -42,6 +44,8 @@ import { KibanaReactContext, KibanaReactContextValue, } from '../../../../kibana_react/public'; +import { PLACEHOLDER_EMBEDDABLE } from './placeholder'; +import { PanelPlacementMethod, IPanelPlacementArgs } from './panel/dashboard_panel_placement'; export interface DashboardContainerInput extends ContainerInput { viewMode: ViewMode; @@ -120,7 +124,61 @@ export class DashboardContainer extends Container = {} ): DashboardPanelState { const panelState = super.createNewPanelState(factory, partial); - return createPanelState(panelState, Object.values(this.input.panels)); + return createPanelState(panelState, this.input.panels); + } + + public showPlaceholderUntil( + newStateComplete: Promise>, + placementMethod?: PanelPlacementMethod, + placementArgs?: TPlacementMethodArgs + ): void { + const originalPanelState = { + type: PLACEHOLDER_EMBEDDABLE, + explicitInput: { + id: uuid.v4(), + disabledActions: [ + 'ACTION_CUSTOMIZE_PANEL', + 'CUSTOM_TIME_RANGE', + 'clonePanel', + 'replacePanel', + 'togglePanel', + ], + }, + } as PanelState; + const placeholderPanelState = createPanelState( + originalPanelState, + this.input.panels, + placementMethod, + placementArgs + ); + this.updateInput({ + panels: { + ...this.input.panels, + [placeholderPanelState.explicitInput.id]: placeholderPanelState, + }, + }); + newStateComplete.then((newPanelState: Partial) => { + const finalPanels = { ...this.input.panels }; + delete finalPanels[placeholderPanelState.explicitInput.id]; + const newPanelId = newPanelState.explicitInput?.id + ? newPanelState.explicitInput.id + : uuid.v4(); + finalPanels[newPanelId] = { + ...placeholderPanelState, + ...newPanelState, + gridData: { + ...placeholderPanelState.gridData, + i: newPanelId, + }, + explicitInput: { + ...newPanelState.explicitInput, + id: newPanelId, + }, + }; + this.updateInput({ + panels: finalPanels, + }); + }); } public render(dom: HTMLElement) { diff --git a/src/plugins/dashboard/public/application/embeddable/panel/create_panel_state.test.ts b/src/plugins/dashboard/public/application/embeddable/panel/create_panel_state.test.ts index 409cae8b49a53..7c11ac8a5031b 100644 --- a/src/plugins/dashboard/public/application/embeddable/panel/create_panel_state.test.ts +++ b/src/plugins/dashboard/public/application/embeddable/panel/create_panel_state.test.ts @@ -26,7 +26,7 @@ import { CONTACT_CARD_EMBEDDABLE } from '../../../embeddable_plugin_test_samples interface TestInput extends EmbeddableInput { test: string; } -const panels: DashboardPanelState[] = []; +const panels: { [key: string]: DashboardPanelState } = {}; test('createPanelState adds a new panel state in 0,0 position', () => { const panelState = createPanelState( @@ -34,7 +34,7 @@ test('createPanelState adds a new panel state in 0,0 position', () => { type: CONTACT_CARD_EMBEDDABLE, explicitInput: { test: 'hi', id: '123' }, }, - [] + panels ); expect(panelState.explicitInput.test).toBe('hi'); expect(panelState.type).toBe(CONTACT_CARD_EMBEDDABLE); @@ -44,7 +44,7 @@ test('createPanelState adds a new panel state in 0,0 position', () => { expect(panelState.gridData.h).toBe(DEFAULT_PANEL_HEIGHT); expect(panelState.gridData.w).toBe(DEFAULT_PANEL_WIDTH); - panels.push(panelState); + panels[panelState.explicitInput.id] = panelState; }); test('createPanelState adds a second new panel state', () => { @@ -58,7 +58,7 @@ test('createPanelState adds a second new panel state', () => { expect(panelState.gridData.h).toBe(DEFAULT_PANEL_HEIGHT); expect(panelState.gridData.w).toBe(DEFAULT_PANEL_WIDTH); - panels.push(panelState); + panels[panelState.explicitInput.id] = panelState; }); test('createPanelState adds a third new panel state', () => { @@ -74,17 +74,17 @@ test('createPanelState adds a third new panel state', () => { expect(panelState.gridData.h).toBe(DEFAULT_PANEL_HEIGHT); expect(panelState.gridData.w).toBe(DEFAULT_PANEL_WIDTH); - panels.push(panelState); + panels[panelState.explicitInput.id] = panelState; }); test('createPanelState adds a new panel state in the top most position', () => { - const panelsWithEmptySpace = panels.filter(panel => panel.gridData.x === 0); + delete panels['456']; const panelState = createPanelState( { type: CONTACT_CARD_EMBEDDABLE, explicitInput: { test: 'bye', id: '987' }, }, - panelsWithEmptySpace + panels ); expect(panelState.gridData.x).toBe(DEFAULT_PANEL_WIDTH); expect(panelState.gridData.y).toBe(0); diff --git a/src/plugins/dashboard/public/application/embeddable/panel/create_panel_state.ts b/src/plugins/dashboard/public/application/embeddable/panel/create_panel_state.ts index f3a48368fe1b3..79116a57869d3 100644 --- a/src/plugins/dashboard/public/application/embeddable/panel/create_panel_state.ts +++ b/src/plugins/dashboard/public/application/embeddable/panel/create_panel_state.ts @@ -19,98 +19,45 @@ import _ from 'lodash'; import { PanelState, EmbeddableInput } from '../../../embeddable_plugin'; -import { - DASHBOARD_GRID_COLUMN_COUNT, - DEFAULT_PANEL_HEIGHT, - DEFAULT_PANEL_WIDTH, -} from '../dashboard_constants'; +import { DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_WIDTH } from '../dashboard_constants'; import { DashboardPanelState } from '../types'; - -// Look for the smallest y and x value where the default panel will fit. -function findTopLeftMostOpenSpace( - width: number, - height: number, - currentPanels: DashboardPanelState[] -) { - let maxY = -1; - - currentPanels.forEach(panel => { - maxY = Math.max(panel.gridData.y + panel.gridData.h, maxY); - }); - - // Handle case of empty grid. - if (maxY < 0) { - return { x: 0, y: 0 }; - } - - const grid = new Array(maxY); - for (let y = 0; y < maxY; y++) { - grid[y] = new Array(DASHBOARD_GRID_COLUMN_COUNT).fill(0); - } - - currentPanels.forEach(panel => { - for (let x = panel.gridData.x; x < panel.gridData.x + panel.gridData.w; x++) { - for (let y = panel.gridData.y; y < panel.gridData.y + panel.gridData.h; y++) { - const row = grid[y]; - if (row === undefined) { - throw new Error( - `Attempted to access a row that doesn't exist at ${y} for panel ${JSON.stringify( - panel - )}` - ); - } - grid[y][x] = 1; - } - } - }); - - for (let y = 0; y < maxY; y++) { - for (let x = 0; x < DASHBOARD_GRID_COLUMN_COUNT; x++) { - if (grid[y][x] === 1) { - // Space is filled - continue; - } else { - for (let h = y; h < Math.min(y + height, maxY); h++) { - for (let w = x; w < Math.min(x + width, DASHBOARD_GRID_COLUMN_COUNT); w++) { - const spaceIsEmpty = grid[h][w] === 0; - const fitsPanelWidth = w === x + width - 1; - // If the panel is taller than any other panel in the current grid, it can still fit in the space, hence - // we check the minimum of maxY and the panel height. - const fitsPanelHeight = h === Math.min(y + height - 1, maxY - 1); - - if (spaceIsEmpty && fitsPanelWidth && fitsPanelHeight) { - // Found space - return { x, y }; - } else if (grid[h][w] === 1) { - // x, y spot doesn't work, break. - break; - } - } - } - } - } - } - return { x: 0, y: maxY }; -} +import { + IPanelPlacementArgs, + findTopLeftMostOpenSpace, + PanelPlacementMethod, +} from './dashboard_panel_placement'; /** * Creates and initializes a basic panel state. */ -export function createPanelState( +export function createPanelState< + TEmbeddableInput extends EmbeddableInput, + TPlacementMethodArgs extends IPanelPlacementArgs = IPanelPlacementArgs +>( panelState: PanelState, - currentPanels: DashboardPanelState[] + currentPanels: { [key: string]: DashboardPanelState }, + placementMethod?: PanelPlacementMethod, + placementArgs?: TPlacementMethodArgs ): DashboardPanelState { - const { x, y } = findTopLeftMostOpenSpace( - DEFAULT_PANEL_WIDTH, - DEFAULT_PANEL_HEIGHT, - currentPanels - ); + const defaultPlacementArgs = { + width: DEFAULT_PANEL_WIDTH, + height: DEFAULT_PANEL_HEIGHT, + currentPanels, + }; + const finalPlacementArgs = placementArgs + ? { + ...defaultPlacementArgs, + ...placementArgs, + } + : defaultPlacementArgs; + + const gridDataLocation = placementMethod + ? placementMethod(finalPlacementArgs as TPlacementMethodArgs) + : findTopLeftMostOpenSpace(defaultPlacementArgs); + return { gridData: { - w: DEFAULT_PANEL_WIDTH, - h: DEFAULT_PANEL_HEIGHT, - x, - y, + ...gridDataLocation, i: panelState.explicitInput.id, }, ...panelState, diff --git a/src/plugins/dashboard/public/application/embeddable/panel/dashboard_panel_placement.ts b/src/plugins/dashboard/public/application/embeddable/panel/dashboard_panel_placement.ts new file mode 100644 index 0000000000000..70a6c83418587 --- /dev/null +++ b/src/plugins/dashboard/public/application/embeddable/panel/dashboard_panel_placement.ts @@ -0,0 +1,167 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { PanelNotFoundError } from '../../../embeddable_plugin'; +import { DashboardPanelState, GridData, DASHBOARD_GRID_COLUMN_COUNT } from '..'; + +export type PanelPlacementMethod = ( + args: PlacementArgs +) => Omit; + +export interface IPanelPlacementArgs { + width: number; + height: number; + currentPanels: { [key: string]: DashboardPanelState }; +} + +export interface IPanelPlacementBesideArgs extends IPanelPlacementArgs { + placeBesideId: string; +} + +// Look for the smallest y and x value where the default panel will fit. +export function findTopLeftMostOpenSpace({ + width, + height, + currentPanels, +}: IPanelPlacementArgs): Omit { + let maxY = -1; + + const currentPanelsArray = Object.values(currentPanels); + currentPanelsArray.forEach(panel => { + maxY = Math.max(panel.gridData.y + panel.gridData.h, maxY); + }); + + // Handle case of empty grid. + if (maxY < 0) { + return { x: 0, y: 0, w: width, h: height }; + } + + const grid = new Array(maxY); + for (let y = 0; y < maxY; y++) { + grid[y] = new Array(DASHBOARD_GRID_COLUMN_COUNT).fill(0); + } + + currentPanelsArray.forEach(panel => { + for (let x = panel.gridData.x; x < panel.gridData.x + panel.gridData.w; x++) { + for (let y = panel.gridData.y; y < panel.gridData.y + panel.gridData.h; y++) { + const row = grid[y]; + if (row === undefined) { + throw new Error( + `Attempted to access a row that doesn't exist at ${y} for panel ${JSON.stringify( + panel + )}` + ); + } + grid[y][x] = 1; + } + } + }); + + for (let y = 0; y < maxY; y++) { + for (let x = 0; x < DASHBOARD_GRID_COLUMN_COUNT; x++) { + if (grid[y][x] === 1) { + // Space is filled + continue; + } else { + for (let h = y; h < Math.min(y + height, maxY); h++) { + for (let w = x; w < Math.min(x + width, DASHBOARD_GRID_COLUMN_COUNT); w++) { + const spaceIsEmpty = grid[h][w] === 0; + const fitsPanelWidth = w === x + width - 1; + // If the panel is taller than any other panel in the current grid, it can still fit in the space, hence + // we check the minimum of maxY and the panel height. + const fitsPanelHeight = h === Math.min(y + height - 1, maxY - 1); + + if (spaceIsEmpty && fitsPanelWidth && fitsPanelHeight) { + // Found space + return { x, y, w: width, h: height }; + } else if (grid[h][w] === 1) { + // x, y spot doesn't work, break. + break; + } + } + } + } + } + } + return { x: 0, y: maxY, w: width, h: height }; +} + +interface IplacementDirection { + grid: Omit; + fits: boolean; +} + +export function placePanelBeside({ + width, + height, + currentPanels, + placeBesideId, +}: IPanelPlacementBesideArgs): Omit { + // const clonedPanels = _.cloneDeep(currentPanels); + if (!placeBesideId) { + throw new Error('Place beside method called without placeBesideId'); + } + const panelToPlaceBeside = currentPanels[placeBesideId]; + if (!panelToPlaceBeside) { + throw new PanelNotFoundError(); + } + const beside = panelToPlaceBeside.gridData; + const otherPanels: GridData[] = []; + _.forOwn(currentPanels, (panel: DashboardPanelState, key: string | undefined) => { + otherPanels.push(panel.gridData); + }); + + const possiblePlacementDirections: IplacementDirection[] = [ + { grid: { x: beside.x + beside.w, y: beside.y, w: width, h: height }, fits: true }, // right + { grid: { x: beside.x - width, y: beside.y, w: width, h: height }, fits: true }, // left + { grid: { x: beside.x, y: beside.y + beside.h, w: width, h: height }, fits: true }, // bottom + ]; + + for (const direction of possiblePlacementDirections) { + if ( + direction.grid.x >= 0 && + direction.grid.x + direction.grid.w <= DASHBOARD_GRID_COLUMN_COUNT && + direction.grid.y >= 0 + ) { + const intersection = otherPanels.some((currentPanelGrid: GridData) => { + return ( + direction.grid.x + direction.grid.w > currentPanelGrid.x && + direction.grid.x < currentPanelGrid.x + currentPanelGrid.w && + direction.grid.y < currentPanelGrid.y + currentPanelGrid.h && + direction.grid.y + direction.grid.h > currentPanelGrid.y + ); + }); + if (!intersection) { + return direction.grid; + } + } else { + direction.fits = false; + } + } + // if we get here that means there is no blank space around the panel we are placing beside. This means it's time to mess up the dashboard's groove. Fun! + const [, , bottomPlacement] = possiblePlacementDirections; + for (const currentPanelGrid of otherPanels) { + if (bottomPlacement.grid.y <= currentPanelGrid.y) { + const movedPanel = _.cloneDeep(currentPanels[currentPanelGrid.i]); + movedPanel.gridData.y = movedPanel.gridData.y + bottomPlacement.grid.h; + currentPanels[currentPanelGrid.i] = movedPanel; + } + } + return bottomPlacement.grid; +} diff --git a/src/plugins/dashboard/public/application/embeddable/placeholder/index.ts b/src/plugins/dashboard/public/application/embeddable/placeholder/index.ts new file mode 100644 index 0000000000000..7c65d50ce3fea --- /dev/null +++ b/src/plugins/dashboard/public/application/embeddable/placeholder/index.ts @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export * from './placeholder_embeddable'; +export * from './placeholder_embeddable_factory'; diff --git a/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable.tsx b/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable.tsx new file mode 100644 index 0000000000000..1a5c3386bdeda --- /dev/null +++ b/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable.tsx @@ -0,0 +1,52 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import { EuiLoadingChart } from '@elastic/eui'; +import classNames from 'classnames'; +import { Embeddable, EmbeddableInput, IContainer } from '../../../embeddable_plugin'; + +export const PLACEHOLDER_EMBEDDABLE = 'placeholder'; + +export class PlaceholderEmbeddable extends Embeddable { + public readonly type = PLACEHOLDER_EMBEDDABLE; + private node?: HTMLElement; + + constructor(initialInput: EmbeddableInput, parent?: IContainer) { + super(initialInput, {}, parent); + this.input = initialInput; + } + public render(node: HTMLElement) { + if (this.node) { + ReactDOM.unmountComponentAtNode(this.node); + } + this.node = node; + + const classes = classNames('embPanel', 'embPanel-isLoading'); + ReactDOM.render( +

+ +
, + node + ); + } + + public reload() {} +} diff --git a/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable_factory.ts b/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable_factory.ts new file mode 100644 index 0000000000000..30a93989649a7 --- /dev/null +++ b/src/plugins/dashboard/public/application/embeddable/placeholder/placeholder_embeddable_factory.ts @@ -0,0 +1,45 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { i18n } from '@kbn/i18n'; + +import { + EmbeddableFactoryDefinition, + EmbeddableInput, + IContainer, +} from '../../../embeddable_plugin'; +import { PlaceholderEmbeddable, PLACEHOLDER_EMBEDDABLE } from './placeholder_embeddable'; + +export class PlaceholderEmbeddableFactory implements EmbeddableFactoryDefinition { + public readonly type = PLACEHOLDER_EMBEDDABLE; + + public async isEditable() { + return false; + } + + public async create(initialInput: EmbeddableInput, parent?: IContainer) { + return new PlaceholderEmbeddable(initialInput, parent); + } + + public getDisplayName() { + return i18n.translate('dashboard.placeholder.factory.displayName', { + defaultMessage: 'placeholder', + }); + } +} diff --git a/src/plugins/dashboard/public/plugin.tsx b/src/plugins/dashboard/public/plugin.tsx index 322d734d9f39f..203c784d9df4e 100644 --- a/src/plugins/dashboard/public/plugin.tsx +++ b/src/plugins/dashboard/public/plugin.tsx @@ -67,9 +67,12 @@ import { ExpandPanelActionContext, ReplacePanelAction, ReplacePanelActionContext, + ClonePanelAction, + ClonePanelActionContext, ACTION_EXPAND_PANEL, ACTION_REPLACE_PANEL, RenderDeps, + ACTION_CLONE_PANEL, } from './application'; import { DashboardAppLinkGeneratorState, @@ -78,6 +81,7 @@ import { } from './url_generator'; import { createSavedDashboardLoader } from './saved_dashboards'; import { DashboardConstants } from './dashboard_constants'; +import { PlaceholderEmbeddableFactory } from './application/embeddable/placeholder'; declare module '../../share/public' { export interface UrlGeneratorStateMapping { @@ -115,6 +119,7 @@ declare module '../../../plugins/ui_actions/public' { export interface ActionContextMapping { [ACTION_EXPAND_PANEL]: ExpandPanelActionContext; [ACTION_REPLACE_PANEL]: ReplacePanelActionContext; + [ACTION_CLONE_PANEL]: ClonePanelActionContext; } } @@ -173,6 +178,9 @@ export class DashboardPlugin const factory = new DashboardContainerFactory(getStartServices); embeddable.registerEmbeddableFactory(factory.type, factory); + const placeholderFactory = new PlaceholderEmbeddableFactory(); + embeddable.registerEmbeddableFactory(placeholderFactory.type, placeholderFactory); + const { appMounted, appUnMounted, stop: stopUrlTracker } = createKbnUrlTracker({ baseUrl: core.http.basePath.prepend('/app/kibana'), defaultSubUrl: `#${DashboardConstants.LANDING_PAGE_PATH}`, @@ -297,6 +305,11 @@ export class DashboardPlugin ); uiActions.registerAction(changeViewAction); uiActions.attachAction(CONTEXT_MENU_TRIGGER, changeViewAction); + + const clonePanelAction = new ClonePanelAction(core); + uiActions.registerAction(clonePanelAction); + uiActions.attachAction(CONTEXT_MENU_TRIGGER, clonePanelAction); + const savedDashboardLoader = createSavedDashboardLoader({ savedObjectsClient: core.savedObjects.client, indexPatterns, diff --git a/src/plugins/dashboard/public/types.ts b/src/plugins/dashboard/public/types.ts index 7bccd3de6eca8..d96d2cdf75626 100644 --- a/src/plugins/dashboard/public/types.ts +++ b/src/plugins/dashboard/public/types.ts @@ -152,6 +152,14 @@ export type DashboardAppStateDefaults = DashboardAppState & { description?: string; }; +/** + * In URL panels are optional, + * Panels are not added to the URL when in "view" mode + */ +export type DashboardAppStateInUrl = Omit & { + panels?: SavedDashboardPanel[]; +}; + export interface DashboardAppStateTransitions { set: ( state: DashboardAppState diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index 06a46065baa84..05a4141483587 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -293,6 +293,7 @@ import { convertIPRangeToString, intervalOptions, // only used in Discover isDateHistogramBucketAggConfig, + isNumberType, isStringType, isType, parentPipelineType, @@ -363,7 +364,6 @@ export { SearchRequest, SearchResponse, SearchError, - SearchStrategyProvider, ISearchSource, SearchSource, createSearchSource, @@ -393,6 +393,7 @@ export const search = { InvalidEsCalendarIntervalError, InvalidEsIntervalFormatError, isDateHistogramBucketAggConfig, + isNumberType, isStringType, isType, isValidEsInterval, diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 6e06d063e7ebe..6383f61864146 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -1545,8 +1545,9 @@ export const search: { InvalidEsCalendarIntervalError: typeof InvalidEsCalendarIntervalError; InvalidEsIntervalFormatError: typeof InvalidEsIntervalFormatError; isDateHistogramBucketAggConfig: typeof isDateHistogramBucketAggConfig; + isNumberType: (agg: import("./search").AggConfig) => boolean; isStringType: (agg: import("./search").AggConfig) => boolean; - isType: (type: string) => (agg: import("./search").AggConfig) => boolean; + isType: (...types: string[]) => (agg: import("./search").AggConfig) => boolean; isValidEsInterval: typeof isValidEsInterval; isValidInterval: typeof isValidInterval; parentPipelineType: string; @@ -1724,21 +1725,6 @@ export interface SearchSourceFields { version?: boolean; } -// Warning: (ae-missing-release-tag) "SearchStrategyProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface SearchStrategyProvider { - // (undocumented) - id: string; - // (undocumented) - isViable: (indexPattern: IndexPattern) => boolean; - // Warning: (ae-forgotten-export) The symbol "SearchStrategySearchParams" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "SearchStrategyResponse" needs to be exported by the entry point index.d.ts - // - // (undocumented) - search: (params: SearchStrategySearchParams) => SearchStrategyResponse; -} - // Warning: (ae-missing-release-tag) "SortDirection" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -1899,11 +1885,11 @@ export type TSearchStrategyProvider = (context: ISearc // src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:402:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:406:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:406:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:407:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:414:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:33:33 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:37:1 - (ae-forgotten-export) The symbol "QueryStateChange" needs to be exported by the entry point index.d.ts // src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromEvent" needs to be exported by the entry point index.d.ts diff --git a/src/plugins/data/public/search/aggs/buckets/migrate_include_exclude_format.ts b/src/plugins/data/public/search/aggs/buckets/migrate_include_exclude_format.ts index 0beeb1c372275..116f8cfad60f6 100644 --- a/src/plugins/data/public/search/aggs/buckets/migrate_include_exclude_format.ts +++ b/src/plugins/data/public/search/aggs/buckets/migrate_include_exclude_format.ts @@ -21,20 +21,22 @@ import { isString, isObject } from 'lodash'; import { IBucketAggConfig, BucketAggType, BucketAggParam } from './bucket_agg_type'; import { IAggConfig } from '../agg_config'; -export const isType = (type: string) => { +export const isType = (...types: string[]) => { return (agg: IAggConfig): boolean => { const field = agg.params.field; - return field && field.type === type; + return types.some(type => field && field.type === type); }; }; +export const isNumberType = isType('number'); export const isStringType = isType('string'); +export const isStringOrNumberType = isType('string', 'number'); export const migrateIncludeExcludeFormat = { serialize(this: BucketAggParam, value: any, agg: IBucketAggConfig) { if (this.shouldShow && !this.shouldShow(agg)) return; - if (!value || isString(value)) return value; + if (!value || isString(value) || Array.isArray(value)) return value; else return value.pattern; }, write( @@ -44,7 +46,12 @@ export const migrateIncludeExcludeFormat = { ) { const value = aggConfig.getParam(this.name); - if (isObject(value)) { + if (Array.isArray(value) && value.length > 0 && isNumberType(aggConfig)) { + const parsedValue = value.filter((val): val is number => Number.isFinite(val)); + if (parsedValue.length) { + output.params[this.name] = parsedValue; + } + } else if (isObject(value)) { output.params[this.name] = value.pattern; } else if (value && isStringType(aggConfig)) { output.params[this.name] = value; diff --git a/src/plugins/data/public/search/aggs/buckets/terms.test.ts b/src/plugins/data/public/search/aggs/buckets/terms.test.ts index 0dc052bd1fdf6..9769efb6da749 100644 --- a/src/plugins/data/public/search/aggs/buckets/terms.test.ts +++ b/src/plugins/data/public/search/aggs/buckets/terms.test.ts @@ -75,5 +75,65 @@ describe('Terms Agg', () => { expect(params.include).toBe('404'); expect(params.exclude).toBe('400'); }); + + test('accepts string from string field type and writes this value', () => { + const aggConfigs = getAggConfigs({ + include: 'include value', + exclude: 'exclude value', + field: { + name: 'string_field', + type: 'string', + }, + orderAgg: { + type: 'count', + }, + }); + + const { [BUCKET_TYPES.TERMS]: params } = aggConfigs.aggs[0].toDsl(); + + expect(params.field).toBe('string_field'); + expect(params.include).toBe('include value'); + expect(params.exclude).toBe('exclude value'); + }); + + test('accepts empty array from number field type and does not write a value', () => { + const aggConfigs = getAggConfigs({ + include: [], + exclude: [], + field: { + name: 'empty_number_field', + type: 'number', + }, + orderAgg: { + type: 'count', + }, + }); + + const { [BUCKET_TYPES.TERMS]: params } = aggConfigs.aggs[0].toDsl(); + + expect(params.field).toBe('empty_number_field'); + expect(params.include).toBe(undefined); + expect(params.exclude).toBe(undefined); + }); + + test('filters array with empty strings from number field type and writes only numbers', () => { + const aggConfigs = getAggConfigs({ + include: [1.1, 2, '', 3.33, ''], + exclude: ['', 4, 5.555, '', 6], + field: { + name: 'number_field', + type: 'number', + }, + orderAgg: { + type: 'count', + }, + }); + + const { [BUCKET_TYPES.TERMS]: params } = aggConfigs.aggs[0].toDsl(); + + expect(params.field).toBe('number_field'); + expect(params.include).toStrictEqual([1.1, 2, 3.33]); + expect(params.exclude).toStrictEqual([4, 5.555, 6]); + }); }); }); diff --git a/src/plugins/data/public/search/aggs/buckets/terms.ts b/src/plugins/data/public/search/aggs/buckets/terms.ts index 5baa38af0e8d6..698e0dfb1d340 100644 --- a/src/plugins/data/public/search/aggs/buckets/terms.ts +++ b/src/plugins/data/public/search/aggs/buckets/terms.ts @@ -22,7 +22,10 @@ import { i18n } from '@kbn/i18n'; import { BucketAggType, IBucketAggConfig } from './bucket_agg_type'; import { BUCKET_TYPES } from './bucket_agg_types'; import { createFilterTerms } from './create_filter/terms'; -import { isStringType, migrateIncludeExcludeFormat } from './migrate_include_exclude_format'; +import { + isStringOrNumberType, + migrateIncludeExcludeFormat, +} from './migrate_include_exclude_format'; import { IAggConfigs } from '../agg_configs'; import { Adapters } from '../../../../../inspector/public'; @@ -266,7 +269,7 @@ export const getTermsBucketAgg = ({ getInternalStartServices }: TermsBucketAggDe }), type: 'string', advanced: true, - shouldShow: isStringType, + shouldShow: isStringOrNumberType, ...migrateIncludeExcludeFormat, }, { @@ -276,7 +279,7 @@ export const getTermsBucketAgg = ({ getInternalStartServices }: TermsBucketAggDe }), type: 'string', advanced: true, - shouldShow: isStringType, + shouldShow: isStringOrNumberType, ...migrateIncludeExcludeFormat, }, ], diff --git a/src/plugins/data/public/search/aggs/test_helpers/mock_data_services.ts b/src/plugins/data/public/search/aggs/test_helpers/mock_data_services.ts index d1d591771743c..e807e084c683a 100644 --- a/src/plugins/data/public/search/aggs/test_helpers/mock_data_services.ts +++ b/src/plugins/data/public/search/aggs/test_helpers/mock_data_services.ts @@ -18,8 +18,8 @@ */ // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { coreMock } from '../../../../../../../src/core/public/mocks'; -import { dataPluginMock } from '../../../../public/mocks'; +import { coreMock } from '../../../../../../core/public/mocks'; +import { dataPluginMock } from '../../../mocks'; import { setFieldFormats, setIndexPatterns, @@ -29,7 +29,7 @@ import { setQueryService, setSearchService, setUiSettings, -} from '../../../../public/services'; +} from '../../../services'; /** * Testing helper which calls all of the service setters used in the @@ -49,4 +49,9 @@ export function mockDataServices() { setQueryService(data.query); setSearchService(data.search); setUiSettings(core.uiSettings); + + return { + core, + data, + }; } diff --git a/src/plugins/data/public/search/fetch/get_search_params.test.ts b/src/plugins/data/public/search/fetch/get_search_params.test.ts new file mode 100644 index 0000000000000..edf18405e8ff7 --- /dev/null +++ b/src/plugins/data/public/search/fetch/get_search_params.test.ts @@ -0,0 +1,70 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { getSearchParams } from './get_search_params'; +import { IUiSettingsClient } from 'kibana/public'; + +function getConfigStub(config: any = {}) { + return { + get: key => config[key], + } as IUiSettingsClient; +} + +describe('getSearchParams', () => { + test('includes rest_total_hits_as_int', () => { + const config = getConfigStub(); + const searchParams = getSearchParams(config); + expect(searchParams.rest_total_hits_as_int).toBe(true); + }); + + test('includes ignore_unavailable', () => { + const config = getConfigStub(); + const searchParams = getSearchParams(config); + expect(searchParams.ignore_unavailable).toBe(true); + }); + + test('includes ignore_throttled according to search:includeFrozen', () => { + let config = getConfigStub({ 'search:includeFrozen': true }); + let searchParams = getSearchParams(config); + expect(searchParams.ignore_throttled).toBe(false); + + config = getConfigStub({ 'search:includeFrozen': false }); + searchParams = getSearchParams(config); + expect(searchParams.ignore_throttled).toBe(true); + }); + + test('includes max_concurrent_shard_requests according to courier:maxConcurrentShardRequests', () => { + let config = getConfigStub({ 'courier:maxConcurrentShardRequests': 0 }); + let searchParams = getSearchParams(config); + expect(searchParams.max_concurrent_shard_requests).toBe(undefined); + + config = getConfigStub({ 'courier:maxConcurrentShardRequests': 5 }); + searchParams = getSearchParams(config); + expect(searchParams.max_concurrent_shard_requests).toBe(5); + }); + + test('includes timeout according to esShardTimeout if greater than 0', () => { + const config = getConfigStub(); + let searchParams = getSearchParams(config, 0); + expect(searchParams.timeout).toBe(undefined); + + searchParams = getSearchParams(config, 100); + expect(searchParams.timeout).toBe('100ms'); + }); +}); diff --git a/src/plugins/data/public/search/search_strategy/get_search_params.ts b/src/plugins/data/public/search/fetch/get_search_params.ts similarity index 81% rename from src/plugins/data/public/search/search_strategy/get_search_params.ts rename to src/plugins/data/public/search/fetch/get_search_params.ts index 9fb8f2c728c6f..f0c43bd2e74cd 100644 --- a/src/plugins/data/public/search/search_strategy/get_search_params.ts +++ b/src/plugins/data/public/search/fetch/get_search_params.ts @@ -17,18 +17,10 @@ * under the License. */ -import { IUiSettingsClient } from '../../../../../core/public'; +import { IUiSettingsClient } from 'kibana/public'; const sessionId = Date.now(); -export function getMSearchParams(config: IUiSettingsClient) { - return { - rest_total_hits_as_int: true, - ignore_throttled: getIgnoreThrottled(config), - max_concurrent_shard_requests: getMaxConcurrentShardRequests(config), - }; -} - export function getSearchParams(config: IUiSettingsClient, esShardTimeout: number = 0) { return { rest_total_hits_as_int: true, @@ -40,11 +32,11 @@ export function getSearchParams(config: IUiSettingsClient, esShardTimeout: numbe }; } -function getIgnoreThrottled(config: IUiSettingsClient) { +export function getIgnoreThrottled(config: IUiSettingsClient) { return !config.get('search:includeFrozen'); } -function getMaxConcurrentShardRequests(config: IUiSettingsClient) { +export function getMaxConcurrentShardRequests(config: IUiSettingsClient) { const maxConcurrentShardRequests = config.get('courier:maxConcurrentShardRequests'); return maxConcurrentShardRequests > 0 ? maxConcurrentShardRequests : undefined; } diff --git a/src/plugins/data/public/search/fetch/index.ts b/src/plugins/data/public/search/fetch/index.ts index 8a80b716add32..39845ec31bfaa 100644 --- a/src/plugins/data/public/search/fetch/index.ts +++ b/src/plugins/data/public/search/fetch/index.ts @@ -18,5 +18,14 @@ */ export * from './types'; -export { fetchSoon } from './fetch_soon'; -export { RequestFailure } from './errors'; +export { + getSearchParams, + getPreference, + getTimeout, + getIgnoreThrottled, + getMaxConcurrentShardRequests, +} from './get_search_params'; + +export { SearchError, getSearchErrorType } from './search_error'; +export { RequestFailure } from './request_error'; +export { handleResponse } from './handle_response'; diff --git a/src/plugins/data/public/search/fetch/errors.ts b/src/plugins/data/public/search/fetch/request_error.ts similarity index 100% rename from src/plugins/data/public/search/fetch/errors.ts rename to src/plugins/data/public/search/fetch/request_error.ts diff --git a/src/plugins/data/public/search/search_strategy/search_error.ts b/src/plugins/data/public/search/fetch/search_error.ts similarity index 100% rename from src/plugins/data/public/search/search_strategy/search_error.ts rename to src/plugins/data/public/search/fetch/search_error.ts diff --git a/src/plugins/data/public/search/fetch/types.ts b/src/plugins/data/public/search/fetch/types.ts index e8de0576b8a72..475b2abbc019f 100644 --- a/src/plugins/data/public/search/fetch/types.ts +++ b/src/plugins/data/public/search/fetch/types.ts @@ -20,6 +20,9 @@ import { IUiSettingsClient } from '../../../../../core/public'; import { ISearchStart } from '../types'; +export type SearchRequest = any; +export type SearchResponse = any; + export interface FetchOptions { abortSignal?: AbortSignal; searchStrategyId?: string; diff --git a/src/plugins/data/public/search/index.ts b/src/plugins/data/public/search/index.ts index cce973d632f41..75c0eb8b6f022 100644 --- a/src/plugins/data/public/search/index.ts +++ b/src/plugins/data/public/search/index.ts @@ -44,9 +44,13 @@ export { esSearchStrategyProvider, getEsPreference } from './es_search'; export { IKibanaSearchResponse, IKibanaSearchRequest } from '../../common/search'; -export { LegacyApiCaller, SearchRequest, SearchResponse } from './es_client'; - -export { SearchError, SearchStrategyProvider, getSearchErrorType } from './search_strategy'; +export { + SearchError, + FetchOptions, + SearchRequest, + SearchResponse, + getSearchErrorType, +} from './fetch'; export { ISearchSource, @@ -59,5 +63,3 @@ export { export { SearchInterceptor } from './search_interceptor'; export { RequestTimeoutError } from './request_timeout_error'; - -export { FetchOptions } from './fetch'; diff --git a/src/plugins/data/public/search/fetch/call_client.test.ts b/src/plugins/data/public/search/legacy/call_client.test.ts similarity index 91% rename from src/plugins/data/public/search/fetch/call_client.test.ts rename to src/plugins/data/public/search/legacy/call_client.test.ts index 7a99b7c064515..f919187d46784 100644 --- a/src/plugins/data/public/search/fetch/call_client.test.ts +++ b/src/plugins/data/public/search/legacy/call_client.test.ts @@ -18,16 +18,17 @@ */ import { callClient } from './call_client'; -import { handleResponse } from './handle_response'; -import { FetchHandlers } from './types'; -import { SearchStrategySearchParams, defaultSearchStrategy } from '../search_strategy'; +import { SearchStrategySearchParams } from './types'; +import { defaultSearchStrategy } from './default_search_strategy'; +import { FetchHandlers } from '../fetch'; +import { handleResponse } from '../fetch/handle_response'; const mockAbortFn = jest.fn(); -jest.mock('./handle_response', () => ({ +jest.mock('../fetch/handle_response', () => ({ handleResponse: jest.fn((request, response) => response), })); -jest.mock('../search_strategy', () => { +jest.mock('./default_search_strategy', () => { return { defaultSearchStrategy: { search: jest.fn(({ searchRequests }: SearchStrategySearchParams) => { diff --git a/src/plugins/data/public/search/fetch/call_client.ts b/src/plugins/data/public/search/legacy/call_client.ts similarity index 89% rename from src/plugins/data/public/search/fetch/call_client.ts rename to src/plugins/data/public/search/legacy/call_client.ts index b3c4c682fa60c..c484c46aa4879 100644 --- a/src/plugins/data/public/search/fetch/call_client.ts +++ b/src/plugins/data/public/search/legacy/call_client.ts @@ -17,10 +17,9 @@ * under the License. */ -import { handleResponse } from './handle_response'; -import { FetchOptions, FetchHandlers } from './types'; -import { defaultSearchStrategy } from '../search_strategy'; -import { SearchRequest } from '..'; +import { FetchOptions, FetchHandlers, handleResponse } from '../fetch'; +import { defaultSearchStrategy } from './default_search_strategy'; +import { SearchRequest } from '../index'; export function callClient( searchRequests: SearchRequest[], diff --git a/src/plugins/data/public/search/search_strategy/default_search_strategy.test.ts b/src/plugins/data/public/search/legacy/default_search_strategy.test.ts similarity index 83% rename from src/plugins/data/public/search/search_strategy/default_search_strategy.test.ts rename to src/plugins/data/public/search/legacy/default_search_strategy.test.ts index 210a0e5fd1ac7..835b02b3cd5c7 100644 --- a/src/plugins/data/public/search/search_strategy/default_search_strategy.test.ts +++ b/src/plugins/data/public/search/legacy/default_search_strategy.test.ts @@ -17,10 +17,10 @@ * under the License. */ -import { IUiSettingsClient } from '../../../../../core/public'; -import { SearchStrategySearchParams } from './types'; +import { IUiSettingsClient } from 'kibana/public'; import { defaultSearchStrategy } from './default_search_strategy'; import { searchStartMock } from '../mocks'; +import { SearchStrategySearchParams } from './types'; const { search } = defaultSearchStrategy; @@ -38,12 +38,6 @@ const searchMockResponse: any = Promise.resolve([]); searchMockResponse.abort = jest.fn(); const searchMock = jest.fn().mockReturnValue(searchMockResponse); -const newSearchMockResponse: any = Promise.resolve([]); -newSearchMockResponse.abort = jest.fn(); -const newSearchMock = jest.fn().mockReturnValue({ - toPromise: () => searchMockResponse, -}); - describe('defaultSearchStrategy', function() { describe('search', function() { let searchArgs: MockedKeys>; @@ -58,7 +52,6 @@ describe('defaultSearchStrategy', function() { const searchService = searchStartMock; searchService.aggs.calculateAutoTimeExpression = jest.fn().mockReturnValue('1d'); - searchService.search = newSearchMock; searchService.__LEGACY.esClient.search = searchMock; searchService.__LEGACY.esClient.msearch = msearchMock; @@ -112,18 +105,5 @@ describe('defaultSearchStrategy', function() { search({ ...searchArgs, config }).abort(); expect(msearchMockResponse.abort).toHaveBeenCalled(); }); - - test('should call new search service', () => { - const config = getConfigStub(); - search({ ...searchArgs, config }); - expect(newSearchMock).toHaveBeenCalledTimes(1); - }); - - test('should properly abort with new search service', async () => { - const abortSpy = jest.spyOn(AbortController.prototype, 'abort'); - const config = getConfigStub({}); - search({ ...searchArgs, config }).abort(); - expect(abortSpy).toHaveBeenCalled(); - }); }); }); diff --git a/src/plugins/data/public/search/search_strategy/default_search_strategy.ts b/src/plugins/data/public/search/legacy/default_search_strategy.ts similarity index 64% rename from src/plugins/data/public/search/search_strategy/default_search_strategy.ts rename to src/plugins/data/public/search/legacy/default_search_strategy.ts index 2bd88f51587a8..1552410f9090c 100644 --- a/src/plugins/data/public/search/search_strategy/default_search_strategy.ts +++ b/src/plugins/data/public/search/legacy/default_search_strategy.ts @@ -17,23 +17,19 @@ * under the License. */ +import { getPreference, getTimeout } from '../fetch'; +import { getMSearchParams } from './get_msearch_params'; import { SearchStrategyProvider, SearchStrategySearchParams } from './types'; -import { isDefault } from '../../index_patterns'; -import { getSearchParams, getMSearchParams, getPreference, getTimeout } from './get_search_params'; +// @deprecated export const defaultSearchStrategy: SearchStrategyProvider = { id: 'default', search: params => { - return params.config.get('courier:batchSearches') ? msearch(params) : search(params); - }, - - isViable: indexPattern => { - return indexPattern && isDefault(indexPattern); + return msearch(params); }, }; -// @deprecated function msearch({ searchRequests, searchService, @@ -65,29 +61,3 @@ function msearch({ abort: searching.abort, }; } - -function search({ - searchRequests, - searchService, - config, - esShardTimeout, -}: SearchStrategySearchParams) { - const abortController = new AbortController(); - const searchParams = getSearchParams(config, esShardTimeout); - const promises = searchRequests.map(({ index, indexType, body }) => { - const params = { - index: index.title || index, - body, - ...searchParams, - }; - const { signal } = abortController; - return searchService - .search({ params, indexType }, { signal }) - .toPromise() - .then(({ rawResponse }) => rawResponse); - }); - return { - searching: Promise.all(promises), - abort: () => abortController.abort(), - }; -} diff --git a/src/plugins/data/public/search/es_client/get_es_client.ts b/src/plugins/data/public/search/legacy/es_client/get_es_client.ts similarity index 100% rename from src/plugins/data/public/search/es_client/get_es_client.ts rename to src/plugins/data/public/search/legacy/es_client/get_es_client.ts diff --git a/src/plugins/data/public/search/es_client/index.ts b/src/plugins/data/public/search/legacy/es_client/index.ts similarity index 91% rename from src/plugins/data/public/search/es_client/index.ts rename to src/plugins/data/public/search/legacy/es_client/index.ts index b1e0ce3116824..78ac83af642d8 100644 --- a/src/plugins/data/public/search/es_client/index.ts +++ b/src/plugins/data/public/search/legacy/es_client/index.ts @@ -18,4 +18,4 @@ */ export { getEsClient } from './get_es_client'; -export { SearchRequest, SearchResponse, LegacyApiCaller } from './types'; +export { LegacyApiCaller } from './types'; diff --git a/src/plugins/data/public/search/es_client/types.ts b/src/plugins/data/public/search/legacy/es_client/types.ts similarity index 94% rename from src/plugins/data/public/search/es_client/types.ts rename to src/plugins/data/public/search/legacy/es_client/types.ts index 3ca0513a14238..7a56b9b0cb00a 100644 --- a/src/plugins/data/public/search/es_client/types.ts +++ b/src/plugins/data/public/search/legacy/es_client/types.ts @@ -17,8 +17,7 @@ * under the License. */ -export type SearchRequest = any; -export type SearchResponse = any; +import { SearchRequest, SearchResponse } from '../../fetch'; export interface LegacyApiCaller { search: (searchRequest: SearchRequest) => LegacyApiCallerResponse; diff --git a/src/plugins/data/public/search/fetch/fetch_soon.test.ts b/src/plugins/data/public/search/legacy/fetch_soon.test.ts similarity index 96% rename from src/plugins/data/public/search/fetch/fetch_soon.test.ts rename to src/plugins/data/public/search/legacy/fetch_soon.test.ts index a8d593c8501f6..b2e17798ccc9f 100644 --- a/src/plugins/data/public/search/fetch/fetch_soon.test.ts +++ b/src/plugins/data/public/search/legacy/fetch_soon.test.ts @@ -19,9 +19,9 @@ import { fetchSoon } from './fetch_soon'; import { callClient } from './call_client'; -import { IUiSettingsClient } from '../../../../../core/public'; -import { FetchHandlers, FetchOptions } from './types'; -import { SearchRequest, SearchResponse } from '..'; +import { IUiSettingsClient } from 'kibana/public'; +import { FetchHandlers, FetchOptions } from '../fetch/types'; +import { SearchRequest, SearchResponse } from '../index'; function getConfigStub(config: any = {}) { return { diff --git a/src/plugins/data/public/search/fetch/fetch_soon.ts b/src/plugins/data/public/search/legacy/fetch_soon.ts similarity index 95% rename from src/plugins/data/public/search/fetch/fetch_soon.ts rename to src/plugins/data/public/search/legacy/fetch_soon.ts index b1405747426ee..18fa410a5bef0 100644 --- a/src/plugins/data/public/search/fetch/fetch_soon.ts +++ b/src/plugins/data/public/search/legacy/fetch_soon.ts @@ -18,8 +18,8 @@ */ import { callClient } from './call_client'; -import { FetchHandlers, FetchOptions } from './types'; -import { SearchRequest, SearchResponse } from '..'; +import { FetchHandlers, FetchOptions } from '../fetch/types'; +import { SearchRequest, SearchResponse } from '../index'; /** * This function introduces a slight delay in the request process to allow multiple requests to queue diff --git a/src/plugins/data/public/search/search_strategy/get_search_params.test.ts b/src/plugins/data/public/search/legacy/get_msearch_params.test.ts similarity index 60% rename from src/plugins/data/public/search/search_strategy/get_search_params.test.ts rename to src/plugins/data/public/search/legacy/get_msearch_params.test.ts index 76f3105d7f942..9f16d5b408178 100644 --- a/src/plugins/data/public/search/search_strategy/get_search_params.test.ts +++ b/src/plugins/data/public/search/legacy/get_msearch_params.test.ts @@ -17,7 +17,7 @@ * under the License. */ -import { getMSearchParams, getSearchParams } from './get_search_params'; +import { getMSearchParams } from './get_msearch_params'; import { IUiSettingsClient } from '../../../../../core/public'; function getConfigStub(config: any = {}) { @@ -64,46 +64,3 @@ describe('getMSearchParams', () => { expect(msearchParams.hasOwnProperty('timeout')).toBe(false); }); }); - -describe('getSearchParams', () => { - test('includes rest_total_hits_as_int', () => { - const config = getConfigStub(); - const searchParams = getSearchParams(config); - expect(searchParams.rest_total_hits_as_int).toBe(true); - }); - - test('includes ignore_unavailable', () => { - const config = getConfigStub(); - const searchParams = getSearchParams(config); - expect(searchParams.ignore_unavailable).toBe(true); - }); - - test('includes ignore_throttled according to search:includeFrozen', () => { - let config = getConfigStub({ 'search:includeFrozen': true }); - let searchParams = getSearchParams(config); - expect(searchParams.ignore_throttled).toBe(false); - - config = getConfigStub({ 'search:includeFrozen': false }); - searchParams = getSearchParams(config); - expect(searchParams.ignore_throttled).toBe(true); - }); - - test('includes max_concurrent_shard_requests according to courier:maxConcurrentShardRequests', () => { - let config = getConfigStub({ 'courier:maxConcurrentShardRequests': 0 }); - let searchParams = getSearchParams(config); - expect(searchParams.max_concurrent_shard_requests).toBe(undefined); - - config = getConfigStub({ 'courier:maxConcurrentShardRequests': 5 }); - searchParams = getSearchParams(config); - expect(searchParams.max_concurrent_shard_requests).toBe(5); - }); - - test('includes timeout according to esShardTimeout if greater than 0', () => { - const config = getConfigStub(); - let searchParams = getSearchParams(config, 0); - expect(searchParams.timeout).toBe(undefined); - - searchParams = getSearchParams(config, 100); - expect(searchParams.timeout).toBe('100ms'); - }); -}); diff --git a/src/plugins/data/public/search/legacy/get_msearch_params.ts b/src/plugins/data/public/search/legacy/get_msearch_params.ts new file mode 100644 index 0000000000000..48d13903c972f --- /dev/null +++ b/src/plugins/data/public/search/legacy/get_msearch_params.ts @@ -0,0 +1,29 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { IUiSettingsClient } from 'kibana/public'; +import { getIgnoreThrottled, getMaxConcurrentShardRequests } from '../fetch'; + +export function getMSearchParams(config: IUiSettingsClient) { + return { + rest_total_hits_as_int: true, + ignore_throttled: getIgnoreThrottled(config), + max_concurrent_shard_requests: getMaxConcurrentShardRequests(config), + }; +} diff --git a/src/plugins/data/public/search/legacy/index.ts b/src/plugins/data/public/search/legacy/index.ts new file mode 100644 index 0000000000000..e2ae72824f3f4 --- /dev/null +++ b/src/plugins/data/public/search/legacy/index.ts @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { fetchSoon } from './fetch_soon'; +export { getEsClient, LegacyApiCaller } from './es_client'; diff --git a/src/plugins/data/public/search/search_strategy/types.ts b/src/plugins/data/public/search/legacy/types.ts similarity index 89% rename from src/plugins/data/public/search/search_strategy/types.ts rename to src/plugins/data/public/search/legacy/types.ts index 764370d8ff649..3812cec7a2aa2 100644 --- a/src/plugins/data/public/search/search_strategy/types.ts +++ b/src/plugins/data/public/search/legacy/types.ts @@ -17,21 +17,20 @@ * under the License. */ -import { IndexPattern } from '../..'; -import { FetchHandlers } from '../fetch/types'; +import { FetchHandlers } from '../fetch'; import { SearchRequest, SearchResponse } from '..'; +export interface SearchStrategySearchParams extends FetchHandlers { + searchRequests: SearchRequest[]; +} + +// @deprecated export interface SearchStrategyProvider { id: string; search: (params: SearchStrategySearchParams) => SearchStrategyResponse; - isViable: (indexPattern: IndexPattern) => boolean; } export interface SearchStrategyResponse { searching: Promise; abort: () => void; } - -export interface SearchStrategySearchParams extends FetchHandlers { - searchRequests: SearchRequest[]; -} diff --git a/src/plugins/data/public/search/search_service.ts b/src/plugins/data/public/search/search_service.ts index a539736991adb..916278a96659b 100644 --- a/src/plugins/data/public/search/search_service.ts +++ b/src/plugins/data/public/search/search_service.ts @@ -22,12 +22,12 @@ import { Plugin, CoreSetup, CoreStart, PackageInfo } from '../../../../core/publ import { SYNC_SEARCH_STRATEGY, syncSearchStrategyProvider } from './sync_search_strategy'; import { ISearchSetup, ISearchStart, TSearchStrategyProvider, TSearchStrategiesMap } from './types'; import { TStrategyTypes } from './strategy_types'; -import { getEsClient, LegacyApiCaller } from './es_client'; +import { getEsClient, LegacyApiCaller } from './legacy'; import { ES_SEARCH_STRATEGY, DEFAULT_SEARCH_STRATEGY } from '../../common/search'; -import { esSearchStrategyProvider } from './es_search/es_search_strategy'; +import { esSearchStrategyProvider } from './es_search'; import { IndexPatternsContract } from '../index_patterns/index_patterns'; import { createSearchSource } from './search_source'; -import { QuerySetup } from '../query/query_service'; +import { QuerySetup } from '../query'; import { GetInternalStartServicesFn } from '../types'; import { SearchInterceptor } from './search_interceptor'; import { diff --git a/src/plugins/data/public/search/search_source/search_source.test.ts b/src/plugins/data/public/search/search_source/search_source.test.ts index 6bad093d31402..6e878844664ad 100644 --- a/src/plugins/data/public/search/search_source/search_source.test.ts +++ b/src/plugins/data/public/search/search_source/search_source.test.ts @@ -20,8 +20,26 @@ import { SearchSource } from './search_source'; import { IndexPattern, SortDirection } from '../..'; import { mockDataServices } from '../aggs/test_helpers'; +import { setSearchService } from '../../services'; +import { searchStartMock } from '../mocks'; +import { fetchSoon } from '../legacy'; +import { CoreStart } from 'kibana/public'; +import { Observable } from 'rxjs'; -jest.mock('../fetch', () => ({ +// Setup search service mock +searchStartMock.search = jest.fn(() => { + return new Observable(subscriber => { + setTimeout(() => { + subscriber.next({ + rawResponse: '', + }); + subscriber.complete(); + }, 100); + }); +}) as any; +setSearchService(searchStartMock); + +jest.mock('../legacy', () => ({ fetchSoon: jest.fn().mockResolvedValue({}), })); @@ -44,8 +62,11 @@ const indexPattern2 = ({ } as unknown) as IndexPattern; describe('SearchSource', function() { + let uiSettingsMock: jest.Mocked; beforeEach(() => { - mockDataServices(); + const { core } = mockDataServices(); + uiSettingsMock = core.uiSettings; + jest.clearAllMocks(); }); describe('#setField()', function() { @@ -151,6 +172,36 @@ describe('SearchSource', function() { }); }); + describe('#legacy fetch()', () => { + beforeEach(() => { + uiSettingsMock.get.mockImplementation(() => { + return true; // batchSearches = true + }); + }); + + afterEach(() => { + uiSettingsMock.get.mockImplementation(() => { + return false; // batchSearches = false + }); + }); + + it('should call msearch', async () => { + const searchSource = new SearchSource({ index: indexPattern }); + const options = {}; + await searchSource.fetch(options); + expect(fetchSoon).toBeCalledTimes(1); + }); + }); + + describe('#search service fetch()', () => { + it('should call msearch', async () => { + const searchSource = new SearchSource({ index: indexPattern }); + const options = {}; + await searchSource.fetch(options); + expect(searchStartMock.search).toBeCalledTimes(1); + }); + }); + describe('#serialize', function() { it('should reference index patterns', () => { const indexPattern123 = { id: '123' } as IndexPattern; diff --git a/src/plugins/data/public/search/search_source/search_source.ts b/src/plugins/data/public/search/search_source/search_source.ts index c70db7bb82ef7..9d2bb889953cf 100644 --- a/src/plugins/data/public/search/search_source/search_source.ts +++ b/src/plugins/data/public/search/search_source/search_source.ts @@ -70,17 +70,19 @@ */ import _ from 'lodash'; +import { map } from 'rxjs/operators'; import { SavedObjectReference } from 'kibana/public'; import { normalizeSortRequest } from './normalize_sort_request'; import { filterDocvalueFields } from './filter_docvalue_fields'; import { fieldWildcardFilter } from '../../../../kibana_utils/public'; import { IIndexPattern, SearchRequest } from '../..'; import { SearchSourceOptions, SearchSourceFields } from './types'; -import { fetchSoon, FetchOptions, RequestFailure } from '../fetch'; +import { FetchOptions, RequestFailure, getSearchParams, handleResponse } from '../fetch'; import { getSearchService, getUiSettings, getInjectedMetadata } from '../../services'; import { getEsQueryConfig, buildEsQuery, Filter } from '../../../common'; import { getHighlightRequest } from '../../../common/field_formats'; +import { fetchSoon } from '../legacy'; export type ISearchSource = Pick; @@ -185,18 +187,29 @@ export class SearchSource { } /** - * Fetch this source and reject the returned Promise on error - * - * @async + * Run a search using the search service + * @return {Observable>} */ - async fetch(options: FetchOptions = {}) { - await this.requestIsStarting(options); - - const searchRequest = await this.flatten(); - this.history = [searchRequest]; + private fetch$(searchRequest: SearchRequest, signal?: AbortSignal) { + const esShardTimeout = getInjectedMetadata().getInjectedVar('esShardTimeout') as number; + const searchParams = getSearchParams(getUiSettings(), esShardTimeout); + const params = { + index: searchRequest.index.title || searchRequest.index, + body: searchRequest.body, + ...searchParams, + }; + return getSearchService() + .search({ params, indexType: searchRequest.indexType }, { signal }) + .pipe(map(({ rawResponse }) => handleResponse(searchRequest, rawResponse))); + } + /** + * Run a search using the search service + * @return {Promise>} + */ + private async legacyFetch(searchRequest: SearchRequest, options: FetchOptions) { const esShardTimeout = getInjectedMetadata().getInjectedVar('esShardTimeout') as number; - const response = await fetchSoon( + return await fetchSoon( searchRequest, { ...(this.searchStrategyId && { searchStrategyId: this.searchStrategyId }), @@ -208,6 +221,24 @@ export class SearchSource { esShardTimeout, } ); + } + /** + * Fetch this source and reject the returned Promise on error + * + * @async + */ + async fetch(options: FetchOptions = {}) { + await this.requestIsStarting(options); + + const searchRequest = await this.flatten(); + this.history = [searchRequest]; + + let response; + if (getUiSettings().get('courier:batchSearches')) { + response = await this.legacyFetch(searchRequest, options); + } else { + response = this.fetch$(searchRequest, options.abortSignal).toPromise(); + } if (response.error) { throw new RequestFailure(null, response); @@ -246,7 +277,6 @@ export class SearchSource { /** * Called by requests of this search source when they are started - * @param {Courier.Request} request * @param options * @return {Promise} */ @@ -430,7 +460,6 @@ export class SearchSource { * and `kibanaSavedObjectMeta.searchSourceJSON.filter[].meta.index`. * * Using `createSearchSource`, the instance can be re-created. - * @param searchSource The search source to serialize * @public */ public serialize() { const references: SavedObjectReference[] = []; diff --git a/src/plugins/data/public/search/search_strategy/no_op_search_strategy.ts b/src/plugins/data/public/search/search_strategy/no_op_search_strategy.ts deleted file mode 100644 index dc7331e614a0e..0000000000000 --- a/src/plugins/data/public/search/search_strategy/no_op_search_strategy.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { i18n } from '@kbn/i18n'; -import { SearchError } from './search_error'; -import { SearchStrategyProvider } from './types'; - -export const noOpSearchStrategy: SearchStrategyProvider = { - id: 'noOp', - - search: () => { - const searchError = new SearchError({ - status: '418', // "I'm a teapot" error - title: i18n.translate( - 'data.search.searchSource.noSearchStrategyRegisteredErrorMessageTitle', - { - defaultMessage: 'No search strategy registered', - } - ), - message: i18n.translate( - 'data.search.searchSource.noSearchStrategyRegisteredErrorMessageDescription', - { - defaultMessage: `Couldn't find a search strategy for the search request`, - } - ), - type: 'NO_OP_SEARCH_STRATEGY', - path: '', - }); - - return { - searching: Promise.reject(searchError), - abort: () => {}, - }; - }, - - isViable: () => { - return true; - }, -}; diff --git a/src/plugins/data/public/search/types.ts b/src/plugins/data/public/search/types.ts index ba6e44f47b75e..2122e4e82ec1d 100644 --- a/src/plugins/data/public/search/types.ts +++ b/src/plugins/data/public/search/types.ts @@ -22,7 +22,7 @@ import { createSearchSource } from './search_source'; import { SearchAggsSetup, SearchAggsStart, SearchAggsStartLegacy } from './aggs'; import { ISearch, ISearchGeneric } from './i_search'; import { TStrategyTypes } from './strategy_types'; -import { LegacyApiCaller } from './es_client'; +import { LegacyApiCaller } from './legacy/es_client'; import { SearchInterceptor } from './search_interceptor'; export interface ISearchContext { @@ -38,15 +38,6 @@ export interface ISearchStrategy { search: ISearch; } -/** - * Search strategy provider creates an instance of a search strategy with the request - * handler context bound to it. This way every search strategy can use - * whatever information they require from the request context. - */ -export type TSearchStrategyProviderEnhanced = ( - search: ISearchGeneric -) => Promise>; - export type TSearchStrategiesMap = { [K in TStrategyTypes]?: TSearchStrategyProvider; }; diff --git a/src/plugins/data/server/saved_objects/index_patterns.ts b/src/plugins/data/server/saved_objects/index_patterns.ts index 9838071eee5a4..497dbb7d6f630 100644 --- a/src/plugins/data/server/saved_objects/index_patterns.ts +++ b/src/plugins/data/server/saved_objects/index_patterns.ts @@ -23,7 +23,7 @@ import { indexPatternSavedObjectTypeMigrations } from './index_pattern_migration export const indexPatternSavedObjectType: SavedObjectsType = { name: 'index-pattern', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'indexPatternApp', defaultSearchField: 'title', diff --git a/src/plugins/data/server/saved_objects/query.ts b/src/plugins/data/server/saved_objects/query.ts index ff0a6cfde8113..015cc7c6cb134 100644 --- a/src/plugins/data/server/saved_objects/query.ts +++ b/src/plugins/data/server/saved_objects/query.ts @@ -22,7 +22,7 @@ import { SavedObjectsType } from 'kibana/server'; export const querySavedObjectType: SavedObjectsType = { name: 'query', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'search', defaultSearchField: 'title', diff --git a/src/plugins/data/server/saved_objects/search.ts b/src/plugins/data/server/saved_objects/search.ts index 8b30ff7d08201..54de35a90ae02 100644 --- a/src/plugins/data/server/saved_objects/search.ts +++ b/src/plugins/data/server/saved_objects/search.ts @@ -23,7 +23,7 @@ import { searchSavedObjectTypeMigrations } from './search_migrations'; export const searchSavedObjectType: SavedObjectsType = { name: 'search', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'discoverApp', defaultSearchField: 'title', diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/authorization_provider.tsx b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/authorization_provider.tsx new file mode 100644 index 0000000000000..68f1cf2045efb --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/authorization_provider.tsx @@ -0,0 +1,73 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { HttpSetup } from 'kibana/public'; +import React, { createContext, useContext } from 'react'; + +import { useRequest } from '../../../public'; + +import { Error as CustomError } from './section_error'; + +import { Privileges } from '../types'; + +interface Authorization { + isLoading: boolean; + apiError: CustomError | null; + privileges: Privileges; +} + +const initialValue: Authorization = { + isLoading: true, + apiError: null, + privileges: { + hasAllPrivileges: true, + missingPrivileges: {}, + }, +}; + +export const AuthorizationContext = createContext(initialValue); + +export const useAuthorizationContext = () => { + const ctx = useContext(AuthorizationContext); + if (!ctx) { + throw new Error('AuthorizationContext can only be used inside of AuthorizationProvider!'); + } + return ctx; +}; + +interface Props { + privilegesEndpoint: string; + children: React.ReactNode; + httpClient: HttpSetup; +} + +export const AuthorizationProvider = ({ privilegesEndpoint, httpClient, children }: Props) => { + const { isLoading, error, data: privilegesData } = useRequest(httpClient, { + path: privilegesEndpoint, + method: 'get', + }); + + const value = { + isLoading, + privileges: isLoading ? { hasAllPrivileges: true, missingPrivileges: {} } : privilegesData, + apiError: error ? error : null, + } as Authorization; + + return {children}; +}; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/index.ts new file mode 100644 index 0000000000000..71be3cc6152ca --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/index.ts @@ -0,0 +1,30 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { + AuthorizationProvider, + AuthorizationContext, + useAuthorizationContext, +} from './authorization_provider'; + +export { WithPrivileges } from './with_privileges'; + +export { NotAuthorizedSection } from './not_authorized_section'; + +export { Error, SectionError } from './section_error'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/not_authorized_section.tsx b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/not_authorized_section.tsx new file mode 100644 index 0000000000000..c35f674ef9ec4 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/not_authorized_section.tsx @@ -0,0 +1,30 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import { EuiEmptyPrompt } from '@elastic/eui'; + +interface Props { + title: React.ReactNode; + message: React.ReactNode | string; +} + +export const NotAuthorizedSection = ({ title, message }: Props) => ( + {title}} body={

{message}

} /> +); diff --git a/x-pack/plugins/snapshot_restore/public/application/components/section_error.tsx b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/section_error.tsx similarity index 54% rename from x-pack/plugins/snapshot_restore/public/application/components/section_error.tsx rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/section_error.tsx index bd9e48796779e..3d56309adae97 100644 --- a/x-pack/plugins/snapshot_restore/public/application/components/section_error.tsx +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/section_error.tsx @@ -1,7 +1,20 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ import { EuiCallOut, EuiSpacer } from '@elastic/eui'; diff --git a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/with_privileges.tsx b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/with_privileges.tsx similarity index 70% rename from x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/with_privileges.tsx rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/with_privileges.tsx index 223a2882c3cab..8f4b2b976d141 100644 --- a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/with_privileges.tsx +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/components/with_privileges.tsx @@ -1,13 +1,25 @@ /* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ -import { useContext } from 'react'; +import { MissingPrivileges } from '../types'; -import { MissingPrivileges } from '../../../../../common/types'; -import { AuthorizationContext } from './authorization_provider'; +import { useAuthorizationContext } from './authorization_provider'; interface Props { /** @@ -29,7 +41,7 @@ const toArray = (value: string | string[]): string[] => Array.isArray(value) ? (value as string[]) : ([value] as string[]); export const WithPrivileges = ({ privileges: requiredPrivileges, children }: Props) => { - const { isLoading, privileges } = useContext(AuthorizationContext); + const { isLoading, privileges } = useAuthorizationContext(); const privilegesToArray: Privilege[] = toArray(requiredPrivileges).map(p => { const [section, privilege] = p.split('.'); diff --git a/src/plugins/data/public/search/search_strategy/index.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/index.ts similarity index 77% rename from src/plugins/data/public/search/search_strategy/index.ts rename to src/plugins/es_ui_shared/__packages_do_not_import__/authorization/index.ts index e3de2ea46e3ec..ad89052b3bb54 100644 --- a/src/plugins/data/public/search/search_strategy/index.ts +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/index.ts @@ -17,8 +17,14 @@ * under the License. */ -export { SearchError, getSearchErrorType } from './search_error'; +export { + WithPrivileges, + NotAuthorizedSection, + AuthorizationProvider, + AuthorizationContext, + SectionError, + Error, + useAuthorizationContext, +} from './components'; -export { SearchStrategyProvider, SearchStrategySearchParams } from './types'; - -export { defaultSearchStrategy } from './default_search_strategy'; +export { Privileges, MissingPrivileges } from './types'; diff --git a/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/types.ts b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/types.ts new file mode 100644 index 0000000000000..cdc2052122688 --- /dev/null +++ b/src/plugins/es_ui_shared/__packages_do_not_import__/authorization/types.ts @@ -0,0 +1,27 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export interface MissingPrivileges { + [key: string]: string[] | undefined; +} + +export interface Privileges { + hasAllPrivileges: boolean; + missingPrivileges: MissingPrivileges; +} diff --git a/src/plugins/es_ui_shared/public/authorization/index.ts b/src/plugins/es_ui_shared/public/authorization/index.ts new file mode 100644 index 0000000000000..3a02c0d2694f3 --- /dev/null +++ b/src/plugins/es_ui_shared/public/authorization/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export * from '../../__packages_do_not_import__/authorization'; diff --git a/src/plugins/es_ui_shared/public/index.ts b/src/plugins/es_ui_shared/public/index.ts index a0371bf351193..7e5510d7c9c65 100644 --- a/src/plugins/es_ui_shared/public/index.ts +++ b/src/plugins/es_ui_shared/public/index.ts @@ -47,6 +47,18 @@ export { expandLiteralStrings, } from './console_lang'; +export { + AuthorizationContext, + AuthorizationProvider, + NotAuthorizedSection, + WithPrivileges, + Privileges, + MissingPrivileges, + SectionError, + Error, + useAuthorizationContext, +} from './authorization'; + /** dummy plugin, we just want esUiShared to have its own bundle */ export function plugin() { return new (class EsUiSharedPlugin { diff --git a/src/plugins/expressions/kibana.json b/src/plugins/expressions/kibana.json index cba693dd4bc20..5d2112103e94d 100644 --- a/src/plugins/expressions/kibana.json +++ b/src/plugins/expressions/kibana.json @@ -4,7 +4,6 @@ "server": true, "ui": true, "requiredPlugins": [ - "bfetch", - "inspector" + "bfetch" ] } diff --git a/src/plugins/expressions/public/loader.ts b/src/plugins/expressions/public/loader.ts index fbe2f37c648d6..418ff6fdf8614 100644 --- a/src/plugins/expressions/public/loader.ts +++ b/src/plugins/expressions/public/loader.ts @@ -19,13 +19,14 @@ import { BehaviorSubject, Observable, Subject } from 'rxjs'; import { filter, map } from 'rxjs/operators'; -import { Adapters, InspectorSession } from '../../inspector/public'; -import { ExpressionRenderHandler } from './render'; +import { Adapters } from '../../inspector/public'; import { IExpressionLoaderParams } from './types'; import { ExpressionAstExpression } from '../common'; -import { getInspector, getExpressionsService } from './services'; import { ExecutionContract } from '../common/execution/execution_contract'; +import { ExpressionRenderHandler } from './render'; +import { getExpressionsService } from './services'; + type Data = any; export class ExpressionLoader { @@ -120,15 +121,6 @@ export class ExpressionLoader { return this.renderHandler.getElement(); } - openInspector(title: string): InspectorSession | undefined { - const inspector = this.inspect(); - if (inspector) { - return getInspector().open(inspector, { - title, - }); - } - } - inspect(): Adapters | undefined { return this.execution ? (this.execution.inspect() as Adapters) : undefined; } diff --git a/src/plugins/expressions/public/mocks.tsx b/src/plugins/expressions/public/mocks.tsx index cb7089f814643..b8f2f693e9c77 100644 --- a/src/plugins/expressions/public/mocks.tsx +++ b/src/plugins/expressions/public/mocks.tsx @@ -22,7 +22,6 @@ import { ExpressionsSetup, ExpressionsStart, plugin as pluginInitializer } from /* eslint-disable */ import { coreMock } from '../../../core/public/mocks'; -import { inspectorPluginMock } from '../../inspector/public/mocks'; import { bfetchPluginMock } from '../../bfetch/public/mocks'; /* eslint-enable */ @@ -89,7 +88,6 @@ const createPlugin = async () => { const plugin = pluginInitializer(pluginInitializerContext); const setup = await plugin.setup(coreSetup, { bfetch: bfetchPluginMock.createSetupContract(), - inspector: inspectorPluginMock.createSetupContract(), }); return { @@ -101,7 +99,6 @@ const createPlugin = async () => { doStart: async () => await plugin.start(coreStart, { bfetch: bfetchPluginMock.createStartContract(), - inspector: inspectorPluginMock.createStartContract(), }), }; }; diff --git a/src/plugins/expressions/public/plugin.ts b/src/plugins/expressions/public/plugin.ts index 7c0de271b7706..720c3b701d504 100644 --- a/src/plugins/expressions/public/plugin.ts +++ b/src/plugins/expressions/public/plugin.ts @@ -29,11 +29,9 @@ import { ExpressionsServiceStart, ExecutionContext, } from '../common'; -import { Setup as InspectorSetup, Start as InspectorStart } from '../../inspector/public'; import { BfetchPublicSetup, BfetchPublicStart } from '../../bfetch/public'; import { setCoreStart, - setInspector, setInterpreter, setRenderersRegistry, setNotifications, @@ -45,12 +43,10 @@ import { render, ExpressionRenderHandler } from './render'; export interface ExpressionsSetupDeps { bfetch: BfetchPublicSetup; - inspector: InspectorSetup; } export interface ExpressionsStartDeps { bfetch: BfetchPublicStart; - inspector: InspectorStart; } export interface ExpressionsSetup extends ExpressionsServiceSetup { @@ -120,7 +116,7 @@ export class ExpressionsPublicPlugin }); } - public setup(core: CoreSetup, { inspector, bfetch }: ExpressionsSetupDeps): ExpressionsSetup { + public setup(core: CoreSetup, { bfetch }: ExpressionsSetupDeps): ExpressionsSetup { this.configureExecutor(core); const { expressions } = this; @@ -180,9 +176,8 @@ export class ExpressionsPublicPlugin return Object.freeze(setup); } - public start(core: CoreStart, { inspector, bfetch }: ExpressionsStartDeps): ExpressionsStart { + public start(core: CoreStart, { bfetch }: ExpressionsStartDeps): ExpressionsStart { setCoreStart(core); - setInspector(inspector); setNotifications(core.notifications); const { expressions } = this; diff --git a/src/plugins/expressions/public/react_expression_renderer.tsx b/src/plugins/expressions/public/react_expression_renderer.tsx index 242a49c6d6639..2c99f173c9f33 100644 --- a/src/plugins/expressions/public/react_expression_renderer.tsx +++ b/src/plugins/expressions/public/react_expression_renderer.tsx @@ -17,8 +17,7 @@ * under the License. */ -import { useRef, useEffect, useState, useLayoutEffect } from 'react'; -import React from 'react'; +import React, { useRef, useEffect, useState, useLayoutEffect } from 'react'; import classNames from 'classnames'; import { Subscription } from 'rxjs'; import { filter } from 'rxjs/operators'; diff --git a/src/plugins/expressions/public/render.ts b/src/plugins/expressions/public/render.ts index ad4d16bcd1323..4aaf0da60fc60 100644 --- a/src/plugins/expressions/public/render.ts +++ b/src/plugins/expressions/public/render.ts @@ -21,10 +21,11 @@ import * as Rx from 'rxjs'; import { Observable } from 'rxjs'; import { filter } from 'rxjs/operators'; import { RenderError, RenderErrorHandlerFnType, IExpressionLoaderParams } from './types'; -import { getRenderersRegistry } from './services'; import { renderErrorHandler as defaultRenderErrorHandler } from './render_error_handler'; import { IInterpreterRenderHandlers, ExpressionAstExpression } from '../common'; +import { getRenderersRegistry } from './services'; + export type IExpressionRendererExtraHandlers = Record; export interface ExpressionRenderHandlerParams { diff --git a/src/plugins/expressions/public/services.ts b/src/plugins/expressions/public/services.ts index a203e87414571..016456c956666 100644 --- a/src/plugins/expressions/public/services.ts +++ b/src/plugins/expressions/public/services.ts @@ -20,14 +20,11 @@ import { NotificationsStart } from 'kibana/public'; import { createKibanaUtilsCore, createGetterSetter } from '../../kibana_utils/public'; import { ExpressionInterpreter } from './types'; -import { Start as IInspector } from '../../inspector/public'; import { ExpressionsSetup } from './plugin'; import { ExpressionsService } from '../common'; export const { getCoreStart, setCoreStart } = createKibanaUtilsCore(); -export const [getInspector, setInspector] = createGetterSetter('Inspector'); - export const [getInterpreter, setInterpreter] = createGetterSetter( 'Interpreter' ); diff --git a/src/plugins/kibana_legacy/public/angular/angular_config.tsx b/src/plugins/kibana_legacy/public/angular/angular_config.tsx index 71cd57ef2d72e..295cf27688c80 100644 --- a/src/plugins/kibana_legacy/public/angular/angular_config.tsx +++ b/src/plugins/kibana_legacy/public/angular/angular_config.tsx @@ -92,9 +92,9 @@ export const configureAppAngularModule = ( ) => { const core = 'core' in newPlatform ? newPlatform.core : newPlatform; const packageInfo = - 'injectedMetadata' in newPlatform - ? newPlatform.injectedMetadata.getLegacyMetadata() - : newPlatform.env.packageInfo; + 'env' in newPlatform + ? newPlatform.env.packageInfo + : newPlatform.injectedMetadata.getLegacyMetadata(); if ('injectedMetadata' in newPlatform) { forOwn(newPlatform.injectedMetadata.getInjectedVars(), (val, name) => { diff --git a/src/plugins/kibana_legacy/public/mocks.ts b/src/plugins/kibana_legacy/public/mocks.ts index 8e9a05b186191..2fdd0d8b4be59 100644 --- a/src/plugins/kibana_legacy/public/mocks.ts +++ b/src/plugins/kibana_legacy/public/mocks.ts @@ -25,6 +25,7 @@ export type Start = jest.Mocked>; const createSetupContract = (): Setup => ({ forwardApp: jest.fn(), + registerLegacyAppAlias: jest.fn(), registerLegacyApp: jest.fn(), config: { defaultAppId: 'home', @@ -37,6 +38,7 @@ const createSetupContract = (): Setup => ({ const createStartContract = (): Start => ({ getApps: jest.fn(), + getLegacyAppAliases: jest.fn(), getForwards: jest.fn(), config: { defaultAppId: 'home', diff --git a/src/plugins/kibana_legacy/public/plugin.ts b/src/plugins/kibana_legacy/public/plugin.ts index 2ad620f355848..831fc3f0d4a71 100644 --- a/src/plugins/kibana_legacy/public/plugin.ts +++ b/src/plugins/kibana_legacy/public/plugin.ts @@ -28,12 +28,18 @@ import { Observable } from 'rxjs'; import { ConfigSchema } from '../config'; import { getDashboardConfig } from './dashboard_config'; -interface ForwardDefinition { +interface LegacyAppAliasDefinition { legacyAppId: string; newAppId: string; keepPrefix: boolean; } +interface ForwardDefinition { + legacyAppId: string; + newAppId: string; + rewritePath: (legacyPath: string) => string; +} + export type AngularRenderedAppUpdater = ( app: AppBase ) => Partial | undefined; @@ -54,7 +60,8 @@ export interface AngularRenderedApp extends App { export class KibanaLegacyPlugin { private apps: AngularRenderedApp[] = []; - private forwards: ForwardDefinition[] = []; + private legacyAppAliases: LegacyAppAliasDefinition[] = []; + private forwardDefinitions: ForwardDefinition[] = []; constructor(private readonly initializerContext: PluginInitializerContext) {} @@ -94,17 +101,55 @@ export class KibanaLegacyPlugin { * renaming or nesting plugins. For route changes after the prefix, please * use the routing mechanism of your app. * + * This method just redirects URLs within the legacy `kibana` app. + * * @param legacyAppId The name of the old app to forward URLs from * @param newAppId The name of the new app that handles the URLs now * @param options Whether the prefix of the old app is kept to nest the legacy * path into the new path */ - forwardApp: ( + registerLegacyAppAlias: ( legacyAppId: string, newAppId: string, options: { keepPrefix: boolean } = { keepPrefix: false } ) => { - this.forwards.push({ legacyAppId, newAppId, ...options }); + this.legacyAppAliases.push({ legacyAppId, newAppId, ...options }); + }, + + /** + * Forwards URLs within the legacy `kibana` app to a new platform application. + * + * @param legacyAppId The name of the old app to forward URLs from + * @param newAppId The name of the new app that handles the URLs now + * @param rewritePath Function to rewrite the legacy sub path of the app to the new path in the core app + * path into the new path + * + * Example usage: + * ``` + * kibanaLegacy.forwardApp( + * 'old', + * 'new', + * path => { + * const [, id] = /old/item\/(.*)$/.exec(path) || []; + * if (!id) { + * return '#/home'; + * } + * return '#/items/${id}'; + * } + * ); + * ``` + * This will cause the following redirects: + * + * * app/kibana#/old/ -> app/new#/home + * * app/kibana#/old/item/123 -> app/new#/items/123 + * + */ + forwardApp: ( + legacyAppId: string, + newAppId: string, + rewritePath: (legacyPath: string) => string + ) => { + this.forwardDefinitions.push({ legacyAppId, newAppId, rewritePath }); }, /** @@ -132,7 +177,12 @@ export class KibanaLegacyPlugin { * @deprecated * Just exported for wiring up with legacy platform, should not be used. */ - getForwards: () => this.forwards, + getLegacyAppAliases: () => this.legacyAppAliases, + /** + * @deprecated + * Just exported for wiring up with legacy platform, should not be used. + */ + getForwards: () => this.forwardDefinitions, config: this.initializerContext.config.get(), dashboardConfig: getDashboardConfig(!application.capabilities.dashboard.showWriteControls), }; diff --git a/src/plugins/kibana_react/public/index.ts b/src/plugins/kibana_react/public/index.ts index 9ad9f14ac5659..9bec91b859ab7 100644 --- a/src/plugins/kibana_react/public/index.ts +++ b/src/plugins/kibana_react/public/index.ts @@ -25,7 +25,7 @@ export * from './ui_settings'; export * from './field_icon'; export * from './table_list_view'; export * from './split_panel'; -export { ValidatedDualRange } from './validated_range'; +export { ValidatedDualRange, Value } from './validated_range'; export * from './notifications'; export { Markdown, MarkdownSimple } from './markdown'; export { reactToUiComponent, uiToReactComponent } from './adapters'; diff --git a/src/plugins/kibana_react/public/validated_range/index.ts b/src/plugins/kibana_react/public/validated_range/index.ts index bc643373f5e60..7d720ec842a43 100644 --- a/src/plugins/kibana_react/public/validated_range/index.ts +++ b/src/plugins/kibana_react/public/validated_range/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { ValidatedDualRange } from './validated_dual_range'; +export { ValidatedDualRange, Value } from './validated_dual_range'; diff --git a/src/plugins/kibana_utils/public/core/create_start_service_getter.test.ts b/src/plugins/kibana_utils/public/core/create_start_service_getter.test.ts new file mode 100644 index 0000000000000..9d9b21269e102 --- /dev/null +++ b/src/plugins/kibana_utils/public/core/create_start_service_getter.test.ts @@ -0,0 +1,78 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { StartServicesAccessor } from '../../../../core/public'; +import { createStartServicesGetter } from './create_start_service_getter'; +import { Defer } from '../../common/defer'; + +describe('createStartServicesGetter', () => { + test('throws if services are accessed before accessor resolves', async () => { + const future = new Defer(); + const accessor: StartServicesAccessor = async () => await future.promise; + const start = createStartServicesGetter(accessor); + + await new Promise(r => setTimeout(r, 1)); + + expect(() => start()).toThrowErrorMatchingInlineSnapshot( + `"Trying to access start services before start."` + ); + }); + + test('returns services after accessor resolves even if first time called before it resolved', async () => { + const future = new Defer(); + const core = {}; + const plugins = {}; + const self = {}; + const accessor: StartServicesAccessor = async () => await future.promise; + const start = createStartServicesGetter(accessor); + + await new Promise(r => setTimeout(r, 1)); + + expect(() => start()).toThrow(); + + await new Promise(r => setTimeout(r, 1)); + future.resolve([core, plugins, self]); + await future.promise; + + expect(start()).toEqual({ + core, + plugins, + self, + }); + }); + + test('returns services if called after accessor resolves', async () => { + const future = new Defer(); + const core = {}; + const plugins = {}; + const self = {}; + const accessor: StartServicesAccessor = async () => await future.promise; + const start = createStartServicesGetter(accessor); + + await new Promise(r => setTimeout(r, 1)); + future.resolve([core, plugins, self]); + await future.promise; + + expect(start()).toEqual({ + core, + plugins, + self, + }); + }); +}); diff --git a/src/plugins/kibana_utils/public/core/create_start_service_getter.ts b/src/plugins/kibana_utils/public/core/create_start_service_getter.ts new file mode 100644 index 0000000000000..5e385eb5ed473 --- /dev/null +++ b/src/plugins/kibana_utils/public/core/create_start_service_getter.ts @@ -0,0 +1,98 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { CoreStart, StartServicesAccessor } from '../../../../core/public'; + +export interface StartServices { + plugins: Plugins; + self: OwnContract; + core: CoreStart; +} + +export type StartServicesGetter = () => StartServices< + Plugins, + OwnContract +>; + +/** + * Use this utility to create a synchronous *start* service getter in *setup* + * life-cycle of your plugin. + * + * Below is a usage example in a Kibana plugin. + * + * ```ts + * export interface MyPluginStartDeps { + * data: DataPublicPluginStart; + * expressions: ExpressionsStart; + * inspector: InspectorStart; + * uiActions: UiActionsStart; + * } + * + * class MyPlugin implements Plugin { + * setup(core: CoreSetup, plugins) { + * const start = createStartServicesGetter(core.getStartServices); + * plugins.expressions.registerFunction(myExpressionFunction(start)); + * } + * + * start(core, plugins: MyPluginStartDeps) { + * + * } + * } + * ``` + * + * In `myExpressionFunction` you can make sure you are picking only the dependencies + * your function needs using the `Pick` type. + * + * ```ts + * const myExpressionFunction = + * (start: StartServicesGetter>) => { + * + * start().plugins.indexPatterns.something(123); + * } + * ``` + * + * @param accessor Asynchronous start service accessor provided by platform. + * @returns Returns a function which synchronously returns *start* core services + * and plugin contracts. If you call this function before the *start* life-cycle + * has started it will throw. + */ +export const createStartServicesGetter = ( + accessor: StartServicesAccessor +): StartServicesGetter => { + let services: StartServices | undefined; + + accessor().then( + ([core, plugins, self]) => { + services = { + core, + plugins, + self, + }; + }, + error => { + // eslint-disable-next-line no-console + console.error('Could not access start services.', error); + } + ); + + return () => { + if (!services) throw new Error('Trying to access start services before start.'); + return services; + }; +}; diff --git a/src/plugins/kibana_utils/public/core/index.ts b/src/plugins/kibana_utils/public/core/index.ts index 3f08d591300a2..8bbb2129071f5 100644 --- a/src/plugins/kibana_utils/public/core/index.ts +++ b/src/plugins/kibana_utils/public/core/index.ts @@ -18,3 +18,4 @@ */ export * from './create_kibana_utils_core'; +export * from './create_start_service_getter'; diff --git a/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.test.ts b/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.test.ts index 6e4c505c62ebc..513c70e60048a 100644 --- a/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.test.ts +++ b/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.test.ts @@ -31,6 +31,7 @@ import { setStateToKbnUrl, getStateFromKbnUrl, } from './kbn_url_storage'; +import { ScopedHistory } from '../../../../../core/public'; describe('kbn_url_storage', () => { describe('getStateFromUrl & setStateToUrl', () => { @@ -187,23 +188,54 @@ describe('kbn_url_storage', () => { urlControls.update('/', true); }); - const getCurrentUrl = () => window.location.href; + const getCurrentUrl = () => history.createHref(history.location); it('should flush async url updates', async () => { const pr1 = urlControls.updateAsync(() => '/1', false); const pr2 = urlControls.updateAsync(() => '/2', false); const pr3 = urlControls.updateAsync(() => '/3', false); - expect(getCurrentUrl()).toBe('http://localhost/'); - expect(urlControls.flush()).toBe('http://localhost/3'); - expect(getCurrentUrl()).toBe('http://localhost/3'); + expect(getCurrentUrl()).toBe('/'); + expect(urlControls.flush()).toBe('/3'); + expect(getCurrentUrl()).toBe('/3'); + await Promise.all([pr1, pr2, pr3]); + expect(getCurrentUrl()).toBe('/3'); + }); + + it('flush() should return undefined, if no url updates happened', () => { + expect(urlControls.flush()).toBeUndefined(); + urlControls.updateAsync(() => '/1', false); + urlControls.updateAsync(() => '/', false); + expect(urlControls.flush()).toBeUndefined(); + }); + }); + + describe('urlControls - scoped history integration', () => { + let history: History; + let urlControls: IKbnUrlControls; + beforeEach(() => { + const parentHistory = createBrowserHistory(); + parentHistory.replace('/app/kibana/'); + history = new ScopedHistory(parentHistory, '/app/kibana/'); + urlControls = createKbnUrlControls(history); + }); + + const getCurrentUrl = () => history.createHref(history.location); + + it('should flush async url updates', async () => { + const pr1 = urlControls.updateAsync(() => '/app/kibana/1', false); + const pr2 = urlControls.updateAsync(() => '/app/kibana/2', false); + const pr3 = urlControls.updateAsync(() => '/app/kibana/3', false); + expect(getCurrentUrl()).toBe('/app/kibana/'); + expect(urlControls.flush()).toBe('/app/kibana/3'); + expect(getCurrentUrl()).toBe('/app/kibana/3'); await Promise.all([pr1, pr2, pr3]); - expect(getCurrentUrl()).toBe('http://localhost/3'); + expect(getCurrentUrl()).toBe('/app/kibana/3'); }); it('flush() should return undefined, if no url updates happened', () => { expect(urlControls.flush()).toBeUndefined(); - urlControls.updateAsync(() => 'http://localhost/1', false); - urlControls.updateAsync(() => 'http://localhost/', false); + urlControls.updateAsync(() => '/app/kibana/1', false); + urlControls.updateAsync(() => '/app/kibana/', false); expect(urlControls.flush()).toBeUndefined(); }); }); diff --git a/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.ts b/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.ts index 40a411d425a54..337d122e2854b 100644 --- a/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.ts +++ b/src/plugins/kibana_utils/public/state_management/url/kbn_url_storage.ts @@ -154,7 +154,7 @@ export const createKbnUrlControls = ( let shouldReplace = true; function updateUrl(newUrl: string, replace = false): string | undefined { - const currentUrl = getCurrentUrl(); + const currentUrl = getCurrentUrl(history); if (newUrl === currentUrl) return undefined; // skip update const historyPath = getRelativeToHistoryPath(newUrl, history); @@ -165,7 +165,7 @@ export const createKbnUrlControls = ( history.push(historyPath); } - return getCurrentUrl(); + return getCurrentUrl(history); } // queue clean up @@ -187,7 +187,10 @@ export const createKbnUrlControls = ( function getPendingUrl() { if (updateQueue.length === 0) return undefined; - const resultUrl = updateQueue.reduce((url, nextUpdate) => nextUpdate(url), getCurrentUrl()); + const resultUrl = updateQueue.reduce( + (url, nextUpdate) => nextUpdate(url), + getCurrentUrl(history) + ); return resultUrl; } diff --git a/src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.ts b/src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.ts index af8811b1969e6..8adbbfb06e1ed 100644 --- a/src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.ts +++ b/src/plugins/kibana_utils/public/state_management/url/kbn_url_tracker.ts @@ -57,6 +57,7 @@ export function createKbnUrlTracker({ navLinkUpdater$, toastNotifications, history, + getHistory, storage, shouldTrackUrlUpdate = pathname => { const currentAppName = defaultSubUrl.slice(2); // cut hash and slash symbols @@ -103,6 +104,12 @@ export function createKbnUrlTracker({ * History object to use to track url changes. If this isn't provided, a local history instance will be created. */ history?: History; + + /** + * Lazily retrieve history instance + */ + getHistory?: () => History; + /** * Storage object to use to persist currently active url. If this isn't provided, the browser wide session storage instance will be used. */ @@ -158,7 +165,7 @@ export function createKbnUrlTracker({ function onMountApp() { unsubscribe(); - const historyInstance = history || createHashHistory(); + const historyInstance = history || (getHistory && getHistory()) || createHashHistory(); // track current hash when within app unsubscribeURLHistory = historyInstance.listen(location => { if (shouldTrackUrlUpdate(location.pathname)) { diff --git a/src/plugins/kibana_utils/public/state_management/url/parse.ts b/src/plugins/kibana_utils/public/state_management/url/parse.ts index 95041d0662f56..6339002ea5c68 100644 --- a/src/plugins/kibana_utils/public/state_management/url/parse.ts +++ b/src/plugins/kibana_utils/public/state_management/url/parse.ts @@ -18,12 +18,11 @@ */ import { parse as _parseUrl } from 'url'; +import { History } from 'history'; export const parseUrl = (url: string) => _parseUrl(url, true); export const parseUrlHash = (url: string) => { const hash = parseUrl(url).hash; return hash ? parseUrl(hash.slice(1)) : null; }; -export const getCurrentUrl = () => window.location.href; -export const parseCurrentUrl = () => parseUrl(getCurrentUrl()); -export const parseCurrentUrlHash = () => parseUrlHash(getCurrentUrl()); +export const getCurrentUrl = (history: History) => history.createHref(history.location); diff --git a/src/plugins/kibana_utils/public/state_sync/state_sync_state_storage/create_kbn_url_state_storage.test.ts b/src/plugins/kibana_utils/public/state_sync/state_sync_state_storage/create_kbn_url_state_storage.test.ts index cc3f1df7c1e00..8a9a4ea71ee9a 100644 --- a/src/plugins/kibana_utils/public/state_sync/state_sync_state_storage/create_kbn_url_state_storage.test.ts +++ b/src/plugins/kibana_utils/public/state_sync/state_sync_state_storage/create_kbn_url_state_storage.test.ts @@ -21,6 +21,7 @@ import { createKbnUrlStateStorage, IKbnUrlStateStorage } from './create_kbn_url_ import { History, createBrowserHistory } from 'history'; import { takeUntil, toArray } from 'rxjs/operators'; import { Subject } from 'rxjs'; +import { ScopedHistory } from '../../../../../core/public'; describe('KbnUrlStateStorage', () => { describe('useHash: false', () => { @@ -132,4 +133,78 @@ describe('KbnUrlStateStorage', () => { expect(await result).toEqual([{ test: 'test', ok: 1 }, { test: 'test', ok: 2 }, null]); }); }); + + describe('ScopedHistory integration', () => { + let urlStateStorage: IKbnUrlStateStorage; + let history: ScopedHistory; + const getCurrentUrl = () => history.createHref(history.location); + beforeEach(() => { + const parentHistory = createBrowserHistory(); + parentHistory.push('/kibana/app/'); + history = new ScopedHistory(parentHistory, '/kibana/app/'); + urlStateStorage = createKbnUrlStateStorage({ useHash: false, history }); + }); + + it('should persist state to url', async () => { + const state = { test: 'test', ok: 1 }; + const key = '_s'; + await urlStateStorage.set(key, state); + expect(getCurrentUrl()).toMatchInlineSnapshot(`"/kibana/app/#?_s=(ok:1,test:test)"`); + expect(urlStateStorage.get(key)).toEqual(state); + }); + + it('should flush state to url', () => { + const state = { test: 'test', ok: 1 }; + const key = '_s'; + urlStateStorage.set(key, state); + expect(getCurrentUrl()).toMatchInlineSnapshot(`"/kibana/app/"`); + expect(urlStateStorage.flush()).toBe(true); + expect(getCurrentUrl()).toMatchInlineSnapshot(`"/kibana/app/#?_s=(ok:1,test:test)"`); + expect(urlStateStorage.get(key)).toEqual(state); + + expect(urlStateStorage.flush()).toBe(false); // nothing to flush, not update + }); + + it('should cancel url updates', async () => { + const state = { test: 'test', ok: 1 }; + const key = '_s'; + const pr = urlStateStorage.set(key, state); + expect(getCurrentUrl()).toMatchInlineSnapshot(`"/kibana/app/"`); + urlStateStorage.cancel(); + await pr; + expect(getCurrentUrl()).toMatchInlineSnapshot(`"/kibana/app/"`); + expect(urlStateStorage.get(key)).toEqual(null); + }); + + it('should cancel url updates if synchronously returned to the same state', async () => { + const state1 = { test: 'test', ok: 1 }; + const state2 = { test: 'test', ok: 2 }; + const key = '_s'; + const pr1 = urlStateStorage.set(key, state1); + await pr1; + const historyLength = history.length; + const pr2 = urlStateStorage.set(key, state2); + const pr3 = urlStateStorage.set(key, state1); + await Promise.all([pr2, pr3]); + expect(history.length).toBe(historyLength); + }); + + it('should notify about url changes', async () => { + expect(urlStateStorage.change$).toBeDefined(); + const key = '_s'; + const destroy$ = new Subject(); + const result = urlStateStorage.change$!(key) + .pipe(takeUntil(destroy$), toArray()) + .toPromise(); + + history.push(`/#?${key}=(ok:1,test:test)`); + history.push(`/?query=test#?${key}=(ok:2,test:test)&some=test`); + history.push(`/?query=test#?some=test`); + + destroy$.next(); + destroy$.complete(); + + expect(await result).toEqual([{ test: 'test', ok: 1 }, { test: 'test', ok: 2 }, null]); + }); + }); }); diff --git a/src/plugins/management/public/management_service.test.ts b/src/plugins/management/public/management_service.test.ts index ceb91837921eb..18569ef285ff3 100644 --- a/src/plugins/management/public/management_service.test.ts +++ b/src/plugins/management/public/management_service.test.ts @@ -29,9 +29,8 @@ test('Provides default sections', () => { () => {}, coreMock.createSetup().getStartServices ); - expect(service.getAllSections().length).toEqual(3); + expect(service.getAllSections().length).toEqual(2); expect(service.getSection('kibana')).not.toBeUndefined(); - expect(service.getSection('logstash')).not.toBeUndefined(); expect(service.getSection('elasticsearch')).not.toBeUndefined(); }); diff --git a/src/plugins/management/public/management_service.ts b/src/plugins/management/public/management_service.ts index ed31a22992da8..8fc207e32e6ce 100644 --- a/src/plugins/management/public/management_service.ts +++ b/src/plugins/management/public/management_service.ts @@ -80,7 +80,6 @@ export class ManagementService { ); register({ id: 'kibana', title: 'Kibana', order: 30, euiIconType: 'logoKibana' }); - register({ id: 'logstash', title: 'Logstash', order: 30, euiIconType: 'logoLogstash' }); register({ id: 'elasticsearch', title: 'Elasticsearch', diff --git a/src/plugins/maps_legacy/public/__tests__/map/service_settings.js b/src/plugins/maps_legacy/public/__tests__/map/service_settings.js index a9272ea396639..4cbe098501c67 100644 --- a/src/plugins/maps_legacy/public/__tests__/map/service_settings.js +++ b/src/plugins/maps_legacy/public/__tests__/map/service_settings.js @@ -143,24 +143,24 @@ describe('service_settings (FKA tilemaptest)', function() { } it('accepts an object', async () => { - serviceSettings.addQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ foo: 'bar' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'bar' }); }); it('merged additions with previous values', async () => { // ensure that changes are always additive - serviceSettings.addQueryParams({ foo: 'bar' }); - serviceSettings.addQueryParams({ bar: 'stool' }); + serviceSettings.setQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ bar: 'stool' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'bar', bar: 'stool' }); }); it('overwrites conflicting previous values', async () => { // ensure that conflicts are overwritten - serviceSettings.addQueryParams({ foo: 'bar' }); - serviceSettings.addQueryParams({ bar: 'stool' }); - serviceSettings.addQueryParams({ foo: 'tstool' }); + serviceSettings.setQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ bar: 'stool' }); + serviceSettings.setQueryParams({ foo: 'tstool' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'tstool', bar: 'stool' }); }); @@ -168,7 +168,7 @@ describe('service_settings (FKA tilemaptest)', function() { it('when overridden, should continue to work', async () => { mapConfig.emsFileApiUrl = emsFileApiUrl2; mapConfig.emsTileApiUrl = emsTileApiUrl2; - serviceSettings.addQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ foo: 'bar' }); tilemapServices = await serviceSettings.getTMSServices(); await assertQuery({ foo: 'bar' }); }); @@ -292,7 +292,7 @@ describe('service_settings (FKA tilemaptest)', function() { describe('File layers', function() { it('should load manifest (all props)', async function() { - serviceSettings.addQueryParams({ foo: 'bar' }); + serviceSettings.setQueryParams({ foo: 'bar' }); const fileLayers = await serviceSettings.getFileLayers(); expect(fileLayers.length).to.be(18); const assertions = fileLayers.map(async function(fileLayer) { diff --git a/src/plugins/maps_legacy/public/map/service_settings.js b/src/plugins/maps_legacy/public/map/service_settings.js index 11c853d39e107..f4f0d66ee20de 100644 --- a/src/plugins/maps_legacy/public/map/service_settings.js +++ b/src/plugins/maps_legacy/public/map/service_settings.js @@ -69,6 +69,10 @@ export class ServiceSettings { return origin === ORIGIN.EMS && this._showZoomMessage; } + enableZoomMessage() { + this._showZoomMessage = true; + } + disableZoomMessage() { this._showZoomMessage = false; } @@ -148,11 +152,12 @@ export class ServiceSettings { } /** - * Add optional query-parameters to all requests + * Set optional query-parameters for all requests * * @param additionalQueryParams */ - addQueryParams(additionalQueryParams) { + setQueryParams(additionalQueryParams) { + // Functions more as a "set" than an "add" in ems-client this._emsClient.addQueryParams(additionalQueryParams); } diff --git a/src/plugins/saved_objects_management/server/services/management.test.ts b/src/plugins/saved_objects_management/server/services/management.test.ts index 6b95048749fae..3625a3f913444 100644 --- a/src/plugins/saved_objects_management/server/services/management.test.ts +++ b/src/plugins/saved_objects_management/server/services/management.test.ts @@ -28,7 +28,7 @@ describe('SavedObjectsManagement', () => { registry.registerType({ name: 'unknown', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: {} }, migrations: {}, ...type, diff --git a/src/plugins/telemetry/server/collectors/application_usage/saved_objects_types.ts b/src/plugins/telemetry/server/collectors/application_usage/saved_objects_types.ts index 9f997ab7b5df3..a0de79da565e6 100644 --- a/src/plugins/telemetry/server/collectors/application_usage/saved_objects_types.ts +++ b/src/plugins/telemetry/server/collectors/application_usage/saved_objects_types.ts @@ -33,7 +33,7 @@ export function registerMappings(registerType: SavedObjectsServiceSetup['registe registerType({ name: 'application_usage_totals', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { appId: { type: 'keyword' }, @@ -46,7 +46,7 @@ export function registerMappings(registerType: SavedObjectsServiceSetup['registe registerType({ name: 'application_usage_transactional', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { timestamp: { type: 'date' }, diff --git a/src/plugins/telemetry/server/collectors/ui_metric/telemetry_ui_metric_collector.ts b/src/plugins/telemetry/server/collectors/ui_metric/telemetry_ui_metric_collector.ts index 3f6e1836cac7d..603742f612a6b 100644 --- a/src/plugins/telemetry/server/collectors/ui_metric/telemetry_ui_metric_collector.ts +++ b/src/plugins/telemetry/server/collectors/ui_metric/telemetry_ui_metric_collector.ts @@ -38,7 +38,7 @@ export function registerUiMetricUsageCollector( registerType({ name: 'ui-metric', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { count: { diff --git a/src/plugins/telemetry/server/config.ts b/src/plugins/telemetry/server/config.ts index 9621a8b5619b2..99dde0c3b3d96 100644 --- a/src/plugins/telemetry/server/config.ts +++ b/src/plugins/telemetry/server/config.ts @@ -36,8 +36,8 @@ export const configSchema = schema.object({ config: schema.string({ defaultValue: getConfigPath() }), banner: schema.boolean({ defaultValue: true }), url: schema.conditional( - schema.contextRef('dev'), - schema.literal(true), + schema.contextRef('dist'), + schema.literal(false), // Point to staging if it's not a distributable release schema.string({ defaultValue: `https://telemetry-staging.elastic.co/xpack/${ENDPOINT_VERSION}/send`, }), @@ -46,8 +46,8 @@ export const configSchema = schema.object({ }) ), optInStatusUrl: schema.conditional( - schema.contextRef('dev'), - schema.literal(true), + schema.contextRef('dist'), + schema.literal(false), // Point to staging if it's not a distributable release schema.string({ defaultValue: `https://telemetry-staging.elastic.co/opt_in_status/${ENDPOINT_VERSION}/send`, }), diff --git a/src/plugins/telemetry/server/plugin.ts b/src/plugins/telemetry/server/plugin.ts index 1df6a665e4d76..d1530c272027a 100644 --- a/src/plugins/telemetry/server/plugin.ts +++ b/src/plugins/telemetry/server/plugin.ts @@ -125,7 +125,7 @@ export class TelemetryPlugin implements Plugin { registerType({ name: 'telemetry', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { enabled: { diff --git a/src/plugins/telemetry_collection_manager/server/encryption/encrypt.test.ts b/src/plugins/telemetry_collection_manager/server/encryption/encrypt.test.ts index c04625eb1dd42..6d64268569e06 100644 --- a/src/plugins/telemetry_collection_manager/server/encryption/encrypt.test.ts +++ b/src/plugins/telemetry_collection_manager/server/encryption/encrypt.test.ts @@ -22,14 +22,14 @@ import { encryptTelemetry, getKID } from './encrypt'; describe('getKID', () => { it(`returns 'kibana_dev' kid for development`, async () => { - const isProd = false; - const kid = getKID(isProd); + const useProdKey = false; + const kid = getKID(useProdKey); expect(kid).toBe('kibana_dev'); }); it(`returns 'kibana_prod' kid for development`, async () => { - const isProd = true; - const kid = getKID(isProd); + const useProdKey = true; + const kid = getKID(useProdKey); expect(kid).toBe('kibana'); }); }); @@ -41,19 +41,19 @@ describe('encryptTelemetry', () => { it('encrypts payload', async () => { const payload = { some: 'value' }; - await encryptTelemetry(payload, { isProd: true }); + await encryptTelemetry(payload, { useProdKey: true }); expect(createRequestEncryptor).toBeCalledWith(telemetryJWKS); }); - it('uses kibana kid on { isProd: true }', async () => { + it('uses kibana kid on { useProdKey: true }', async () => { const payload = { some: 'value' }; - await encryptTelemetry(payload, { isProd: true }); + await encryptTelemetry(payload, { useProdKey: true }); expect(mockEncrypt).toBeCalledWith('kibana', payload); }); - it('uses kibana_dev kid on { isProd: false }', async () => { + it('uses kibana_dev kid on { useProdKey: false }', async () => { const payload = { some: 'value' }; - await encryptTelemetry(payload, { isProd: false }); + await encryptTelemetry(payload, { useProdKey: false }); expect(mockEncrypt).toBeCalledWith('kibana_dev', payload); }); }); diff --git a/src/plugins/telemetry_collection_manager/server/encryption/encrypt.ts b/src/plugins/telemetry_collection_manager/server/encryption/encrypt.ts index 44f053064cfcb..89f34d794f059 100644 --- a/src/plugins/telemetry_collection_manager/server/encryption/encrypt.ts +++ b/src/plugins/telemetry_collection_manager/server/encryption/encrypt.ts @@ -20,12 +20,15 @@ import { createRequestEncryptor } from '@elastic/request-crypto'; import { telemetryJWKS } from './telemetry_jwks'; -export function getKID(isProd = false): string { - return isProd ? 'kibana' : 'kibana_dev'; +export function getKID(useProdKey = false): string { + return useProdKey ? 'kibana' : 'kibana_dev'; } -export async function encryptTelemetry(payload: any, { isProd = false } = {}): Promise { - const kid = getKID(isProd); +export async function encryptTelemetry( + payload: any, + { useProdKey = false } = {} +): Promise { + const kid = getKID(useProdKey); const encryptor = await createRequestEncryptor(telemetryJWKS); const clusters = [].concat(payload); return Promise.all(clusters.map((cluster: any) => encryptor.encrypt(kid, cluster))); diff --git a/src/plugins/telemetry_collection_manager/server/plugin.ts b/src/plugins/telemetry_collection_manager/server/plugin.ts index f2f20e215c535..0b57fae83c0fb 100644 --- a/src/plugins/telemetry_collection_manager/server/plugin.ts +++ b/src/plugins/telemetry_collection_manager/server/plugin.ts @@ -50,12 +50,12 @@ export class TelemetryCollectionManagerPlugin private readonly collections: Array> = []; private usageGetterMethodPriority = -1; private usageCollection?: UsageCollectionSetup; - private readonly isDev: boolean; + private readonly isDistributable: boolean; private readonly version: string; constructor(initializerContext: PluginInitializerContext) { this.logger = initializerContext.logger.get(); - this.isDev = initializerContext.env.mode.dev; + this.isDistributable = initializerContext.env.packageInfo.dist; this.version = initializerContext.env.packageInfo.version; } @@ -158,7 +158,7 @@ export class TelemetryCollectionManagerPlugin if (config.unencrypted) { return optInStats; } - return encryptTelemetry(optInStats, { isProd: !this.isDev }); + return encryptTelemetry(optInStats, { useProdKey: this.isDistributable }); } } catch (err) { this.logger.debug(`Failed to collect any opt in stats with registered collections.`); @@ -176,7 +176,6 @@ export class TelemetryCollectionManagerPlugin ) => { const context: StatsCollectionContext = { logger: this.logger.get(collection.title), - isDev: this.isDev, version: this.version, ...collection.customContext, }; @@ -206,7 +205,7 @@ export class TelemetryCollectionManagerPlugin return usageData; } - return encryptTelemetry(usageData, { isProd: !this.isDev }); + return encryptTelemetry(usageData, { useProdKey: this.isDistributable }); } } catch (err) { this.logger.debug( @@ -225,7 +224,6 @@ export class TelemetryCollectionManagerPlugin ): Promise { const context: StatsCollectionContext = { logger: this.logger.get(collection.title), - isDev: this.isDev, version: this.version, ...collection.customContext, }; diff --git a/src/plugins/telemetry_collection_manager/server/types.ts b/src/plugins/telemetry_collection_manager/server/types.ts index e23d6a4c388f4..d3a47694d38a7 100644 --- a/src/plugins/telemetry_collection_manager/server/types.ts +++ b/src/plugins/telemetry_collection_manager/server/types.ts @@ -101,7 +101,6 @@ export interface ESLicense { export interface StatsCollectionContext { logger: Logger; - isDev: boolean; version: string; } diff --git a/src/plugins/timelion/kibana.json b/src/plugins/timelion/kibana.json deleted file mode 100644 index dddfd6c67e655..0000000000000 --- a/src/plugins/timelion/kibana.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "timelion", - "version": "8.0.0", - "kibanaVersion": "kibana", - "configPath": ["timelion"], - "server": true, - "ui": true -} diff --git a/src/plugins/vis_default_editor/public/components/agg_params_map.ts b/src/plugins/vis_default_editor/public/components/agg_params_map.ts index 5af3cfc5b0928..9bc3146b9903b 100644 --- a/src/plugins/vis_default_editor/public/components/agg_params_map.ts +++ b/src/plugins/vis_default_editor/public/components/agg_params_map.ts @@ -58,6 +58,8 @@ const buckets = { size: controls.SizeParamEditor, }, [BUCKET_TYPES.TERMS]: { + include: controls.IncludeExcludeParamEditor, + exclude: controls.IncludeExcludeParamEditor, orderBy: controls.OrderByParamEditor, orderAgg: controls.OrderAggParamEditor, order: wrapWithInlineComp(controls.OrderParamEditor), diff --git a/src/plugins/vis_default_editor/public/components/controls/components/number_list/utils.ts b/src/plugins/vis_default_editor/public/components/controls/components/number_list/utils.ts index dac86249ebbb9..5cb594ade8dba 100644 --- a/src/plugins/vis_default_editor/public/components/controls/components/number_list/utils.ts +++ b/src/plugins/vis_default_editor/public/components/controls/components/number_list/utils.ts @@ -119,7 +119,7 @@ function getNextModel(list: NumberRowModel[], range: NumberListRange): NumberRow }; } -function getInitModelList(list: Array): NumberRowModel[] { +function getInitModelList(list: Array): NumberRowModel[] { return list.length ? list.map(num => ({ value: (num === undefined ? EMPTY_STRING : num) as NumberRowModel['value'], diff --git a/src/plugins/vis_default_editor/public/components/controls/components/simple_number_list.tsx b/src/plugins/vis_default_editor/public/components/controls/components/simple_number_list.tsx new file mode 100644 index 0000000000000..becf8e47ef573 --- /dev/null +++ b/src/plugins/vis_default_editor/public/components/controls/components/simple_number_list.tsx @@ -0,0 +1,140 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react'; +import { isArray } from 'lodash'; +import { EuiButtonEmpty, EuiFlexItem, EuiFormRow, EuiSpacer, htmlIdGenerator } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { EMPTY_STRING, getInitModelList, getRange, parse } from './number_list/utils'; +import { NumberRow, NumberRowModel } from './number_list/number_row'; +import { AggParamEditorProps } from '../../agg_param_props'; + +const generateId = htmlIdGenerator(); + +function SimpleNumberList({ + agg, + aggParam, + value, + setValue, + setTouched, +}: AggParamEditorProps>) { + const [numbers, setNumbers] = useState( + getInitModelList(value && isArray(value) ? value : [EMPTY_STRING]) + ); + const numberRange = useMemo(() => getRange('[-Infinity,Infinity]'), []); + + // This useEffect is needed to discard changes, it sets numbers a mapped value if they are different + useEffect(() => { + if ( + isArray(value) && + (value.length !== numbers.length || + !value.every((numberValue, index) => numberValue === numbers[index].value)) + ) { + setNumbers( + value.map(numberValue => ({ + id: generateId(), + value: numberValue, + isInvalid: false, + })) + ); + } + }, [numbers, value]); + + const onUpdate = useCallback( + (numberList: NumberRowModel[]) => { + setNumbers(numberList); + setValue(numberList.map(({ value: numberValue }) => numberValue)); + }, + [setValue] + ); + + const onChangeValue = useCallback( + (numberField: { id: string; value: string }) => { + onUpdate( + numbers.map(number => + number.id === numberField.id + ? { + id: numberField.id, + value: parse(numberField.value), + isInvalid: false, + } + : number + ) + ); + }, + [numbers, onUpdate] + ); + + // Add an item to the end of the list + const onAdd = useCallback(() => { + const newArray = [ + ...numbers, + { + id: generateId(), + value: EMPTY_STRING as '', + isInvalid: false, + }, + ]; + onUpdate(newArray); + }, [numbers, onUpdate]); + + const onDelete = useCallback( + (id: string) => onUpdate(numbers.filter(number => number.id !== id)), + [numbers, onUpdate] + ); + + return ( + + <> + {numbers.map((number, arrayIndex) => ( + + + {numbers.length - 1 !== arrayIndex && } + + ))} + + + + + + + + + ); +} + +export { SimpleNumberList }; diff --git a/src/plugins/vis_default_editor/public/components/controls/include_exclude.tsx b/src/plugins/vis_default_editor/public/components/controls/include_exclude.tsx new file mode 100644 index 0000000000000..f60f6ce7ce249 --- /dev/null +++ b/src/plugins/vis_default_editor/public/components/controls/include_exclude.tsx @@ -0,0 +1,49 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React, { useEffect } from 'react'; +import { AggParamEditorProps } from '../agg_param_props'; +import { StringParamEditor } from './string'; +import { search } from '../../../../data/public'; +import { SimpleNumberList } from './components/simple_number_list'; +const { isNumberType } = search.aggs; + +export function IncludeExcludeParamEditor(props: AggParamEditorProps>) { + const { agg, value, setValue } = props; + const isAggOfNumberType = isNumberType(agg); + + // This useEffect converts value from string type to number and back when the field type is changed + useEffect(() => { + if (isAggOfNumberType && !Array.isArray(value) && value !== undefined) { + const numberArray = value + .split('|') + .map(item => parseFloat(item)) + .filter(number => Number.isFinite(number)); + setValue(numberArray.length ? numberArray : ['']); + } else if (!isAggOfNumberType && Array.isArray(value) && value !== undefined) { + setValue(value.filter(item => item !== '').join('|')); + } + }, [isAggOfNumberType, setValue, value]); + + return isAggOfNumberType ? ( + } /> + ) : ( + + ); +} diff --git a/src/plugins/vis_default_editor/public/components/controls/index.ts b/src/plugins/vis_default_editor/public/components/controls/index.ts index e8944aa667853..cfb236e5e22e3 100644 --- a/src/plugins/vis_default_editor/public/components/controls/index.ts +++ b/src/plugins/vis_default_editor/public/components/controls/index.ts @@ -24,6 +24,7 @@ export { ExtendedBoundsParamEditor } from './extended_bounds'; export { FieldParamEditor } from './field'; export { FiltersParamEditor } from './filters'; export { HasExtendedBoundsParamEditor } from './has_extended_bounds'; +export { IncludeExcludeParamEditor } from './include_exclude'; export { IpRangesParamEditor } from './ip_ranges'; export { IpRangeTypeParamEditor } from './ip_range_type'; export { IsFilteredByCollarParamEditor } from './is_filtered_by_collar'; diff --git a/src/plugins/vis_type_table/config.ts b/src/plugins/vis_type_table/config.ts new file mode 100644 index 0000000000000..6749bd83de39f --- /dev/null +++ b/src/plugins/vis_type_table/config.ts @@ -0,0 +1,26 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { schema, TypeOf } from '@kbn/config-schema'; + +export const configSchema = schema.object({ + enabled: schema.boolean({ defaultValue: true }), +}); + +export type ConfigSchema = TypeOf; diff --git a/src/plugins/vis_type_table/kibana.json b/src/plugins/vis_type_table/kibana.json new file mode 100644 index 0000000000000..bb0f6478a4240 --- /dev/null +++ b/src/plugins/vis_type_table/kibana.json @@ -0,0 +1,11 @@ +{ + "id": "visTypeTable", + "version": "kibana", + "server": true, + "ui": true, + "requiredPlugins": [ + "expressions", + "visualizations", + "data" + ] +} diff --git a/src/legacy/core_plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap b/src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap rename to src/plugins/vis_type_table/public/__snapshots__/table_vis_fn.test.ts.snap diff --git a/src/legacy/core_plugins/vis_type_table/public/_table_vis.scss b/src/plugins/vis_type_table/public/_table_vis.scss similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/_table_vis.scss rename to src/plugins/vis_type_table/public/_table_vis.scss diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/_agg_table.scss b/src/plugins/vis_type_table/public/agg_table/_agg_table.scss similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/agg_table/_agg_table.scss rename to src/plugins/vis_type_table/public/agg_table/_agg_table.scss diff --git a/src/plugins/vis_type_table/public/agg_table/_index.scss b/src/plugins/vis_type_table/public/agg_table/_index.scss new file mode 100644 index 0000000000000..340e08a76f1bd --- /dev/null +++ b/src/plugins/vis_type_table/public/agg_table/_index.scss @@ -0,0 +1 @@ +@import './agg_table'; diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/agg_table.html b/src/plugins/vis_type_table/public/agg_table/agg_table.html similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/agg_table/agg_table.html rename to src/plugins/vis_type_table/public/agg_table/agg_table.html diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/agg_table.js b/src/plugins/vis_type_table/public/agg_table/agg_table.js similarity index 98% rename from src/legacy/core_plugins/vis_type_table/public/agg_table/agg_table.js rename to src/plugins/vis_type_table/public/agg_table/agg_table.js index b9e79f96e4fc1..0cd501e2d0344 100644 --- a/src/legacy/core_plugins/vis_type_table/public/agg_table/agg_table.js +++ b/src/plugins/vis_type_table/public/agg_table/agg_table.js @@ -238,9 +238,9 @@ export function KbnAggTable(config, RecursionHelper) { } /** - * @param {[]Object} columns - the formatted columns that will be displayed + * @param {Object[]} columns - the formatted columns that will be displayed * @param {String} title - the title of the column to add to - * @param {[]Object} rows - the row data for the columns + * @param {Object[]} rows - the row data for the columns * @param {Number} insertAtIndex - the index to insert the percentage column at * @returns {Object} - cols and rows for the table to render now included percentage column(s) */ diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/agg_table_group.html b/src/plugins/vis_type_table/public/agg_table/agg_table_group.html similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/agg_table/agg_table_group.html rename to src/plugins/vis_type_table/public/agg_table/agg_table_group.html diff --git a/src/legacy/core_plugins/vis_type_table/public/agg_table/agg_table_group.js b/src/plugins/vis_type_table/public/agg_table/agg_table_group.js similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/agg_table/agg_table_group.js rename to src/plugins/vis_type_table/public/agg_table/agg_table_group.js diff --git a/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx b/src/plugins/vis_type_table/public/components/table_vis_options.tsx similarity index 96% rename from src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx rename to src/plugins/vis_type_table/public/components/table_vis_options.tsx index 265528f33f9cd..68348d5ef1060 100644 --- a/src/legacy/core_plugins/vis_type_table/public/components/table_vis_options.tsx +++ b/src/plugins/vis_type_table/public/components/table_vis_options.tsx @@ -24,12 +24,8 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { VisOptionsProps } from 'src/plugins/vis_default_editor/public'; -import { search } from '../../../../../plugins/data/public'; -import { - SwitchOption, - SelectOption, - NumberInputOption, -} from '../../../../../plugins/charts/public'; +import { search } from '../../../data/public'; +import { SwitchOption, SelectOption, NumberInputOption } from '../../../charts/public'; import { TableVisParams } from '../types'; import { totalAggregations } from './utils'; diff --git a/src/legacy/core_plugins/vis_type_table/public/components/utils.ts b/src/plugins/vis_type_table/public/components/utils.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/components/utils.ts rename to src/plugins/vis_type_table/public/components/utils.ts diff --git a/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts b/src/plugins/vis_type_table/public/get_inner_angular.ts similarity index 91% rename from src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts rename to src/plugins/vis_type_table/public/get_inner_angular.ts index 6208e358b4184..d69b9bba31b03 100644 --- a/src/legacy/core_plugins/vis_type_table/public/get_inner_angular.ts +++ b/src/plugins/vis_type_table/public/get_inner_angular.ts @@ -23,7 +23,7 @@ import angular from 'angular'; import 'angular-recursion'; import { i18nDirective, i18nFilter, I18nProvider } from '@kbn/i18n/angular'; -import { CoreStart, LegacyCoreStart, IUiSettingsClient } from 'kibana/public'; +import { CoreStart, IUiSettingsClient, PluginInitializerContext } from 'kibana/public'; import { initAngularBootstrap, PaginateDirectiveProvider, @@ -32,15 +32,15 @@ import { watchMultiDecorator, KbnAccessibleClickProvider, configureAppAngularModule, -} from '../../../../plugins/kibana_legacy/public'; +} from '../../kibana_legacy/public'; initAngularBootstrap(); const thirdPartyAngularDependencies = ['ngSanitize', 'ui.bootstrap', 'RecursionHelper']; -export function getAngularModule(name: string, core: CoreStart) { +export function getAngularModule(name: string, core: CoreStart, context: PluginInitializerContext) { const uiModule = getInnerAngular(name, core); - configureAppAngularModule(uiModule, core as LegacyCoreStart, true); + configureAppAngularModule(uiModule, { core, env: context.env }, true); return uiModule; } diff --git a/src/legacy/core_plugins/vis_type_table/public/index.scss b/src/plugins/vis_type_table/public/index.scss similarity index 61% rename from src/legacy/core_plugins/vis_type_table/public/index.scss rename to src/plugins/vis_type_table/public/index.scss index 54124ebc42620..0972c85e0dbe0 100644 --- a/src/legacy/core_plugins/vis_type_table/public/index.scss +++ b/src/plugins/vis_type_table/public/index.scss @@ -1,5 +1,3 @@ -@import 'src/legacy/ui/public/styles/styling_constants'; - // Prefix all styles with "tbv" to avoid conflicts. // Examples // tbvChart @@ -7,6 +5,6 @@ // tbvChart__legend--small // tbvChart__legend-isLoading -@import 'agg_table/index'; -@import 'paginated_table/index'; +@import './agg_table/index'; +@import './paginated_table/index'; @import './table_vis'; diff --git a/src/legacy/core_plugins/vis_type_table/public/index.ts b/src/plugins/vis_type_table/public/index.ts similarity index 92% rename from src/legacy/core_plugins/vis_type_table/public/index.ts rename to src/plugins/vis_type_table/public/index.ts index efbaf69659ea2..5621fdb094772 100644 --- a/src/legacy/core_plugins/vis_type_table/public/index.ts +++ b/src/plugins/vis_type_table/public/index.ts @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - -import { PluginInitializerContext } from '../../../../core/public'; +import './index.scss'; +import { PluginInitializerContext } from 'kibana/public'; import { TableVisPlugin as Plugin } from './plugin'; export function plugin(initializerContext: PluginInitializerContext) { diff --git a/src/plugins/vis_type_table/public/paginated_table/_index.scss b/src/plugins/vis_type_table/public/paginated_table/_index.scss new file mode 100644 index 0000000000000..23d56c09b2818 --- /dev/null +++ b/src/plugins/vis_type_table/public/paginated_table/_index.scss @@ -0,0 +1 @@ +@import './_table_cell_filter'; diff --git a/src/legacy/core_plugins/vis_type_table/public/paginated_table/_table_cell_filter.scss b/src/plugins/vis_type_table/public/paginated_table/_table_cell_filter.scss similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/paginated_table/_table_cell_filter.scss rename to src/plugins/vis_type_table/public/paginated_table/_table_cell_filter.scss diff --git a/src/legacy/core_plugins/vis_type_table/public/paginated_table/paginated_table.html b/src/plugins/vis_type_table/public/paginated_table/paginated_table.html similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/paginated_table/paginated_table.html rename to src/plugins/vis_type_table/public/paginated_table/paginated_table.html diff --git a/src/legacy/core_plugins/vis_type_table/public/paginated_table/paginated_table.js b/src/plugins/vis_type_table/public/paginated_table/paginated_table.js similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/paginated_table/paginated_table.js rename to src/plugins/vis_type_table/public/paginated_table/paginated_table.js diff --git a/src/legacy/core_plugins/vis_type_table/public/paginated_table/paginated_table.test.ts b/src/plugins/vis_type_table/public/paginated_table/paginated_table.test.ts similarity index 98% rename from src/legacy/core_plugins/vis_type_table/public/paginated_table/paginated_table.test.ts rename to src/plugins/vis_type_table/public/paginated_table/paginated_table.test.ts index 7352236f03feb..23e4aee0378dc 100644 --- a/src/legacy/core_plugins/vis_type_table/public/paginated_table/paginated_table.test.ts +++ b/src/plugins/vis_type_table/public/paginated_table/paginated_table.test.ts @@ -25,10 +25,9 @@ import 'angular-mocks'; import { getAngularModule } from '../get_inner_angular'; import { initTableVisLegacyModule } from '../table_vis_legacy_module'; -import { coreMock } from '../../../../../core/public/mocks'; +import { coreMock } from '../../../../core/public/mocks'; -jest.mock('ui/new_platform'); -jest.mock('../../../../../plugins/kibana_legacy/public/angular/angular_config', () => ({ +jest.mock('../../../kibana_legacy/public/angular/angular_config', () => ({ configureAppAngularModule: () => {}, })); @@ -73,7 +72,11 @@ describe('Table Vis - Paginated table', () => { let paginatedTable: any; const initLocalAngular = () => { - const tableVisModule = getAngularModule('kibana/table_vis', coreMock.createStart()); + const tableVisModule = getAngularModule( + 'kibana/table_vis', + coreMock.createStart(), + coreMock.createPluginInitializerContext() + ); initTableVisLegacyModule(tableVisModule); }; diff --git a/src/legacy/core_plugins/vis_type_table/public/paginated_table/rows.js b/src/plugins/vis_type_table/public/paginated_table/rows.js similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/paginated_table/rows.js rename to src/plugins/vis_type_table/public/paginated_table/rows.js diff --git a/src/legacy/core_plugins/vis_type_table/public/paginated_table/table_cell_filter.html b/src/plugins/vis_type_table/public/paginated_table/table_cell_filter.html similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/paginated_table/table_cell_filter.html rename to src/plugins/vis_type_table/public/paginated_table/table_cell_filter.html diff --git a/src/legacy/core_plugins/vis_type_table/public/plugin.ts b/src/plugins/vis_type_table/public/plugin.ts similarity index 80% rename from src/legacy/core_plugins/vis_type_table/public/plugin.ts rename to src/plugins/vis_type_table/public/plugin.ts index ea12a5320a14d..a41d939523bcc 100644 --- a/src/legacy/core_plugins/vis_type_table/public/plugin.ts +++ b/src/plugins/vis_type_table/public/plugin.ts @@ -16,14 +16,13 @@ * specific language governing permissions and limitations * under the License. */ -import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public'; -import { VisualizationsSetup } from '../../../../plugins/visualizations/public'; - -import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../../core/public'; +import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'kibana/public'; +import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public'; +import { VisualizationsSetup } from '../../visualizations/public'; import { createTableVisFn } from './table_vis_fn'; -import { tableVisTypeDefinition } from './table_vis_type'; -import { DataPublicPluginStart } from '../../../../plugins/data/public'; +import { getTableVisTypeDefinition } from './table_vis_type'; +import { DataPublicPluginStart } from '../../data/public'; import { setFormatService } from './services'; /** @internal */ @@ -40,6 +39,7 @@ export interface TablePluginStartDependencies { /** @internal */ export class TableVisPlugin implements Plugin, void> { initializerContext: PluginInitializerContext; + createBaseVisualization: any; constructor(initializerContext: PluginInitializerContext) { this.initializerContext = initializerContext; @@ -50,8 +50,9 @@ export class TableVisPlugin implements Plugin, void> { { expressions, visualizations }: TablePluginSetupDependencies ) { expressions.registerFunction(createTableVisFn); - - visualizations.createBaseVisualization(tableVisTypeDefinition); + visualizations.createBaseVisualization( + getTableVisTypeDefinition(core, this.initializerContext) + ); } public start(core: CoreStart, { data }: TablePluginStartDependencies) { diff --git a/src/legacy/core_plugins/vis_type_table/public/services.ts b/src/plugins/vis_type_table/public/services.ts similarity index 86% rename from src/legacy/core_plugins/vis_type_table/public/services.ts rename to src/plugins/vis_type_table/public/services.ts index b4b491ac7a555..3aaffe75e27f1 100644 --- a/src/legacy/core_plugins/vis_type_table/public/services.ts +++ b/src/plugins/vis_type_table/public/services.ts @@ -17,8 +17,8 @@ * under the License. */ -import { createGetterSetter } from '../../../../plugins/kibana_utils/public'; -import { DataPublicPluginStart } from '../../../../plugins/data/public'; +import { createGetterSetter } from '../../kibana_utils/public'; +import { DataPublicPluginStart } from '../../data/public'; export const [getFormatService, setFormatService] = createGetterSetter< DataPublicPluginStart['fieldFormats'] diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis.html b/src/plugins/vis_type_table/public/table_vis.html similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/table_vis.html rename to src/plugins/vis_type_table/public/table_vis.html diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.js b/src/plugins/vis_type_table/public/table_vis_controller.js similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/table_vis_controller.js rename to src/plugins/vis_type_table/public/table_vis_controller.js diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts b/src/plugins/vis_type_table/public/table_vis_controller.test.ts similarity index 89% rename from src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts rename to src/plugins/vis_type_table/public/table_vis_controller.test.ts index 8d6f88bf8dd4a..4607324ca150c 100644 --- a/src/legacy/core_plugins/vis_type_table/public/table_vis_controller.test.ts +++ b/src/plugins/vis_type_table/public/table_vis_controller.test.ts @@ -26,24 +26,23 @@ import $ from 'jquery'; import StubIndexPattern from 'test_utils/stub_index_pattern'; import { getAngularModule } from './get_inner_angular'; import { initTableVisLegacyModule } from './table_vis_legacy_module'; -import { tableVisTypeDefinition } from './table_vis_type'; -import { Vis } from '../../../../plugins/visualizations/public'; +import { getTableVisTypeDefinition } from './table_vis_type'; +import { Vis } from '../../visualizations/public'; // eslint-disable-next-line -import { stubFields } from '../../../../plugins/data/public/stubs'; +import { stubFields } from '../../data/public/stubs'; // eslint-disable-next-line import { tableVisResponseHandler } from './table_vis_response_handler'; -import { coreMock } from '../../../../core/public/mocks'; +import { coreMock } from '../../../core/public/mocks'; +import { IAggConfig, search } from '../../data/public'; +// TODO: remove linting disable // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { npStart } from './legacy_imports'; -import { IAggConfig, search } from '../../../../plugins/data/public'; +import { searchStartMock } from '../../data/public/search/mocks'; -// should be mocked once get rid of 'ui/new_platform' legacy imports -const { createAggConfigs } = npStart.plugins.data.search.aggs; +const { createAggConfigs } = searchStartMock.aggs; const { tabifyAggResponse } = search; -jest.mock('ui/new_platform'); -jest.mock('../../../../plugins/kibana_legacy/public/angular/angular_config', () => ({ +jest.mock('../../kibana_legacy/public/angular/angular_config', () => ({ configureAppAngularModule: () => {}, })); @@ -89,7 +88,11 @@ describe('Table Vis - Controller', () => { let stubIndexPattern: any; const initLocalAngular = () => { - const tableVisModule = getAngularModule('kibana/table_vis', coreMock.createStart()); + const tableVisModule = getAngularModule( + 'kibana/table_vis', + coreMock.createStart(), + coreMock.createPluginInitializerContext() + ); initTableVisLegacyModule(tableVisModule); }; @@ -110,9 +113,13 @@ describe('Table Vis - Controller', () => { (cfg: any) => cfg, 'time', stubFields, - coreMock.createStart() + coreMock.createSetup() ); }); + const tableVisTypeDefinition = getTableVisTypeDefinition( + coreMock.createSetup(), + coreMock.createPluginInitializerContext() + ); function getRangeVis(params?: object) { return ({ diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_fn.test.ts b/src/plugins/vis_type_table/public/table_vis_fn.test.ts similarity index 95% rename from src/legacy/core_plugins/vis_type_table/public/table_vis_fn.test.ts rename to src/plugins/vis_type_table/public/table_vis_fn.test.ts index 36392c10f93f3..9accf8950d910 100644 --- a/src/legacy/core_plugins/vis_type_table/public/table_vis_fn.test.ts +++ b/src/plugins/vis_type_table/public/table_vis_fn.test.ts @@ -21,7 +21,7 @@ import { createTableVisFn } from './table_vis_fn'; import { tableVisResponseHandler } from './table_vis_response_handler'; // eslint-disable-next-line -import { functionWrapper } from '../../../../plugins/expressions/common/expression_functions/specs/tests/utils'; +import { functionWrapper } from '../../expressions/common/expression_functions/specs/tests/utils'; jest.mock('./table_vis_response_handler', () => ({ tableVisResponseHandler: jest.fn().mockReturnValue({ diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_fn.ts b/src/plugins/vis_type_table/public/table_vis_fn.ts similarity index 94% rename from src/legacy/core_plugins/vis_type_table/public/table_vis_fn.ts rename to src/plugins/vis_type_table/public/table_vis_fn.ts index a97e596e89754..9739a7a284e6c 100644 --- a/src/legacy/core_plugins/vis_type_table/public/table_vis_fn.ts +++ b/src/plugins/vis_type_table/public/table_vis_fn.ts @@ -19,11 +19,7 @@ import { i18n } from '@kbn/i18n'; import { tableVisResponseHandler, TableContext } from './table_vis_response_handler'; -import { - ExpressionFunctionDefinition, - KibanaDatatable, - Render, -} from '../../../../plugins/expressions/public'; +import { ExpressionFunctionDefinition, KibanaDatatable, Render } from '../../expressions/public'; export type Input = KibanaDatatable; diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_legacy_module.ts b/src/plugins/vis_type_table/public/table_vis_legacy_module.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/table_vis_legacy_module.ts rename to src/plugins/vis_type_table/public/table_vis_legacy_module.ts diff --git a/src/legacy/core_plugins/vis_type_table/public/table_vis_response_handler.ts b/src/plugins/vis_type_table/public/table_vis_response_handler.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_table/public/table_vis_response_handler.ts rename to src/plugins/vis_type_table/public/table_vis_response_handler.ts diff --git a/src/plugins/vis_type_table/public/table_vis_type.ts b/src/plugins/vis_type_table/public/table_vis_type.ts new file mode 100644 index 0000000000000..26e5ac8cfd71a --- /dev/null +++ b/src/plugins/vis_type_table/public/table_vis_type.ts @@ -0,0 +1,100 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { CoreSetup, PluginInitializerContext } from 'kibana/public'; +import { i18n } from '@kbn/i18n'; +import { AggGroupNames } from '../../data/public'; +import { Schemas } from '../../vis_default_editor/public'; +import { Vis } from '../../visualizations/public'; +import { tableVisResponseHandler } from './table_vis_response_handler'; +// @ts-ignore +import tableVisTemplate from './table_vis.html'; +import { TableOptions } from './components/table_vis_options'; +import { getTableVisualizationControllerClass } from './vis_controller'; + +export function getTableVisTypeDefinition(core: CoreSetup, context: PluginInitializerContext) { + return { + type: 'table', + name: 'table', + title: i18n.translate('visTypeTable.tableVisTitle', { + defaultMessage: 'Data Table', + }), + icon: 'visTable', + description: i18n.translate('visTypeTable.tableVisDescription', { + defaultMessage: 'Display values in a table', + }), + visualization: getTableVisualizationControllerClass(core, context), + visConfig: { + defaults: { + perPage: 10, + showPartialRows: false, + showMetricsAtAllLevels: false, + sort: { + columnIndex: null, + direction: null, + }, + showTotal: false, + totalFunc: 'sum', + percentageCol: '', + }, + template: tableVisTemplate, + }, + editorConfig: { + optionsTemplate: TableOptions, + schemas: new Schemas([ + { + group: AggGroupNames.Metrics, + name: 'metric', + title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.metricTitle', { + defaultMessage: 'Metric', + }), + aggFilter: ['!geo_centroid', '!geo_bounds'], + aggSettings: { + top_hits: { + allowStrings: true, + }, + }, + min: 1, + defaults: [{ type: 'count', schema: 'metric' }], + }, + { + group: AggGroupNames.Buckets, + name: 'bucket', + title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.bucketTitle', { + defaultMessage: 'Split rows', + }), + aggFilter: ['!filter'], + }, + { + group: AggGroupNames.Buckets, + name: 'split', + title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.splitTitle', { + defaultMessage: 'Split table', + }), + min: 0, + max: 1, + aggFilter: ['!filter'], + }, + ]), + }, + responseHandler: tableVisResponseHandler, + hierarchicalData: (vis: Vis) => { + return Boolean(vis.params.showPartialRows || vis.params.showMetricsAtAllLevels); + }, + }; +} diff --git a/src/legacy/core_plugins/vis_type_table/public/types.ts b/src/plugins/vis_type_table/public/types.ts similarity index 94% rename from src/legacy/core_plugins/vis_type_table/public/types.ts rename to src/plugins/vis_type_table/public/types.ts index c6de14b9f050c..39023d1305cb6 100644 --- a/src/legacy/core_plugins/vis_type_table/public/types.ts +++ b/src/plugins/vis_type_table/public/types.ts @@ -17,7 +17,7 @@ * under the License. */ -import { SchemaConfig } from '../../../../plugins/visualizations/public'; +import { SchemaConfig } from '../../visualizations/public'; export enum AggTypes { SUM = 'sum', diff --git a/src/plugins/vis_type_table/public/vis_controller.ts b/src/plugins/vis_type_table/public/vis_controller.ts new file mode 100644 index 0000000000000..d49dd32c8c89c --- /dev/null +++ b/src/plugins/vis_type_table/public/vis_controller.ts @@ -0,0 +1,109 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { CoreSetup, PluginInitializerContext } from 'kibana/public'; +import angular, { IModule, auto, IRootScopeService, IScope, ICompileService } from 'angular'; +import $ from 'jquery'; + +import { VisParams, ExprVis } from '../../visualizations/public'; +import { getAngularModule } from './get_inner_angular'; +import { initTableVisLegacyModule } from './table_vis_legacy_module'; + +const innerAngularName = 'kibana/table_vis'; + +export function getTableVisualizationControllerClass( + core: CoreSetup, + context: PluginInitializerContext +) { + return class TableVisualizationController { + private tableVisModule: IModule | undefined; + private injector: auto.IInjectorService | undefined; + el: JQuery; + vis: ExprVis; + $rootScope: IRootScopeService | null = null; + $scope: (IScope & { [key: string]: any }) | undefined; + $compile: ICompileService | undefined; + + constructor(domeElement: Element, vis: ExprVis) { + this.el = $(domeElement); + this.vis = vis; + } + + getInjector() { + if (!this.injector) { + const mountpoint = document.createElement('div'); + mountpoint.setAttribute('style', 'height: 100%; width: 100%;'); + this.injector = angular.bootstrap(mountpoint, [innerAngularName]); + this.el.append(mountpoint); + } + + return this.injector; + } + + async initLocalAngular() { + if (!this.tableVisModule) { + const [coreStart] = await core.getStartServices(); + this.tableVisModule = getAngularModule(innerAngularName, coreStart, context); + initTableVisLegacyModule(this.tableVisModule); + } + } + + async render(esResponse: object, visParams: VisParams) { + await this.initLocalAngular(); + + return new Promise(async (resolve, reject) => { + if (!this.$rootScope) { + const $injector = this.getInjector(); + this.$rootScope = $injector.get('$rootScope'); + this.$compile = $injector.get('$compile'); + } + const updateScope = () => { + if (!this.$scope) { + return; + } + this.$scope.vis = this.vis; + this.$scope.visState = { params: visParams }; + this.$scope.esResponse = esResponse; + + this.$scope.visParams = visParams; + this.$scope.renderComplete = resolve; + this.$scope.renderFailed = reject; + this.$scope.resize = Date.now(); + this.$scope.$apply(); + }; + + if (!this.$scope && this.$compile) { + this.$scope = this.$rootScope.$new(); + this.$scope.uiState = this.vis.getUiState(); + updateScope(); + this.el.find('div').append(this.$compile(this.vis.type!.visConfig.template)(this.$scope)); + this.$scope.$apply(); + } else { + updateScope(); + } + }); + } + + destroy() { + if (this.$rootScope) { + this.$rootScope.$destroy(); + this.$rootScope = null; + } + } + }; +} diff --git a/src/plugins/timelion/public/index.ts b/src/plugins/vis_type_table/server/index.ts similarity index 69% rename from src/plugins/timelion/public/index.ts rename to src/plugins/vis_type_table/server/index.ts index b05c4f8a30b22..882958a28777d 100644 --- a/src/plugins/timelion/public/index.ts +++ b/src/plugins/vis_type_table/server/index.ts @@ -17,14 +17,18 @@ * under the License. */ -import { CoreStart, PluginInitializerContext } from 'kibana/public'; -import { ConfigSchema } from '../config'; +import { PluginConfigDescriptor } from 'kibana/server'; -export const plugin = (initializerContext: PluginInitializerContext) => ({ +import { configSchema, ConfigSchema } from '../config'; + +export const config: PluginConfigDescriptor = { + schema: configSchema, + deprecations: ({ renameFromRoot }) => [ + renameFromRoot('table_vis.enabled', 'vis_type_table.enabled'), + ], +}; + +export const plugin = () => ({ setup() {}, - start(core: CoreStart) { - if (initializerContext.config.get().ui.enabled === false) { - core.chrome.navLinks.update('timelion', { hidden: true }); - } - }, + start() {}, }); diff --git a/src/legacy/core_plugins/vis_type_timelion/README.md b/src/plugins/vis_type_timelion/README.md similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/README.md rename to src/plugins/vis_type_timelion/README.md diff --git a/src/plugins/timelion/common/chain.peg b/src/plugins/vis_type_timelion/common/chain.peg similarity index 100% rename from src/plugins/timelion/common/chain.peg rename to src/plugins/vis_type_timelion/common/chain.peg diff --git a/src/plugins/timelion/common/lib/calculate_interval.test.ts b/src/plugins/vis_type_timelion/common/lib/calculate_interval.test.ts similarity index 100% rename from src/plugins/timelion/common/lib/calculate_interval.test.ts rename to src/plugins/vis_type_timelion/common/lib/calculate_interval.test.ts diff --git a/src/plugins/timelion/common/lib/calculate_interval.ts b/src/plugins/vis_type_timelion/common/lib/calculate_interval.ts similarity index 100% rename from src/plugins/timelion/common/lib/calculate_interval.ts rename to src/plugins/vis_type_timelion/common/lib/calculate_interval.ts diff --git a/src/plugins/timelion/common/lib/index.ts b/src/plugins/vis_type_timelion/common/lib/index.ts similarity index 100% rename from src/plugins/timelion/common/lib/index.ts rename to src/plugins/vis_type_timelion/common/lib/index.ts diff --git a/src/plugins/timelion/common/lib/to_milliseconds.ts b/src/plugins/vis_type_timelion/common/lib/to_milliseconds.ts similarity index 100% rename from src/plugins/timelion/common/lib/to_milliseconds.ts rename to src/plugins/vis_type_timelion/common/lib/to_milliseconds.ts diff --git a/src/plugins/timelion/common/types.ts b/src/plugins/vis_type_timelion/common/types.ts similarity index 100% rename from src/plugins/timelion/common/types.ts rename to src/plugins/vis_type_timelion/common/types.ts diff --git a/src/plugins/timelion/config.ts b/src/plugins/vis_type_timelion/config.ts similarity index 100% rename from src/plugins/timelion/config.ts rename to src/plugins/vis_type_timelion/config.ts diff --git a/src/plugins/vis_type_timelion/kibana.json b/src/plugins/vis_type_timelion/kibana.json new file mode 100644 index 0000000000000..85c282c51a2e7 --- /dev/null +++ b/src/plugins/vis_type_timelion/kibana.json @@ -0,0 +1,8 @@ +{ + "id": "visTypeTimelion", + "version": "8.0.0", + "kibanaVersion": "kibana", + "server": true, + "ui": true, + "requiredPlugins": ["visualizations", "data", "expressions"] +} diff --git a/src/legacy/core_plugins/vis_type_timelion/public/_generated_/chain.js b/src/plugins/vis_type_timelion/public/_generated_/chain.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/_generated_/chain.js rename to src/plugins/vis_type_timelion/public/_generated_/chain.js diff --git a/src/legacy/core_plugins/vis_type_timelion/public/_timelion_editor.scss b/src/plugins/vis_type_timelion/public/_timelion_editor.scss similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/_timelion_editor.scss rename to src/plugins/vis_type_timelion/public/_timelion_editor.scss diff --git a/src/legacy/core_plugins/vis_type_timelion/public/_timelion_vis.scss b/src/plugins/vis_type_timelion/public/_timelion_vis.scss similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/_timelion_vis.scss rename to src/plugins/vis_type_timelion/public/_timelion_vis.scss diff --git a/src/plugins/vis_type_timelion/public/components/_index.scss b/src/plugins/vis_type_timelion/public/components/_index.scss new file mode 100644 index 0000000000000..707c9dafebe2b --- /dev/null +++ b/src/plugins/vis_type_timelion/public/components/_index.scss @@ -0,0 +1,2 @@ +@import 'panel'; +@import 'timelion_expression_input'; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/_panel.scss b/src/plugins/vis_type_timelion/public/components/_panel.scss similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/components/_panel.scss rename to src/plugins/vis_type_timelion/public/components/_panel.scss diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/_timelion_expression_input.scss b/src/plugins/vis_type_timelion/public/components/_timelion_expression_input.scss similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/components/_timelion_expression_input.scss rename to src/plugins/vis_type_timelion/public/components/_timelion_expression_input.scss diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/chart.tsx b/src/plugins/vis_type_timelion/public/components/chart.tsx similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/components/chart.tsx rename to src/plugins/vis_type_timelion/public/components/chart.tsx diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/index.ts b/src/plugins/vis_type_timelion/public/components/index.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/components/index.ts rename to src/plugins/vis_type_timelion/public/components/index.ts diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/panel.tsx b/src/plugins/vis_type_timelion/public/components/panel.tsx similarity index 98% rename from src/legacy/core_plugins/vis_type_timelion/public/components/panel.tsx rename to src/plugins/vis_type_timelion/public/components/panel.tsx index 3b42fa7dfcbb8..8f796526e8520 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/components/panel.tsx +++ b/src/plugins/vis_type_timelion/public/components/panel.tsx @@ -22,9 +22,9 @@ import $ from 'jquery'; import moment from 'moment-timezone'; import { debounce, compact, get, each, cloneDeep, last, map } from 'lodash'; -import { useKibana } from '../../../../../plugins/kibana_react/public'; +import { useKibana } from '../../../kibana_react/public'; import '../flot'; -import { DEFAULT_TIME_FORMAT } from '../../../../../plugins/timelion/common/lib'; +import { DEFAULT_TIME_FORMAT } from '../../common/lib'; import { buildSeriesData, diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_expression_input.tsx b/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx similarity index 96% rename from src/legacy/core_plugins/vis_type_timelion/public/components/timelion_expression_input.tsx rename to src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx index c317451b8201e..999409ef35063 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_expression_input.tsx +++ b/src/plugins/vis_type_timelion/public/components/timelion_expression_input.tsx @@ -22,13 +22,10 @@ import { EuiFormLabel } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { monaco } from '@kbn/ui-shared-deps/monaco'; -import { CodeEditor, useKibana } from '../../../../../plugins/kibana_react/public'; +import { CodeEditor, useKibana } from '../../../kibana_react/public'; import { suggest, getSuggestion } from './timelion_expression_input_helpers'; import { getArgValueSuggestions } from '../helpers/arg_value_suggestions'; -import { - ITimelionFunction, - TimelionFunctionArgs, -} from '../../../../../plugins/timelion/common/types'; +import { ITimelionFunction, TimelionFunctionArgs } from '../../common/types'; const LANGUAGE_ID = 'timelion_expression'; monaco.languages.register({ id: LANGUAGE_ID }); diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.test.ts b/src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.test.ts similarity index 99% rename from src/legacy/core_plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.test.ts rename to src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.test.ts index 2f99256e2a192..2ff6809d1c83d 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.test.ts +++ b/src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.test.ts @@ -22,7 +22,7 @@ import { getArgValueSuggestions } from '../helpers/arg_value_suggestions'; import { setIndexPatterns, setSavedObjectsClient } from '../helpers/plugin_services'; import { IndexPatternsContract } from 'src/plugins/data/public'; import { SavedObjectsClient } from 'kibana/public'; -import { ITimelionFunction } from '../../../../../plugins/timelion/common/types'; +import { ITimelionFunction } from '../../common/types'; describe('Timelion expression suggestions', () => { setIndexPatterns({} as IndexPatternsContract); diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts b/src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts similarity index 98% rename from src/legacy/core_plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts rename to src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts index 6f23c864419eb..04cb54306c90e 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts +++ b/src/plugins/vis_type_timelion/public/components/timelion_expression_input_helpers.ts @@ -27,10 +27,7 @@ import { Parser } from 'pegjs'; import { parse } from '../_generated_/chain'; import { ArgValueSuggestions, FunctionArg, Location } from '../helpers/arg_value_suggestions'; -import { - ITimelionFunction, - TimelionFunctionArgs, -} from '../../../../../plugins/timelion/common/types'; +import { ITimelionFunction, TimelionFunctionArgs } from '../../common/types'; export enum SUGGESTION_TYPE { ARGUMENTS = 'arguments', diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_interval.tsx b/src/plugins/vis_type_timelion/public/components/timelion_interval.tsx similarity index 96% rename from src/legacy/core_plugins/vis_type_timelion/public/components/timelion_interval.tsx rename to src/plugins/vis_type_timelion/public/components/timelion_interval.tsx index 8a8e1b22fb78d..985ecaeaf3e5a 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_interval.tsx +++ b/src/plugins/vis_type_timelion/public/components/timelion_interval.tsx @@ -21,9 +21,9 @@ import React, { useMemo, useCallback } from 'react'; import { EuiFormRow, EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { search } from '../../../../../plugins/data/public'; +import { search } from '../../../data/public'; const { isValidEsInterval } = search.aggs; -import { useValidation } from '../../../../../plugins/vis_default_editor/public'; +import { useValidation } from '../../../vis_default_editor/public'; const intervalOptions = [ { diff --git a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_vis.tsx b/src/plugins/vis_type_timelion/public/components/timelion_vis.tsx similarity index 95% rename from src/legacy/core_plugins/vis_type_timelion/public/components/timelion_vis.tsx rename to src/plugins/vis_type_timelion/public/components/timelion_vis.tsx index 0fad0a164bf0b..4bb07fe74ee82 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/components/timelion_vis.tsx +++ b/src/plugins/vis_type_timelion/public/components/timelion_vis.tsx @@ -23,7 +23,7 @@ import { IUiSettingsClient } from 'kibana/public'; import { ChartComponent } from './chart'; import { VisParams } from '../timelion_vis_fn'; import { TimelionSuccessResponse } from '../helpers/timelion_request_handler'; -import { ExprVis } from '../../../../../plugins/visualizations/public'; +import { ExprVis } from '../../../visualizations/public'; export interface TimelionVisComponentProp { config: IUiSettingsClient; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/flot.js b/src/plugins/vis_type_timelion/public/flot.js similarity index 72% rename from src/legacy/core_plugins/vis_type_timelion/public/flot.js rename to src/plugins/vis_type_timelion/public/flot.js index d6ca6d96c34ef..1ccb40c93a3d6 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/flot.js +++ b/src/plugins/vis_type_timelion/public/flot.js @@ -17,10 +17,10 @@ * under the License. */ -require('jquery.flot'); -require('jquery.flot.time'); -require('jquery.flot.symbol'); -require('jquery.flot.crosshair'); -require('jquery.flot.selection'); -require('jquery.flot.stack'); -require('jquery.flot.axislabels'); +import './webpackShims/jquery.flot'; +import './webpackShims/jquery.flot.time'; +import './webpackShims/jquery.flot.symbol'; +import './webpackShims/jquery.flot.crosshair'; +import './webpackShims/jquery.flot.selection'; +import './webpackShims/jquery.flot.stack'; +import './webpackShims/jquery.flot.axislabels'; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts b/src/plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts similarity index 97% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts rename to src/plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts index ea9532964d6fe..76c25b9b9e8de 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts +++ b/src/plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts @@ -19,11 +19,8 @@ import { get } from 'lodash'; import { getIndexPatterns, getSavedObjectsClient } from './plugin_services'; -import { TimelionFunctionArgs } from '../../../../../plugins/timelion/common/types'; -import { - indexPatterns as indexPatternsUtils, - IndexPatternAttributes, -} from '../../../../../plugins/data/public'; +import { TimelionFunctionArgs } from '../../common/types'; +import { indexPatterns as indexPatternsUtils, IndexPatternAttributes } from '../../../data/public'; export interface Location { min: number; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/get_timezone.ts b/src/plugins/vis_type_timelion/public/helpers/get_timezone.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/get_timezone.ts rename to src/plugins/vis_type_timelion/public/helpers/get_timezone.ts diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/panel_utils.ts b/src/plugins/vis_type_timelion/public/helpers/panel_utils.ts similarity index 98% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/panel_utils.ts rename to src/plugins/vis_type_timelion/public/helpers/panel_utils.ts index f932e5ee4b2f4..db29d9112be8e 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/helpers/panel_utils.ts +++ b/src/plugins/vis_type_timelion/public/helpers/panel_utils.ts @@ -23,7 +23,7 @@ import moment, { Moment } from 'moment-timezone'; import { TimefilterContract } from 'src/plugins/data/public'; import { IUiSettingsClient } from 'kibana/public'; -import { calculateInterval } from '../../../../../plugins/timelion/common/lib'; +import { calculateInterval } from '../../common/lib'; import { xaxisFormatterProvider } from './xaxis_formatter'; import { Series } from './timelion_request_handler'; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/plugin_services.ts b/src/plugins/vis_type_timelion/public/helpers/plugin_services.ts similarity index 93% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/plugin_services.ts rename to src/plugins/vis_type_timelion/public/helpers/plugin_services.ts index 5ba4ee5e47983..b055626934eea 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/helpers/plugin_services.ts +++ b/src/plugins/vis_type_timelion/public/helpers/plugin_services.ts @@ -19,7 +19,7 @@ import { IndexPatternsContract } from 'src/plugins/data/public'; import { SavedObjectsClientContract } from 'kibana/public'; -import { createGetterSetter } from '../../../../../plugins/kibana_utils/public'; +import { createGetterSetter } from '../../../kibana_utils/public'; export const [getIndexPatterns, setIndexPatterns] = createGetterSetter( 'IndexPatterns' diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/tick_formatters.test.ts b/src/plugins/vis_type_timelion/public/helpers/tick_formatters.test.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/tick_formatters.test.ts rename to src/plugins/vis_type_timelion/public/helpers/tick_formatters.test.ts diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/tick_formatters.ts b/src/plugins/vis_type_timelion/public/helpers/tick_formatters.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/tick_formatters.ts rename to src/plugins/vis_type_timelion/public/helpers/tick_formatters.ts diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/tick_generator.test.ts b/src/plugins/vis_type_timelion/public/helpers/tick_generator.test.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/tick_generator.test.ts rename to src/plugins/vis_type_timelion/public/helpers/tick_generator.test.ts diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/tick_generator.ts b/src/plugins/vis_type_timelion/public/helpers/tick_generator.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/tick_generator.ts rename to src/plugins/vis_type_timelion/public/helpers/tick_generator.ts diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/timelion_request_handler.ts b/src/plugins/vis_type_timelion/public/helpers/timelion_request_handler.ts similarity index 95% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/timelion_request_handler.ts rename to src/plugins/vis_type_timelion/public/helpers/timelion_request_handler.ts index 61e31420f73ba..a654f7935af5f 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/helpers/timelion_request_handler.ts +++ b/src/plugins/vis_type_timelion/public/helpers/timelion_request_handler.ts @@ -19,8 +19,8 @@ import { i18n } from '@kbn/i18n'; import { KIBANA_CONTEXT_NAME } from 'src/plugins/expressions/public'; -import { VisParams } from '../../../../../plugins/visualizations/public'; -import { TimeRange, Filter, esQuery, Query } from '../../../../../plugins/data/public'; +import { VisParams } from '../../../visualizations/public'; +import { TimeRange, Filter, esQuery, Query } from '../../../data/public'; import { TimelionVisDependencies } from '../plugin'; import { getTimezone } from './get_timezone'; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/helpers/xaxis_formatter.ts b/src/plugins/vis_type_timelion/public/helpers/xaxis_formatter.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/helpers/xaxis_formatter.ts rename to src/plugins/vis_type_timelion/public/helpers/xaxis_formatter.ts diff --git a/src/legacy/core_plugins/vis_type_timelion/public/index.scss b/src/plugins/vis_type_timelion/public/index.scss similarity index 59% rename from src/legacy/core_plugins/vis_type_timelion/public/index.scss rename to src/plugins/vis_type_timelion/public/index.scss index 313f14a8acf69..00e9a88520961 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/index.scss +++ b/src/plugins/vis_type_timelion/public/index.scss @@ -1,5 +1,3 @@ -@import 'src/legacy/ui/public/styles/styling_constants'; - @import './timelion_vis'; @import './timelion_editor'; @import './components/index'; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/index.ts b/src/plugins/vis_type_timelion/public/index.ts similarity index 90% rename from src/legacy/core_plugins/vis_type_timelion/public/index.ts rename to src/plugins/vis_type_timelion/public/index.ts index 6292e2ad3eb08..0aa5f3a810033 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/index.ts +++ b/src/plugins/vis_type_timelion/public/index.ts @@ -17,7 +17,7 @@ * under the License. */ -import { PluginInitializerContext } from '../../../../core/public'; +import { PluginInitializerContext } from 'kibana/public'; import { TimelionVisPlugin as Plugin } from './plugin'; export function plugin(initializerContext: PluginInitializerContext) { @@ -25,3 +25,5 @@ export function plugin(initializerContext: PluginInitializerContext) { } export { getTimezone } from './helpers/get_timezone'; + +export { VisTypeTimelionPluginStart } from './plugin'; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts b/src/plugins/vis_type_timelion/public/plugin.ts similarity index 67% rename from src/legacy/core_plugins/vis_type_timelion/public/plugin.ts rename to src/plugins/vis_type_timelion/public/plugin.ts index b5aa64db19aa4..060fec04deb3f 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/plugin.ts +++ b/src/plugins/vis_type_timelion/public/plugin.ts @@ -26,16 +26,21 @@ import { HttpSetup, } from 'kibana/public'; import { Plugin as ExpressionsPlugin } from 'src/plugins/expressions/public'; -import { DataPublicPluginSetup, TimefilterContract } from 'src/plugins/data/public'; +import { + DataPublicPluginSetup, + DataPublicPluginStart, + TimefilterContract, +} from 'src/plugins/data/public'; -import { PluginsStart } from './legacy_imports'; -import { VisualizationsSetup } from '../../../../plugins/visualizations/public'; +import { VisualizationsSetup } from '../../visualizations/public'; import { getTimelionVisualizationConfig } from './timelion_vis_fn'; import { getTimelionVisDefinition } from './timelion_vis_type'; import { setIndexPatterns, setSavedObjectsClient } from './helpers/plugin_services'; +import { ConfigSchema } from '../config'; -type TimelionVisCoreSetup = CoreSetup; +import './index.scss'; +import { getArgValueSuggestions } from './helpers/arg_value_suggestions'; /** @internal */ export interface TimelionVisDependencies extends Partial { @@ -52,11 +57,28 @@ export interface TimelionVisSetupDependencies { } /** @internal */ -export class TimelionVisPlugin implements Plugin { - constructor(public initializerContext: PluginInitializerContext) {} +export interface TimelionVisStartDependencies { + data: DataPublicPluginStart; +} + +/** @public */ +export interface VisTypeTimelionPluginStart { + getArgValueSuggestions: typeof getArgValueSuggestions; +} + +/** @internal */ +export class TimelionVisPlugin + implements + Plugin< + void, + VisTypeTimelionPluginStart, + TimelionVisSetupDependencies, + TimelionVisStartDependencies + > { + constructor(public initializerContext: PluginInitializerContext) {} - public async setup( - core: TimelionVisCoreSetup, + public setup( + core: CoreSetup, { expressions, visualizations, data }: TimelionVisSetupDependencies ) { const dependencies: TimelionVisDependencies = { @@ -69,8 +91,15 @@ export class TimelionVisPlugin implements Plugin { visualizations.createReactVisualization(getTimelionVisDefinition(dependencies)); } - public start(core: CoreStart, plugins: PluginsStart) { + public start(core: CoreStart, plugins: TimelionVisStartDependencies) { setIndexPatterns(plugins.data.indexPatterns); setSavedObjectsClient(core.savedObjects.client); + if (this.initializerContext.config.get().ui.enabled === false) { + core.chrome.navLinks.update('timelion', { hidden: true }); + } + + return { + getArgValueSuggestions, + }; } } diff --git a/src/legacy/core_plugins/vis_type_timelion/public/timelion_options.tsx b/src/plugins/vis_type_timelion/public/timelion_options.tsx similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/timelion_options.tsx rename to src/plugins/vis_type_timelion/public/timelion_options.tsx diff --git a/src/legacy/core_plugins/vis_type_timelion/public/timelion_vis_fn.ts b/src/plugins/vis_type_timelion/public/timelion_vis_fn.ts similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/timelion_vis_fn.ts rename to src/plugins/vis_type_timelion/public/timelion_vis_fn.ts diff --git a/src/legacy/core_plugins/vis_type_timelion/public/timelion_vis_type.tsx b/src/plugins/vis_type_timelion/public/timelion_vis_type.tsx similarity index 93% rename from src/legacy/core_plugins/vis_type_timelion/public/timelion_vis_type.tsx rename to src/plugins/vis_type_timelion/public/timelion_vis_type.tsx index 0900b7d898ede..52addb3c2d9d2 100644 --- a/src/legacy/core_plugins/vis_type_timelion/public/timelion_vis_type.tsx +++ b/src/plugins/vis_type_timelion/public/timelion_vis_type.tsx @@ -20,8 +20,8 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { KibanaContextProvider } from '../../../../plugins/kibana_react/public'; -import { DefaultEditorSize } from '../../../../plugins/vis_default_editor/public'; +import { KibanaContextProvider } from '../../kibana_react/public'; +import { DefaultEditorSize } from '../../vis_default_editor/public'; import { getTimelionRequestHandler } from './helpers/timelion_request_handler'; import { TimelionVisComponent, TimelionVisComponentProp } from './components'; import { TimelionOptions, TimelionOptionsProps } from './timelion_options'; diff --git a/src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.axislabels.js b/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.axislabels.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.axislabels.js rename to src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.axislabels.js diff --git a/src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.crosshair.js b/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.crosshair.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.crosshair.js rename to src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.crosshair.js diff --git a/src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.js b/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.js rename to src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.js diff --git a/src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.selection.js b/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.selection.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.selection.js rename to src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.selection.js diff --git a/src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.stack.js b/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.stack.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.stack.js rename to src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.stack.js diff --git a/src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.symbol.js b/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.symbol.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.symbol.js rename to src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.symbol.js diff --git a/src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.time.js b/src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.time.js similarity index 100% rename from src/legacy/core_plugins/vis_type_timelion/public/webpackShims/jquery.flot.time.js rename to src/plugins/vis_type_timelion/public/webpackShims/jquery.flot.time.js diff --git a/src/plugins/timelion/server/fit_functions/average.js b/src/plugins/vis_type_timelion/server/fit_functions/average.js similarity index 100% rename from src/plugins/timelion/server/fit_functions/average.js rename to src/plugins/vis_type_timelion/server/fit_functions/average.js diff --git a/src/plugins/timelion/server/fit_functions/average.test.js b/src/plugins/vis_type_timelion/server/fit_functions/average.test.js similarity index 100% rename from src/plugins/timelion/server/fit_functions/average.test.js rename to src/plugins/vis_type_timelion/server/fit_functions/average.test.js diff --git a/src/plugins/timelion/server/fit_functions/carry.js b/src/plugins/vis_type_timelion/server/fit_functions/carry.js similarity index 100% rename from src/plugins/timelion/server/fit_functions/carry.js rename to src/plugins/vis_type_timelion/server/fit_functions/carry.js diff --git a/src/plugins/timelion/server/fit_functions/carry.test.js b/src/plugins/vis_type_timelion/server/fit_functions/carry.test.js similarity index 100% rename from src/plugins/timelion/server/fit_functions/carry.test.js rename to src/plugins/vis_type_timelion/server/fit_functions/carry.test.js diff --git a/src/plugins/timelion/server/fit_functions/nearest.js b/src/plugins/vis_type_timelion/server/fit_functions/nearest.js similarity index 100% rename from src/plugins/timelion/server/fit_functions/nearest.js rename to src/plugins/vis_type_timelion/server/fit_functions/nearest.js diff --git a/src/plugins/timelion/server/fit_functions/none.js b/src/plugins/vis_type_timelion/server/fit_functions/none.js similarity index 100% rename from src/plugins/timelion/server/fit_functions/none.js rename to src/plugins/vis_type_timelion/server/fit_functions/none.js diff --git a/src/plugins/timelion/server/fit_functions/scale.js b/src/plugins/vis_type_timelion/server/fit_functions/scale.js similarity index 100% rename from src/plugins/timelion/server/fit_functions/scale.js rename to src/plugins/vis_type_timelion/server/fit_functions/scale.js diff --git a/src/plugins/timelion/server/handlers/chain_runner.js b/src/plugins/vis_type_timelion/server/handlers/chain_runner.js similarity index 100% rename from src/plugins/timelion/server/handlers/chain_runner.js rename to src/plugins/vis_type_timelion/server/handlers/chain_runner.js diff --git a/src/plugins/timelion/server/handlers/lib/arg_type.js b/src/plugins/vis_type_timelion/server/handlers/lib/arg_type.js similarity index 100% rename from src/plugins/timelion/server/handlers/lib/arg_type.js rename to src/plugins/vis_type_timelion/server/handlers/lib/arg_type.js diff --git a/src/plugins/timelion/server/handlers/lib/index_arguments.js b/src/plugins/vis_type_timelion/server/handlers/lib/index_arguments.js similarity index 100% rename from src/plugins/timelion/server/handlers/lib/index_arguments.js rename to src/plugins/vis_type_timelion/server/handlers/lib/index_arguments.js diff --git a/src/plugins/timelion/server/handlers/lib/parse_sheet.js b/src/plugins/vis_type_timelion/server/handlers/lib/parse_sheet.js similarity index 100% rename from src/plugins/timelion/server/handlers/lib/parse_sheet.js rename to src/plugins/vis_type_timelion/server/handlers/lib/parse_sheet.js diff --git a/src/plugins/timelion/server/handlers/lib/parse_sheet.test.js b/src/plugins/vis_type_timelion/server/handlers/lib/parse_sheet.test.js similarity index 100% rename from src/plugins/timelion/server/handlers/lib/parse_sheet.test.js rename to src/plugins/vis_type_timelion/server/handlers/lib/parse_sheet.test.js diff --git a/src/plugins/timelion/server/handlers/lib/preprocess_chain.js b/src/plugins/vis_type_timelion/server/handlers/lib/preprocess_chain.js similarity index 100% rename from src/plugins/timelion/server/handlers/lib/preprocess_chain.js rename to src/plugins/vis_type_timelion/server/handlers/lib/preprocess_chain.js diff --git a/src/plugins/timelion/server/handlers/lib/reposition_arguments.js b/src/plugins/vis_type_timelion/server/handlers/lib/reposition_arguments.js similarity index 100% rename from src/plugins/timelion/server/handlers/lib/reposition_arguments.js rename to src/plugins/vis_type_timelion/server/handlers/lib/reposition_arguments.js diff --git a/src/plugins/timelion/server/handlers/lib/tl_config.js b/src/plugins/vis_type_timelion/server/handlers/lib/tl_config.js similarity index 100% rename from src/plugins/timelion/server/handlers/lib/tl_config.js rename to src/plugins/vis_type_timelion/server/handlers/lib/tl_config.js diff --git a/src/plugins/timelion/server/handlers/lib/validate_arg.js b/src/plugins/vis_type_timelion/server/handlers/lib/validate_arg.js similarity index 100% rename from src/plugins/timelion/server/handlers/lib/validate_arg.js rename to src/plugins/vis_type_timelion/server/handlers/lib/validate_arg.js diff --git a/src/plugins/timelion/server/handlers/lib/validate_time.js b/src/plugins/vis_type_timelion/server/handlers/lib/validate_time.js similarity index 100% rename from src/plugins/timelion/server/handlers/lib/validate_time.js rename to src/plugins/vis_type_timelion/server/handlers/lib/validate_time.js diff --git a/src/plugins/timelion/server/index.ts b/src/plugins/vis_type_timelion/server/index.ts similarity index 64% rename from src/plugins/timelion/server/index.ts rename to src/plugins/vis_type_timelion/server/index.ts index 5d420327f961e..b40ab2af2b0d7 100644 --- a/src/plugins/timelion/server/index.ts +++ b/src/plugins/vis_type_timelion/server/index.ts @@ -17,19 +17,23 @@ * under the License. */ -import { PluginInitializerContext } from '../../../../src/core/server'; -import { configSchema } from '../config'; +import { PluginConfigDescriptor, PluginInitializerContext } from '../../../../src/core/server'; +import { configSchema, ConfigSchema } from '../config'; import { Plugin } from './plugin'; export { PluginSetupContract } from './plugin'; -export const config = { +export const config: PluginConfigDescriptor = { schema: configSchema, exposeToBrowser: { - ui: { - enabled: true, - }, + ui: true, }, + deprecations: ({ renameFromRoot }) => [ + renameFromRoot('timelion_vis.enabled', 'vis_type_timelion.enabled'), + renameFromRoot('timelion.enabled', 'vis_type_timelion.enabled'), + renameFromRoot('timelion.graphiteUrls', 'vis_type_timelion.graphiteUrls'), + renameFromRoot('timelion.ui.enabled', 'vis_type_timelion.ui.enabled'), + ], }; export const plugin = (initializerContext: PluginInitializerContext) => new Plugin(initializerContext); diff --git a/src/plugins/timelion/server/lib/alter.js b/src/plugins/vis_type_timelion/server/lib/alter.js similarity index 100% rename from src/plugins/timelion/server/lib/alter.js rename to src/plugins/vis_type_timelion/server/lib/alter.js diff --git a/src/plugins/timelion/server/lib/as_sorted.js b/src/plugins/vis_type_timelion/server/lib/as_sorted.js similarity index 100% rename from src/plugins/timelion/server/lib/as_sorted.js rename to src/plugins/vis_type_timelion/server/lib/as_sorted.js diff --git a/src/plugins/timelion/server/lib/build_target.js b/src/plugins/vis_type_timelion/server/lib/build_target.js similarity index 100% rename from src/plugins/timelion/server/lib/build_target.js rename to src/plugins/vis_type_timelion/server/lib/build_target.js diff --git a/src/plugins/timelion/server/lib/classes/chainable.js b/src/plugins/vis_type_timelion/server/lib/classes/chainable.js similarity index 100% rename from src/plugins/timelion/server/lib/classes/chainable.js rename to src/plugins/vis_type_timelion/server/lib/classes/chainable.js diff --git a/src/plugins/timelion/server/lib/classes/datasource.js b/src/plugins/vis_type_timelion/server/lib/classes/datasource.js similarity index 100% rename from src/plugins/timelion/server/lib/classes/datasource.js rename to src/plugins/vis_type_timelion/server/lib/classes/datasource.js diff --git a/src/plugins/timelion/server/lib/classes/timelion_function.d.ts b/src/plugins/vis_type_timelion/server/lib/classes/timelion_function.d.ts similarity index 100% rename from src/plugins/timelion/server/lib/classes/timelion_function.d.ts rename to src/plugins/vis_type_timelion/server/lib/classes/timelion_function.d.ts diff --git a/src/plugins/timelion/server/lib/classes/timelion_function.js b/src/plugins/vis_type_timelion/server/lib/classes/timelion_function.js similarity index 100% rename from src/plugins/timelion/server/lib/classes/timelion_function.js rename to src/plugins/vis_type_timelion/server/lib/classes/timelion_function.js diff --git a/src/plugins/timelion/server/lib/config_manager.ts b/src/plugins/vis_type_timelion/server/lib/config_manager.ts similarity index 100% rename from src/plugins/timelion/server/lib/config_manager.ts rename to src/plugins/vis_type_timelion/server/lib/config_manager.ts diff --git a/src/plugins/timelion/server/lib/functions_md.js b/src/plugins/vis_type_timelion/server/lib/functions_md.js similarity index 100% rename from src/plugins/timelion/server/lib/functions_md.js rename to src/plugins/vis_type_timelion/server/lib/functions_md.js diff --git a/src/plugins/timelion/server/lib/get_namespaced_settings.js b/src/plugins/vis_type_timelion/server/lib/get_namespaced_settings.js similarity index 100% rename from src/plugins/timelion/server/lib/get_namespaced_settings.js rename to src/plugins/vis_type_timelion/server/lib/get_namespaced_settings.js diff --git a/src/plugins/timelion/server/lib/load_functions.d.ts b/src/plugins/vis_type_timelion/server/lib/load_functions.d.ts similarity index 100% rename from src/plugins/timelion/server/lib/load_functions.d.ts rename to src/plugins/vis_type_timelion/server/lib/load_functions.d.ts diff --git a/src/plugins/timelion/server/lib/load_functions.js b/src/plugins/vis_type_timelion/server/lib/load_functions.js similarity index 100% rename from src/plugins/timelion/server/lib/load_functions.js rename to src/plugins/vis_type_timelion/server/lib/load_functions.js diff --git a/src/plugins/timelion/server/lib/load_functions.test.js b/src/plugins/vis_type_timelion/server/lib/load_functions.test.js similarity index 94% rename from src/plugins/timelion/server/lib/load_functions.test.js rename to src/plugins/vis_type_timelion/server/lib/load_functions.test.js index ebe1a04532e05..b4f83611a7773 100644 --- a/src/plugins/timelion/server/lib/load_functions.test.js +++ b/src/plugins/vis_type_timelion/server/lib/load_functions.test.js @@ -17,7 +17,7 @@ * under the License. */ -const fn = require(`src/plugins/timelion/server/lib/load_functions`); +const fn = require(`src/plugins/vis_type_timelion/server/lib/load_functions`); const expect = require('chai').expect; diff --git a/src/plugins/timelion/server/lib/offset_time.js b/src/plugins/vis_type_timelion/server/lib/offset_time.js similarity index 100% rename from src/plugins/timelion/server/lib/offset_time.js rename to src/plugins/vis_type_timelion/server/lib/offset_time.js diff --git a/src/plugins/timelion/server/lib/offset_time.test.js b/src/plugins/vis_type_timelion/server/lib/offset_time.test.js similarity index 100% rename from src/plugins/timelion/server/lib/offset_time.test.js rename to src/plugins/vis_type_timelion/server/lib/offset_time.test.js diff --git a/src/plugins/timelion/server/lib/process_function_definition.js b/src/plugins/vis_type_timelion/server/lib/process_function_definition.js similarity index 100% rename from src/plugins/timelion/server/lib/process_function_definition.js rename to src/plugins/vis_type_timelion/server/lib/process_function_definition.js diff --git a/src/plugins/timelion/server/lib/reduce.js b/src/plugins/vis_type_timelion/server/lib/reduce.js similarity index 100% rename from src/plugins/timelion/server/lib/reduce.js rename to src/plugins/vis_type_timelion/server/lib/reduce.js diff --git a/src/plugins/timelion/server/lib/split_interval.js b/src/plugins/vis_type_timelion/server/lib/split_interval.js similarity index 100% rename from src/plugins/timelion/server/lib/split_interval.js rename to src/plugins/vis_type_timelion/server/lib/split_interval.js diff --git a/src/plugins/timelion/server/lib/unzip_pairs.js b/src/plugins/vis_type_timelion/server/lib/unzip_pairs.js similarity index 100% rename from src/plugins/timelion/server/lib/unzip_pairs.js rename to src/plugins/vis_type_timelion/server/lib/unzip_pairs.js diff --git a/src/plugins/timelion/server/plugin.ts b/src/plugins/vis_type_timelion/server/plugin.ts similarity index 100% rename from src/plugins/timelion/server/plugin.ts rename to src/plugins/vis_type_timelion/server/plugin.ts diff --git a/src/plugins/timelion/server/routes/functions.ts b/src/plugins/vis_type_timelion/server/routes/functions.ts similarity index 100% rename from src/plugins/timelion/server/routes/functions.ts rename to src/plugins/vis_type_timelion/server/routes/functions.ts diff --git a/src/plugins/timelion/server/routes/run.ts b/src/plugins/vis_type_timelion/server/routes/run.ts similarity index 100% rename from src/plugins/timelion/server/routes/run.ts rename to src/plugins/vis_type_timelion/server/routes/run.ts diff --git a/src/plugins/timelion/server/routes/validate_es.ts b/src/plugins/vis_type_timelion/server/routes/validate_es.ts similarity index 100% rename from src/plugins/timelion/server/routes/validate_es.ts rename to src/plugins/vis_type_timelion/server/routes/validate_es.ts diff --git a/src/plugins/timelion/server/series_functions/abs.js b/src/plugins/vis_type_timelion/server/series_functions/abs.js similarity index 100% rename from src/plugins/timelion/server/series_functions/abs.js rename to src/plugins/vis_type_timelion/server/series_functions/abs.js diff --git a/src/plugins/timelion/server/series_functions/abs.test.js b/src/plugins/vis_type_timelion/server/series_functions/abs.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/abs.test.js rename to src/plugins/vis_type_timelion/server/series_functions/abs.test.js diff --git a/src/plugins/timelion/server/series_functions/aggregate/aggregate.test.js b/src/plugins/vis_type_timelion/server/series_functions/aggregate/aggregate.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/aggregate/aggregate.test.js rename to src/plugins/vis_type_timelion/server/series_functions/aggregate/aggregate.test.js diff --git a/src/plugins/timelion/server/series_functions/aggregate/avg.js b/src/plugins/vis_type_timelion/server/series_functions/aggregate/avg.js similarity index 100% rename from src/plugins/timelion/server/series_functions/aggregate/avg.js rename to src/plugins/vis_type_timelion/server/series_functions/aggregate/avg.js diff --git a/src/plugins/timelion/server/series_functions/aggregate/cardinality.js b/src/plugins/vis_type_timelion/server/series_functions/aggregate/cardinality.js similarity index 100% rename from src/plugins/timelion/server/series_functions/aggregate/cardinality.js rename to src/plugins/vis_type_timelion/server/series_functions/aggregate/cardinality.js diff --git a/src/plugins/timelion/server/series_functions/aggregate/first.js b/src/plugins/vis_type_timelion/server/series_functions/aggregate/first.js similarity index 100% rename from src/plugins/timelion/server/series_functions/aggregate/first.js rename to src/plugins/vis_type_timelion/server/series_functions/aggregate/first.js diff --git a/src/plugins/timelion/server/series_functions/aggregate/index.js b/src/plugins/vis_type_timelion/server/series_functions/aggregate/index.js similarity index 100% rename from src/plugins/timelion/server/series_functions/aggregate/index.js rename to src/plugins/vis_type_timelion/server/series_functions/aggregate/index.js diff --git a/src/plugins/timelion/server/series_functions/aggregate/last.js b/src/plugins/vis_type_timelion/server/series_functions/aggregate/last.js similarity index 100% rename from src/plugins/timelion/server/series_functions/aggregate/last.js rename to src/plugins/vis_type_timelion/server/series_functions/aggregate/last.js diff --git a/src/plugins/timelion/server/series_functions/aggregate/max.js b/src/plugins/vis_type_timelion/server/series_functions/aggregate/max.js similarity index 100% rename from src/plugins/timelion/server/series_functions/aggregate/max.js rename to src/plugins/vis_type_timelion/server/series_functions/aggregate/max.js diff --git a/src/plugins/timelion/server/series_functions/aggregate/min.js b/src/plugins/vis_type_timelion/server/series_functions/aggregate/min.js similarity index 100% rename from src/plugins/timelion/server/series_functions/aggregate/min.js rename to src/plugins/vis_type_timelion/server/series_functions/aggregate/min.js diff --git a/src/plugins/timelion/server/series_functions/aggregate/sum.js b/src/plugins/vis_type_timelion/server/series_functions/aggregate/sum.js similarity index 100% rename from src/plugins/timelion/server/series_functions/aggregate/sum.js rename to src/plugins/vis_type_timelion/server/series_functions/aggregate/sum.js diff --git a/src/plugins/timelion/server/series_functions/bars.js b/src/plugins/vis_type_timelion/server/series_functions/bars.js similarity index 100% rename from src/plugins/timelion/server/series_functions/bars.js rename to src/plugins/vis_type_timelion/server/series_functions/bars.js diff --git a/src/plugins/timelion/server/series_functions/bars.test.js b/src/plugins/vis_type_timelion/server/series_functions/bars.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/bars.test.js rename to src/plugins/vis_type_timelion/server/series_functions/bars.test.js diff --git a/src/plugins/timelion/server/series_functions/color.js b/src/plugins/vis_type_timelion/server/series_functions/color.js similarity index 100% rename from src/plugins/timelion/server/series_functions/color.js rename to src/plugins/vis_type_timelion/server/series_functions/color.js diff --git a/src/plugins/timelion/server/series_functions/color.test.js b/src/plugins/vis_type_timelion/server/series_functions/color.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/color.test.js rename to src/plugins/vis_type_timelion/server/series_functions/color.test.js diff --git a/src/plugins/timelion/server/series_functions/condition.js b/src/plugins/vis_type_timelion/server/series_functions/condition.js similarity index 100% rename from src/plugins/timelion/server/series_functions/condition.js rename to src/plugins/vis_type_timelion/server/series_functions/condition.js diff --git a/src/plugins/timelion/server/series_functions/condition.test.js b/src/plugins/vis_type_timelion/server/series_functions/condition.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/condition.test.js rename to src/plugins/vis_type_timelion/server/series_functions/condition.test.js diff --git a/src/plugins/timelion/server/series_functions/cusum.js b/src/plugins/vis_type_timelion/server/series_functions/cusum.js similarity index 100% rename from src/plugins/timelion/server/series_functions/cusum.js rename to src/plugins/vis_type_timelion/server/series_functions/cusum.js diff --git a/src/plugins/timelion/server/series_functions/cusum.test.js b/src/plugins/vis_type_timelion/server/series_functions/cusum.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/cusum.test.js rename to src/plugins/vis_type_timelion/server/series_functions/cusum.test.js diff --git a/src/plugins/timelion/server/series_functions/derivative.js b/src/plugins/vis_type_timelion/server/series_functions/derivative.js similarity index 100% rename from src/plugins/timelion/server/series_functions/derivative.js rename to src/plugins/vis_type_timelion/server/series_functions/derivative.js diff --git a/src/plugins/timelion/server/series_functions/derivative.test.js b/src/plugins/vis_type_timelion/server/series_functions/derivative.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/derivative.test.js rename to src/plugins/vis_type_timelion/server/series_functions/derivative.test.js diff --git a/src/plugins/timelion/server/series_functions/divide.js b/src/plugins/vis_type_timelion/server/series_functions/divide.js similarity index 100% rename from src/plugins/timelion/server/series_functions/divide.js rename to src/plugins/vis_type_timelion/server/series_functions/divide.js diff --git a/src/plugins/timelion/server/series_functions/divide.test.js b/src/plugins/vis_type_timelion/server/series_functions/divide.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/divide.test.js rename to src/plugins/vis_type_timelion/server/series_functions/divide.test.js diff --git a/src/plugins/timelion/server/series_functions/es/es.test.js b/src/plugins/vis_type_timelion/server/series_functions/es/es.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/es/es.test.js rename to src/plugins/vis_type_timelion/server/series_functions/es/es.test.js diff --git a/src/plugins/timelion/server/series_functions/es/index.js b/src/plugins/vis_type_timelion/server/series_functions/es/index.js similarity index 100% rename from src/plugins/timelion/server/series_functions/es/index.js rename to src/plugins/vis_type_timelion/server/series_functions/es/index.js diff --git a/src/plugins/timelion/server/series_functions/es/lib/agg_body.js b/src/plugins/vis_type_timelion/server/series_functions/es/lib/agg_body.js similarity index 100% rename from src/plugins/timelion/server/series_functions/es/lib/agg_body.js rename to src/plugins/vis_type_timelion/server/series_functions/es/lib/agg_body.js diff --git a/src/plugins/timelion/server/series_functions/es/lib/agg_response_to_series_list.js b/src/plugins/vis_type_timelion/server/series_functions/es/lib/agg_response_to_series_list.js similarity index 100% rename from src/plugins/timelion/server/series_functions/es/lib/agg_response_to_series_list.js rename to src/plugins/vis_type_timelion/server/series_functions/es/lib/agg_response_to_series_list.js diff --git a/src/plugins/timelion/server/series_functions/es/lib/build_request.js b/src/plugins/vis_type_timelion/server/series_functions/es/lib/build_request.js similarity index 100% rename from src/plugins/timelion/server/series_functions/es/lib/build_request.js rename to src/plugins/vis_type_timelion/server/series_functions/es/lib/build_request.js diff --git a/src/plugins/timelion/server/series_functions/es/lib/create_date_agg.js b/src/plugins/vis_type_timelion/server/series_functions/es/lib/create_date_agg.js similarity index 100% rename from src/plugins/timelion/server/series_functions/es/lib/create_date_agg.js rename to src/plugins/vis_type_timelion/server/series_functions/es/lib/create_date_agg.js diff --git a/src/plugins/timelion/server/series_functions/first.js b/src/plugins/vis_type_timelion/server/series_functions/first.js similarity index 100% rename from src/plugins/timelion/server/series_functions/first.js rename to src/plugins/vis_type_timelion/server/series_functions/first.js diff --git a/src/plugins/timelion/server/series_functions/first.test.js b/src/plugins/vis_type_timelion/server/series_functions/first.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/first.test.js rename to src/plugins/vis_type_timelion/server/series_functions/first.test.js diff --git a/src/plugins/timelion/server/series_functions/fit.js b/src/plugins/vis_type_timelion/server/series_functions/fit.js similarity index 100% rename from src/plugins/timelion/server/series_functions/fit.js rename to src/plugins/vis_type_timelion/server/series_functions/fit.js diff --git a/src/plugins/timelion/server/series_functions/fit.test.js b/src/plugins/vis_type_timelion/server/series_functions/fit.test.js similarity index 98% rename from src/plugins/timelion/server/series_functions/fit.test.js rename to src/plugins/vis_type_timelion/server/series_functions/fit.test.js index 75eaa2a50ea72..6622259a1fd87 100644 --- a/src/plugins/timelion/server/series_functions/fit.test.js +++ b/src/plugins/vis_type_timelion/server/series_functions/fit.test.js @@ -17,7 +17,7 @@ * under the License. */ -const fn = require(`src/plugins/timelion/server/series_functions/fit`); +const fn = require(`src/plugins/vis_type_timelion/server/series_functions/fit`); import moment from 'moment'; const expect = require('chai').expect; import invoke from './helpers/invoke_series_fn.js'; diff --git a/src/plugins/timelion/server/series_functions/fixtures/bucket_list.js b/src/plugins/vis_type_timelion/server/series_functions/fixtures/bucket_list.js similarity index 100% rename from src/plugins/timelion/server/series_functions/fixtures/bucket_list.js rename to src/plugins/vis_type_timelion/server/series_functions/fixtures/bucket_list.js diff --git a/src/plugins/timelion/server/series_functions/fixtures/es_response.js b/src/plugins/vis_type_timelion/server/series_functions/fixtures/es_response.js similarity index 100% rename from src/plugins/timelion/server/series_functions/fixtures/es_response.js rename to src/plugins/vis_type_timelion/server/series_functions/fixtures/es_response.js diff --git a/src/plugins/timelion/server/series_functions/fixtures/series_list.js b/src/plugins/vis_type_timelion/server/series_functions/fixtures/series_list.js similarity index 100% rename from src/plugins/timelion/server/series_functions/fixtures/series_list.js rename to src/plugins/vis_type_timelion/server/series_functions/fixtures/series_list.js diff --git a/src/plugins/timelion/server/series_functions/fixtures/tl_config.js b/src/plugins/vis_type_timelion/server/series_functions/fixtures/tl_config.js similarity index 100% rename from src/plugins/timelion/server/series_functions/fixtures/tl_config.js rename to src/plugins/vis_type_timelion/server/series_functions/fixtures/tl_config.js diff --git a/src/plugins/timelion/server/series_functions/graphite.js b/src/plugins/vis_type_timelion/server/series_functions/graphite.js similarity index 100% rename from src/plugins/timelion/server/series_functions/graphite.js rename to src/plugins/vis_type_timelion/server/series_functions/graphite.js diff --git a/src/plugins/timelion/server/series_functions/graphite.test.js b/src/plugins/vis_type_timelion/server/series_functions/graphite.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/graphite.test.js rename to src/plugins/vis_type_timelion/server/series_functions/graphite.test.js diff --git a/src/plugins/timelion/server/series_functions/helpers/get_series.js b/src/plugins/vis_type_timelion/server/series_functions/helpers/get_series.js similarity index 100% rename from src/plugins/timelion/server/series_functions/helpers/get_series.js rename to src/plugins/vis_type_timelion/server/series_functions/helpers/get_series.js diff --git a/src/plugins/timelion/server/series_functions/helpers/get_series_list.js b/src/plugins/vis_type_timelion/server/series_functions/helpers/get_series_list.js similarity index 100% rename from src/plugins/timelion/server/series_functions/helpers/get_series_list.js rename to src/plugins/vis_type_timelion/server/series_functions/helpers/get_series_list.js diff --git a/src/plugins/timelion/server/series_functions/helpers/get_single_series_list.js b/src/plugins/vis_type_timelion/server/series_functions/helpers/get_single_series_list.js similarity index 100% rename from src/plugins/timelion/server/series_functions/helpers/get_single_series_list.js rename to src/plugins/vis_type_timelion/server/series_functions/helpers/get_single_series_list.js diff --git a/src/plugins/timelion/server/series_functions/helpers/invoke_series_fn.js b/src/plugins/vis_type_timelion/server/series_functions/helpers/invoke_series_fn.js similarity index 100% rename from src/plugins/timelion/server/series_functions/helpers/invoke_series_fn.js rename to src/plugins/vis_type_timelion/server/series_functions/helpers/invoke_series_fn.js diff --git a/src/plugins/timelion/server/series_functions/hide.js b/src/plugins/vis_type_timelion/server/series_functions/hide.js similarity index 100% rename from src/plugins/timelion/server/series_functions/hide.js rename to src/plugins/vis_type_timelion/server/series_functions/hide.js diff --git a/src/plugins/timelion/server/series_functions/hide.test.js b/src/plugins/vis_type_timelion/server/series_functions/hide.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/hide.test.js rename to src/plugins/vis_type_timelion/server/series_functions/hide.test.js diff --git a/src/plugins/timelion/server/series_functions/holt/index.js b/src/plugins/vis_type_timelion/server/series_functions/holt/index.js similarity index 100% rename from src/plugins/timelion/server/series_functions/holt/index.js rename to src/plugins/vis_type_timelion/server/series_functions/holt/index.js diff --git a/src/plugins/timelion/server/series_functions/holt/lib/des.js b/src/plugins/vis_type_timelion/server/series_functions/holt/lib/des.js similarity index 100% rename from src/plugins/timelion/server/series_functions/holt/lib/des.js rename to src/plugins/vis_type_timelion/server/series_functions/holt/lib/des.js diff --git a/src/plugins/timelion/server/series_functions/holt/lib/ses.js b/src/plugins/vis_type_timelion/server/series_functions/holt/lib/ses.js similarity index 100% rename from src/plugins/timelion/server/series_functions/holt/lib/ses.js rename to src/plugins/vis_type_timelion/server/series_functions/holt/lib/ses.js diff --git a/src/plugins/timelion/server/series_functions/holt/lib/tes.js b/src/plugins/vis_type_timelion/server/series_functions/holt/lib/tes.js similarity index 100% rename from src/plugins/timelion/server/series_functions/holt/lib/tes.js rename to src/plugins/vis_type_timelion/server/series_functions/holt/lib/tes.js diff --git a/src/plugins/timelion/server/series_functions/label.js b/src/plugins/vis_type_timelion/server/series_functions/label.js similarity index 100% rename from src/plugins/timelion/server/series_functions/label.js rename to src/plugins/vis_type_timelion/server/series_functions/label.js diff --git a/src/plugins/timelion/server/series_functions/label.test.js b/src/plugins/vis_type_timelion/server/series_functions/label.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/label.test.js rename to src/plugins/vis_type_timelion/server/series_functions/label.test.js diff --git a/src/plugins/timelion/server/series_functions/legend.js b/src/plugins/vis_type_timelion/server/series_functions/legend.js similarity index 100% rename from src/plugins/timelion/server/series_functions/legend.js rename to src/plugins/vis_type_timelion/server/series_functions/legend.js diff --git a/src/plugins/timelion/server/series_functions/legend.test.js b/src/plugins/vis_type_timelion/server/series_functions/legend.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/legend.test.js rename to src/plugins/vis_type_timelion/server/series_functions/legend.test.js diff --git a/src/plugins/timelion/server/series_functions/lines.js b/src/plugins/vis_type_timelion/server/series_functions/lines.js similarity index 100% rename from src/plugins/timelion/server/series_functions/lines.js rename to src/plugins/vis_type_timelion/server/series_functions/lines.js diff --git a/src/plugins/timelion/server/series_functions/lines.test.js b/src/plugins/vis_type_timelion/server/series_functions/lines.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/lines.test.js rename to src/plugins/vis_type_timelion/server/series_functions/lines.test.js diff --git a/src/plugins/timelion/server/series_functions/log.js b/src/plugins/vis_type_timelion/server/series_functions/log.js similarity index 100% rename from src/plugins/timelion/server/series_functions/log.js rename to src/plugins/vis_type_timelion/server/series_functions/log.js diff --git a/src/plugins/timelion/server/series_functions/log.test.js b/src/plugins/vis_type_timelion/server/series_functions/log.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/log.test.js rename to src/plugins/vis_type_timelion/server/series_functions/log.test.js diff --git a/src/plugins/timelion/server/series_functions/max.js b/src/plugins/vis_type_timelion/server/series_functions/max.js similarity index 100% rename from src/plugins/timelion/server/series_functions/max.js rename to src/plugins/vis_type_timelion/server/series_functions/max.js diff --git a/src/plugins/timelion/server/series_functions/max.test.js b/src/plugins/vis_type_timelion/server/series_functions/max.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/max.test.js rename to src/plugins/vis_type_timelion/server/series_functions/max.test.js diff --git a/src/plugins/timelion/server/series_functions/min.js b/src/plugins/vis_type_timelion/server/series_functions/min.js similarity index 100% rename from src/plugins/timelion/server/series_functions/min.js rename to src/plugins/vis_type_timelion/server/series_functions/min.js diff --git a/src/plugins/timelion/server/series_functions/min.test.js b/src/plugins/vis_type_timelion/server/series_functions/min.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/min.test.js rename to src/plugins/vis_type_timelion/server/series_functions/min.test.js diff --git a/src/plugins/timelion/server/series_functions/movingaverage.js b/src/plugins/vis_type_timelion/server/series_functions/movingaverage.js similarity index 100% rename from src/plugins/timelion/server/series_functions/movingaverage.js rename to src/plugins/vis_type_timelion/server/series_functions/movingaverage.js diff --git a/src/plugins/timelion/server/series_functions/movingaverage.test.js b/src/plugins/vis_type_timelion/server/series_functions/movingaverage.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/movingaverage.test.js rename to src/plugins/vis_type_timelion/server/series_functions/movingaverage.test.js diff --git a/src/plugins/timelion/server/series_functions/movingstd.js b/src/plugins/vis_type_timelion/server/series_functions/movingstd.js similarity index 100% rename from src/plugins/timelion/server/series_functions/movingstd.js rename to src/plugins/vis_type_timelion/server/series_functions/movingstd.js diff --git a/src/plugins/timelion/server/series_functions/movingstd.test.js b/src/plugins/vis_type_timelion/server/series_functions/movingstd.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/movingstd.test.js rename to src/plugins/vis_type_timelion/server/series_functions/movingstd.test.js diff --git a/src/plugins/timelion/server/series_functions/multiply.js b/src/plugins/vis_type_timelion/server/series_functions/multiply.js similarity index 100% rename from src/plugins/timelion/server/series_functions/multiply.js rename to src/plugins/vis_type_timelion/server/series_functions/multiply.js diff --git a/src/plugins/timelion/server/series_functions/multiply.test.js b/src/plugins/vis_type_timelion/server/series_functions/multiply.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/multiply.test.js rename to src/plugins/vis_type_timelion/server/series_functions/multiply.test.js diff --git a/src/plugins/timelion/server/series_functions/points.js b/src/plugins/vis_type_timelion/server/series_functions/points.js similarity index 100% rename from src/plugins/timelion/server/series_functions/points.js rename to src/plugins/vis_type_timelion/server/series_functions/points.js diff --git a/src/plugins/timelion/server/series_functions/points.test.js b/src/plugins/vis_type_timelion/server/series_functions/points.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/points.test.js rename to src/plugins/vis_type_timelion/server/series_functions/points.test.js diff --git a/src/plugins/timelion/server/series_functions/precision.js b/src/plugins/vis_type_timelion/server/series_functions/precision.js similarity index 100% rename from src/plugins/timelion/server/series_functions/precision.js rename to src/plugins/vis_type_timelion/server/series_functions/precision.js diff --git a/src/plugins/timelion/server/series_functions/precision.test.js b/src/plugins/vis_type_timelion/server/series_functions/precision.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/precision.test.js rename to src/plugins/vis_type_timelion/server/series_functions/precision.test.js diff --git a/src/plugins/timelion/server/series_functions/props.js b/src/plugins/vis_type_timelion/server/series_functions/props.js similarity index 100% rename from src/plugins/timelion/server/series_functions/props.js rename to src/plugins/vis_type_timelion/server/series_functions/props.js diff --git a/src/plugins/timelion/server/series_functions/quandl.js b/src/plugins/vis_type_timelion/server/series_functions/quandl.js similarity index 100% rename from src/plugins/timelion/server/series_functions/quandl.js rename to src/plugins/vis_type_timelion/server/series_functions/quandl.js diff --git a/src/plugins/timelion/server/series_functions/quandl.test.js b/src/plugins/vis_type_timelion/server/series_functions/quandl.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/quandl.test.js rename to src/plugins/vis_type_timelion/server/series_functions/quandl.test.js diff --git a/src/plugins/timelion/server/series_functions/range.js b/src/plugins/vis_type_timelion/server/series_functions/range.js similarity index 100% rename from src/plugins/timelion/server/series_functions/range.js rename to src/plugins/vis_type_timelion/server/series_functions/range.js diff --git a/src/plugins/timelion/server/series_functions/range.test.js b/src/plugins/vis_type_timelion/server/series_functions/range.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/range.test.js rename to src/plugins/vis_type_timelion/server/series_functions/range.test.js diff --git a/src/plugins/timelion/server/series_functions/scale_interval.js b/src/plugins/vis_type_timelion/server/series_functions/scale_interval.js similarity index 100% rename from src/plugins/timelion/server/series_functions/scale_interval.js rename to src/plugins/vis_type_timelion/server/series_functions/scale_interval.js diff --git a/src/plugins/timelion/server/series_functions/scale_interval.test.js b/src/plugins/vis_type_timelion/server/series_functions/scale_interval.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/scale_interval.test.js rename to src/plugins/vis_type_timelion/server/series_functions/scale_interval.test.js diff --git a/src/plugins/timelion/server/series_functions/static.js b/src/plugins/vis_type_timelion/server/series_functions/static.js similarity index 100% rename from src/plugins/timelion/server/series_functions/static.js rename to src/plugins/vis_type_timelion/server/series_functions/static.js diff --git a/src/plugins/timelion/server/series_functions/static.test.js b/src/plugins/vis_type_timelion/server/series_functions/static.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/static.test.js rename to src/plugins/vis_type_timelion/server/series_functions/static.test.js diff --git a/src/plugins/timelion/server/series_functions/subtract.js b/src/plugins/vis_type_timelion/server/series_functions/subtract.js similarity index 100% rename from src/plugins/timelion/server/series_functions/subtract.js rename to src/plugins/vis_type_timelion/server/series_functions/subtract.js diff --git a/src/plugins/timelion/server/series_functions/subtract.test.js b/src/plugins/vis_type_timelion/server/series_functions/subtract.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/subtract.test.js rename to src/plugins/vis_type_timelion/server/series_functions/subtract.test.js diff --git a/src/plugins/timelion/server/series_functions/sum.js b/src/plugins/vis_type_timelion/server/series_functions/sum.js similarity index 100% rename from src/plugins/timelion/server/series_functions/sum.js rename to src/plugins/vis_type_timelion/server/series_functions/sum.js diff --git a/src/plugins/timelion/server/series_functions/sum.test.js b/src/plugins/vis_type_timelion/server/series_functions/sum.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/sum.test.js rename to src/plugins/vis_type_timelion/server/series_functions/sum.test.js diff --git a/src/plugins/timelion/server/series_functions/title.js b/src/plugins/vis_type_timelion/server/series_functions/title.js similarity index 100% rename from src/plugins/timelion/server/series_functions/title.js rename to src/plugins/vis_type_timelion/server/series_functions/title.js diff --git a/src/plugins/timelion/server/series_functions/title.test.js b/src/plugins/vis_type_timelion/server/series_functions/title.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/title.test.js rename to src/plugins/vis_type_timelion/server/series_functions/title.test.js diff --git a/src/plugins/timelion/server/series_functions/trend/index.js b/src/plugins/vis_type_timelion/server/series_functions/trend/index.js similarity index 100% rename from src/plugins/timelion/server/series_functions/trend/index.js rename to src/plugins/vis_type_timelion/server/series_functions/trend/index.js diff --git a/src/plugins/timelion/server/series_functions/trend/lib/regress.js b/src/plugins/vis_type_timelion/server/series_functions/trend/lib/regress.js similarity index 100% rename from src/plugins/timelion/server/series_functions/trend/lib/regress.js rename to src/plugins/vis_type_timelion/server/series_functions/trend/lib/regress.js diff --git a/src/plugins/timelion/server/series_functions/trim.js b/src/plugins/vis_type_timelion/server/series_functions/trim.js similarity index 100% rename from src/plugins/timelion/server/series_functions/trim.js rename to src/plugins/vis_type_timelion/server/series_functions/trim.js diff --git a/src/plugins/timelion/server/series_functions/trim.test.js b/src/plugins/vis_type_timelion/server/series_functions/trim.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/trim.test.js rename to src/plugins/vis_type_timelion/server/series_functions/trim.test.js diff --git a/src/plugins/timelion/server/series_functions/worldbank.js b/src/plugins/vis_type_timelion/server/series_functions/worldbank.js similarity index 100% rename from src/plugins/timelion/server/series_functions/worldbank.js rename to src/plugins/vis_type_timelion/server/series_functions/worldbank.js diff --git a/src/plugins/timelion/server/series_functions/worldbank_indicators.js b/src/plugins/vis_type_timelion/server/series_functions/worldbank_indicators.js similarity index 100% rename from src/plugins/timelion/server/series_functions/worldbank_indicators.js rename to src/plugins/vis_type_timelion/server/series_functions/worldbank_indicators.js diff --git a/src/plugins/timelion/server/series_functions/yaxis.js b/src/plugins/vis_type_timelion/server/series_functions/yaxis.js similarity index 100% rename from src/plugins/timelion/server/series_functions/yaxis.js rename to src/plugins/vis_type_timelion/server/series_functions/yaxis.js diff --git a/src/plugins/timelion/server/series_functions/yaxis.test.js b/src/plugins/vis_type_timelion/server/series_functions/yaxis.test.js similarity index 100% rename from src/plugins/timelion/server/series_functions/yaxis.test.js rename to src/plugins/vis_type_timelion/server/series_functions/yaxis.test.js diff --git a/src/plugins/timelion/server/timelion.json b/src/plugins/vis_type_timelion/server/timelion.json similarity index 100% rename from src/plugins/timelion/server/timelion.json rename to src/plugins/vis_type_timelion/server/timelion.json diff --git a/src/plugins/timelion/server/types.ts b/src/plugins/vis_type_timelion/server/types.ts similarity index 100% rename from src/plugins/timelion/server/types.ts rename to src/plugins/vis_type_timelion/server/types.ts diff --git a/src/plugins/vis_type_timeseries/kibana.json b/src/plugins/vis_type_timeseries/kibana.json index 38662c6a7ff89..9053d2543e0d0 100644 --- a/src/plugins/vis_type_timeseries/kibana.json +++ b/src/plugins/vis_type_timeseries/kibana.json @@ -4,6 +4,6 @@ "kibanaVersion": "kibana", "server": true, "ui": true, - "requiredPlugins": ["data", "expressions", "visualizations"], + "requiredPlugins": ["charts", "data", "expressions", "visualizations"], "optionalPlugins": ["usageCollection"] } diff --git a/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js b/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js index 024f59c3abb1c..d29b795b10ec8 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js +++ b/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js @@ -53,7 +53,7 @@ export const TimeseriesConfig = injectI18n(function(props) { point_size: '', value_template: '{{value}}', offset_time: '', - split_color_mode: 'gradient', + split_color_mode: 'kibana', axis_min: '', axis_max: '', stacked: STACKED_OPTIONS.NONE, @@ -140,10 +140,10 @@ export const TimeseriesConfig = injectI18n(function(props) { const splitColorOptions = [ { label: intl.formatMessage({ - id: 'visTypeTimeseries.timeSeries.gradientLabel', - defaultMessage: 'Gradient', + id: 'visTypeTimeseries.timeSeries.defaultPaletteLabel', + defaultMessage: 'Default palette', }), - value: 'gradient', + value: 'kibana', }, { label: intl.formatMessage({ @@ -152,6 +152,13 @@ export const TimeseriesConfig = injectI18n(function(props) { }), value: 'rainbow', }, + { + label: intl.formatMessage({ + id: 'visTypeTimeseries.timeSeries.gradientLabel', + defaultMessage: 'Gradient', + }), + value: 'gradient', + }, ]; const selectedSplitColorOption = splitColorOptions.find(option => { return model.split_color_mode === option.value; diff --git a/src/plugins/vis_type_timeseries/public/application/visualizations/views/timeseries/index.js b/src/plugins/vis_type_timeseries/public/application/visualizations/views/timeseries/index.js index b1c3c7ac6b67a..5cf1619150e5c 100644 --- a/src/plugins/vis_type_timeseries/public/application/visualizations/views/timeseries/index.js +++ b/src/plugins/vis_type_timeseries/public/application/visualizations/views/timeseries/index.js @@ -33,7 +33,7 @@ import { import { EuiIcon } from '@elastic/eui'; import { getTimezone } from '../../../lib/get_timezone'; import { eventBus, ACTIVE_CURSOR } from '../../lib/active_cursor'; -import { getUISettings } from '../../../../services'; +import { getUISettings, getChartsSetup } from '../../../../services'; import { GRID_LINE_CONFIG, ICON_TYPES_MAP, STACKED_OPTIONS } from '../../constants'; import { AreaSeriesDecorator } from './decorators/area_decorator'; import { BarSeriesDecorator } from './decorators/bar_decorator'; @@ -94,6 +94,12 @@ export const TimeSeries = ({ // apply legend style change if bgColor is configured const classes = classNames('tvbVisTimeSeries', getChartClasses(backgroundColor)); + // If the color isn't configured by the user, use the color mapping service + // to assign a color from the Kibana palette. Colors will be shared across the + // session, including dashboards. + const { colors } = getChartsSetup(); + colors.mappedColors.mapKeys(series.filter(({ color }) => !color).map(({ label }) => label)); + return ( ; visualizations: VisualizationsSetup; + charts: ChartsPluginSetup; } /** @internal */ @@ -56,10 +59,11 @@ export class MetricsPlugin implements Plugin, void> { public async setup( core: CoreSetup, - { expressions, visualizations }: MetricsPluginSetupDependencies + { expressions, visualizations, charts }: MetricsPluginSetupDependencies ) { expressions.registerFunction(createMetricsFn); setUISettings(core.uiSettings); + setChartsSetup(charts); visualizations.createReactVisualization(metricsVisDefinition); } diff --git a/src/plugins/vis_type_timeseries/public/services.ts b/src/plugins/vis_type_timeseries/public/services.ts index d93a376584eac..9aa84478fb78b 100644 --- a/src/plugins/vis_type_timeseries/public/services.ts +++ b/src/plugins/vis_type_timeseries/public/services.ts @@ -19,6 +19,7 @@ import { I18nStart, SavedObjectsStart, IUiSettingsClient, CoreStart } from 'src/core/public'; import { createGetterSetter } from '../../kibana_utils/public'; +import { ChartsPluginSetup } from '../../charts/public'; import { DataPublicPluginStart } from '../../data/public'; export const [getUISettings, setUISettings] = createGetterSetter('UISettings'); @@ -36,3 +37,7 @@ export const [getCoreStart, setCoreStart] = createGetterSetter('CoreS export const [getDataStart, setDataStart] = createGetterSetter('DataStart'); export const [getI18n, setI18n] = createGetterSetter('I18n'); + +export const [getChartsSetup, setChartsSetup] = createGetterSetter( + 'ChartsPluginSetup' +); diff --git a/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_split_colors.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_split_colors.js index ff8d9077b0871..cad8c8f2025a1 100644 --- a/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_split_colors.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_split_colors.js @@ -19,7 +19,7 @@ import Color from 'color'; -export function getSplitColors(inputColor, size = 10, style = 'gradient') { +export function getSplitColors(inputColor, size = 10, style = 'kibana') { const color = new Color(inputColor); const colors = []; let workingColor = Color.hsl(color.hsl().object()); @@ -49,7 +49,7 @@ export function getSplitColors(inputColor, size = 10, style = 'gradient') { '#0F1419', '#666666', ]; - } else { + } else if (style === 'gradient') { colors.push(color.string()); const rotateBy = color.luminosity() / (size - 1); for (let i = 0; i < size - 1; i++) { diff --git a/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.test.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.test.js index 0874d944033f5..376d32d0da13f 100644 --- a/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.test.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_splits.test.js @@ -106,7 +106,7 @@ describe('getSplits(resp, panel, series)', () => { ]); }); - test('should return a splits for terms group bys', () => { + describe('terms group bys', () => { const resp = { aggregations: { SERIES: { @@ -126,38 +126,89 @@ describe('getSplits(resp, panel, series)', () => { }, }, }; - const series = { - id: 'SERIES', - color: '#F00', - split_mode: 'terms', - terms_field: 'beat.hostname', - terms_size: 10, - metrics: [ - { id: 'AVG', type: 'avg', field: 'cpu' }, - { id: 'SIBAGG', type: 'avg_bucket', field: 'AVG' }, - ], - }; - const panel = { type: 'timeseries' }; - expect(getSplits(resp, panel, series)).toEqual([ - { - id: 'SERIES:example-01', - key: 'example-01', - label: 'example-01', - meta: { bucketSize: 10 }, - color: 'rgb(255, 0, 0)', - timeseries: { buckets: [] }, - SIBAGG: { value: 1 }, - }, - { - id: 'SERIES:example-02', - key: 'example-02', - label: 'example-02', - meta: { bucketSize: 10 }, - color: 'rgb(147, 0, 0)', - timeseries: { buckets: [] }, - SIBAGG: { value: 2 }, - }, - ]); + + test('should return a splits with no color', () => { + const series = { + id: 'SERIES', + color: '#F00', + split_mode: 'terms', + terms_field: 'beat.hostname', + terms_size: 10, + metrics: [ + { id: 'AVG', type: 'avg', field: 'cpu' }, + { id: 'SIBAGG', type: 'avg_bucket', field: 'AVG' }, + ], + }; + const panel = { type: 'timeseries' }; + expect(getSplits(resp, panel, series)).toEqual([ + { + id: 'SERIES:example-01', + key: 'example-01', + label: 'example-01', + meta: { bucketSize: 10 }, + color: undefined, + timeseries: { buckets: [] }, + SIBAGG: { value: 1 }, + }, + { + id: 'SERIES:example-02', + key: 'example-02', + label: 'example-02', + meta: { bucketSize: 10 }, + color: undefined, + timeseries: { buckets: [] }, + SIBAGG: { value: 2 }, + }, + ]); + }); + + test('should return gradient color', () => { + const series = { + id: 'SERIES', + color: '#F00', + split_mode: 'terms', + split_color_mode: 'gradient', + terms_field: 'beat.hostname', + terms_size: 10, + metrics: [ + { id: 'AVG', type: 'avg', field: 'cpu' }, + { id: 'SIBAGG', type: 'avg_bucket', field: 'AVG' }, + ], + }; + const panel = { type: 'timeseries' }; + expect(getSplits(resp, panel, series)).toEqual([ + expect.objectContaining({ + color: 'rgb(255, 0, 0)', + }), + expect.objectContaining({ + color: 'rgb(147, 0, 0)', + }), + ]); + }); + + test('should return rainbow color', () => { + const series = { + id: 'SERIES', + color: '#F00', + split_mode: 'terms', + split_color_mode: 'rainbow', + terms_field: 'beat.hostname', + terms_size: 10, + metrics: [ + { id: 'AVG', type: 'avg', field: 'cpu' }, + { id: 'SIBAGG', type: 'avg_bucket', field: 'AVG' }, + ], + }; + const panel = { type: 'timeseries' }; + expect(getSplits(resp, panel, series)).toEqual([ + expect.objectContaining({ + color: '#68BC00', + }), + expect.objectContaining({ + color: '#009CE0', + }), + ]); + }); }); test('should return a splits for filters group bys', () => { diff --git a/src/plugins/vis_type_timeseries/server/saved_objects/index.ts b/src/plugins/vis_type_timeseries/server/saved_objects/index.ts new file mode 100644 index 0000000000000..5f7f5767f423d --- /dev/null +++ b/src/plugins/vis_type_timeseries/server/saved_objects/index.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export { tsvbTelemetrySavedObjectType } from './tsvb_telemetry'; diff --git a/src/plugins/vis_type_timeseries/server/validation_telemetry/saved_object_type.ts b/src/plugins/vis_type_timeseries/server/saved_objects/tsvb_telemetry.ts similarity index 97% rename from src/plugins/vis_type_timeseries/server/validation_telemetry/saved_object_type.ts rename to src/plugins/vis_type_timeseries/server/saved_objects/tsvb_telemetry.ts index 77b49e824334f..f18fa1e4cc2fa 100644 --- a/src/plugins/vis_type_timeseries/server/validation_telemetry/saved_object_type.ts +++ b/src/plugins/vis_type_timeseries/server/saved_objects/tsvb_telemetry.ts @@ -31,7 +31,7 @@ const resetCount: SavedObjectMigrationFn = doc => ({ export const tsvbTelemetrySavedObjectType: SavedObjectsType = { name: 'tsvb-validation-telemetry', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { failedRequests: { diff --git a/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts b/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts index 779d9441df2fd..e4b8ca19094e4 100644 --- a/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts +++ b/src/plugins/vis_type_timeseries/server/validation_telemetry/validation_telemetry_service.ts @@ -19,7 +19,7 @@ import { APICaller, CoreSetup, Plugin, PluginInitializerContext } from 'kibana/server'; import { UsageCollectionSetup } from '../../../usage_collection/server'; -import { tsvbTelemetrySavedObjectType } from './saved_object_type'; +import { tsvbTelemetrySavedObjectType } from '../saved_objects'; export interface ValidationTelemetryServiceSetup { logFailedValidation: () => void; diff --git a/src/plugins/visualizations/kibana.json b/src/plugins/visualizations/kibana.json index cd22b1375ae1b..f3f9cbd8341ec 100644 --- a/src/plugins/visualizations/kibana.json +++ b/src/plugins/visualizations/kibana.json @@ -3,5 +3,5 @@ "version": "kibana", "server": true, "ui": true, - "requiredPlugins": ["data", "expressions", "uiActions", "embeddable", "usageCollection"] + "requiredPlugins": ["data", "expressions", "uiActions", "embeddable", "usageCollection", "inspector"] } diff --git a/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts b/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts index bf2d174f594b2..8e51bd4ac5d4f 100644 --- a/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts +++ b/src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts @@ -28,8 +28,9 @@ import { getTimeFilter, getCapabilities, } from '../services'; +import { VisualizeEmbeddableFactoryDeps } from './visualize_embeddable_factory'; -export const createVisEmbeddableFromObject = async ( +export const createVisEmbeddableFromObject = (deps: VisualizeEmbeddableFactoryDeps) => async ( vis: Vis, input: Partial & { id: string }, parent?: IContainer @@ -58,6 +59,7 @@ export const createVisEmbeddableFromObject = async ( indexPatterns, editUrl, editable, + deps, }, input, parent diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts b/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts index e64d200251797..ffb028ff131b3 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable.ts @@ -42,6 +42,7 @@ import { buildPipeline } from '../legacy/build_pipeline'; import { Vis } from '../vis'; import { getExpressions, getUiActions } from '../services'; import { VIS_EVENT_TO_TRIGGER } from './events'; +import { VisualizeEmbeddableFactoryDeps } from './visualize_embeddable_factory'; const getKeys = (o: T): Array => Object.keys(o) as Array; @@ -50,6 +51,7 @@ export interface VisualizeEmbeddableConfiguration { indexPatterns?: IIndexPattern[]; editUrl: string; editable: boolean; + deps: VisualizeEmbeddableFactoryDeps; } export interface VisualizeInput extends EmbeddableInput { @@ -84,10 +86,11 @@ export class VisualizeEmbeddable extends Embeddable { - if (this.handler) { - return this.handler.openInspector(this.getTitle() || ''); - } + if (!this.handler) return; + + const adapters = this.handler.inspect(); + if (!adapters) return; + + this.deps.start().plugins.inspector.open(adapters, { + title: this.getTitle() || '', + }); }; /** diff --git a/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx b/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx index 4b7d01ae3b246..6ab1c98645988 100644 --- a/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx +++ b/src/plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx @@ -25,7 +25,7 @@ import { EmbeddableOutput, ErrorEmbeddable, IContainer, -} from '../../../../plugins/embeddable/public'; +} from '../../../embeddable/public'; import { DisabledLabEmbeddable } from './disabled_lab_embeddable'; import { VisualizeEmbeddable, VisualizeInput, VisualizeOutput } from './visualize_embeddable'; import { VISUALIZE_EMBEDDABLE_TYPE } from './constants'; @@ -39,11 +39,17 @@ import { import { showNewVisModal } from '../wizard'; import { convertToSerializedVis } from '../saved_visualizations/_saved_vis'; import { createVisEmbeddableFromObject } from './create_vis_embeddable_from_object'; +import { StartServicesGetter } from '../../../kibana_utils/public'; +import { VisualizationsStartDeps } from '../plugin'; interface VisualizationAttributes extends SavedObjectAttributes { visState: string; } +export interface VisualizeEmbeddableFactoryDeps { + start: StartServicesGetter>; +} + export class VisualizeEmbeddableFactory implements EmbeddableFactoryDefinition< @@ -79,7 +85,8 @@ export class VisualizeEmbeddableFactory return visType.stage !== 'experimental'; }, }; - constructor() {} + + constructor(private readonly deps: VisualizeEmbeddableFactoryDeps) {} public async isEditable() { return getCapabilities().visualize.save as boolean; @@ -101,7 +108,7 @@ export class VisualizeEmbeddableFactory try { const savedObject = await savedVisualizations.get(savedObjectId); const vis = new Vis(savedObject.visState.type, await convertToSerializedVis(savedObject)); - return createVisEmbeddableFromObject(vis, input, parent); + return createVisEmbeddableFromObject(this.deps)(vis, input, parent); } catch (e) { console.error(e); // eslint-disable-line no-console return new ErrorEmbeddable(e, input, parent); diff --git a/src/plugins/visualizations/public/mocks.ts b/src/plugins/visualizations/public/mocks.ts index 2aa346423297a..d6eeffdb01459 100644 --- a/src/plugins/visualizations/public/mocks.ts +++ b/src/plugins/visualizations/public/mocks.ts @@ -26,6 +26,7 @@ import { expressionsPluginMock } from '../../../plugins/expressions/public/mocks import { dataPluginMock } from '../../../plugins/data/public/mocks'; import { usageCollectionPluginMock } from '../../../plugins/usage_collection/public/mocks'; import { uiActionsPluginMock } from '../../../plugins/ui_actions/public/mocks'; +import { inspectorPluginMock } from '../../../plugins/inspector/public/mocks'; const createSetupContract = (): VisualizationsSetup => ({ createBaseVisualization: jest.fn(), @@ -53,14 +54,16 @@ const createInstance = async () => { const setup = plugin.setup(coreMock.createSetup(), { data: dataPluginMock.createSetupContract(), - expressions: expressionsPluginMock.createSetupContract(), embeddable: embeddablePluginMock.createSetupContract(), + expressions: expressionsPluginMock.createSetupContract(), + inspector: inspectorPluginMock.createSetupContract(), usageCollection: usageCollectionPluginMock.createSetupContract(), }); const doStart = () => plugin.start(coreMock.createStart(), { data: dataPluginMock.createStartContract(), expressions: expressionsPluginMock.createStartContract(), + inspector: inspectorPluginMock.createStartContract(), uiActions: uiActionsPluginMock.createStartContract(), }); diff --git a/src/plugins/visualizations/public/plugin.ts b/src/plugins/visualizations/public/plugin.ts index 8fcb84b19a9be..b3e8c9b5b61b3 100644 --- a/src/plugins/visualizations/public/plugin.ts +++ b/src/plugins/visualizations/public/plugin.ts @@ -43,18 +43,23 @@ import { VisualizeEmbeddableFactory, createVisEmbeddableFromObject, } from './embeddable'; -import { ExpressionsSetup, ExpressionsStart } from '../../../plugins/expressions/public'; -import { EmbeddableSetup } from '../../../plugins/embeddable/public'; +import { ExpressionsSetup, ExpressionsStart } from '../../expressions/public'; +import { EmbeddableSetup } from '../../embeddable/public'; import { visualization as visualizationFunction } from './expressions/visualization_function'; import { visualization as visualizationRenderer } from './expressions/visualization_renderer'; import { range as rangeExpressionFunction } from './expression_functions/range'; import { visDimension as visDimensionExpressionFunction } from './expression_functions/vis_dimension'; import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../plugins/data/public'; -import { UsageCollectionSetup } from '../../../plugins/usage_collection/public'; +import { + Setup as InspectorSetup, + Start as InspectorStart, +} from '../../../plugins/inspector/public'; +import { UsageCollectionSetup } from '../../usage_collection/public'; +import { createStartServicesGetter, StartServicesGetter } from '../../kibana_utils/public'; import { createSavedVisLoader, SavedVisualizationsLoader } from './saved_visualizations'; import { SerializedVis, Vis } from './vis'; import { showNewVisModal } from './wizard'; -import { UiActionsStart } from '../../../plugins/ui_actions/public'; +import { UiActionsStart } from '../../ui_actions/public'; import { convertFromSerializedVis, convertToSerializedVis, @@ -74,19 +79,21 @@ export interface VisualizationsStart extends TypesStart { convertToSerializedVis: typeof convertToSerializedVis; convertFromSerializedVis: typeof convertFromSerializedVis; showNewVisModal: typeof showNewVisModal; - __LEGACY: { createVisEmbeddableFromObject: typeof createVisEmbeddableFromObject }; + __LEGACY: { createVisEmbeddableFromObject: ReturnType }; } export interface VisualizationsSetupDeps { - expressions: ExpressionsSetup; + data: DataPublicPluginSetup; embeddable: EmbeddableSetup; + expressions: ExpressionsSetup; + inspector: InspectorSetup; usageCollection: UsageCollectionSetup; - data: DataPublicPluginSetup; } export interface VisualizationsStartDeps { data: DataPublicPluginStart; expressions: ExpressionsStart; + inspector: InspectorStart; uiActions: UiActionsStart; } @@ -107,13 +114,16 @@ export class VisualizationsPlugin VisualizationsStartDeps > { private readonly types: TypesService = new TypesService(); + private getStartServicesOrDie?: StartServicesGetter; constructor(initializerContext: PluginInitializerContext) {} public setup( - core: CoreSetup, + core: CoreSetup, { expressions, embeddable, usageCollection, data }: VisualizationsSetupDeps ): VisualizationsSetup { + const start = (this.getStartServicesOrDie = createStartServicesGetter(core.getStartServices)); + setUISettings(core.uiSettings); setUsageCollector(usageCollection); @@ -122,7 +132,7 @@ export class VisualizationsPlugin expressions.registerFunction(rangeExpressionFunction); expressions.registerFunction(visDimensionExpressionFunction); - const embeddableFactory = new VisualizeEmbeddableFactory(); + const embeddableFactory = new VisualizeEmbeddableFactory({ start }); embeddable.registerEmbeddableFactory(VISUALIZE_EMBEDDABLE_TYPE, embeddableFactory); return { @@ -171,7 +181,11 @@ export class VisualizationsPlugin convertToSerializedVis, convertFromSerializedVis, savedVisualizationsLoader, - __LEGACY: { createVisEmbeddableFromObject }, + __LEGACY: { + createVisEmbeddableFromObject: createVisEmbeddableFromObject({ + start: this.getStartServicesOrDie!, + }), + }, }; } diff --git a/src/plugins/visualizations/server/saved_objects/visualization.ts b/src/plugins/visualizations/server/saved_objects/visualization.ts index 9f4782f3ec730..cd2211c185530 100644 --- a/src/plugins/visualizations/server/saved_objects/visualization.ts +++ b/src/plugins/visualizations/server/saved_objects/visualization.ts @@ -23,7 +23,7 @@ import { visualizationSavedObjectTypeMigrations } from './visualization_migratio export const visualizationSavedObjectType: SavedObjectsType = { name: 'visualization', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'visualizeApp', defaultSearchField: 'title', diff --git a/src/plugins/visualizations/server/saved_objects/visualization_migrations.test.ts b/src/plugins/visualizations/server/saved_objects/visualization_migrations.test.ts index 26f8278cd3d43..83d53d27e41fd 100644 --- a/src/plugins/visualizations/server/saved_objects/visualization_migrations.test.ts +++ b/src/plugins/visualizations/server/saved_objects/visualization_migrations.test.ts @@ -1460,4 +1460,62 @@ describe('migration visualization', () => { expect(migratedParams.gauge_color_rules[1]).toEqual(params.gauge_color_rules[1]); }); }); + + describe('7.8.0 tsvb split_color_mode', () => { + const migrate = (doc: any) => + visualizationSavedObjectTypeMigrations['7.8.0']( + doc as Parameters[0], + savedObjectMigrationContext + ); + + const generateDoc = (params: any) => ({ + attributes: { + title: 'My Vis', + type: 'visualization', + description: 'This is my super cool vis.', + visState: JSON.stringify(params), + uiStateJSON: '{}', + version: 1, + kibanaSavedObjectMeta: { + searchSourceJSON: '{}', + }, + }, + }); + + it('should change a missing split_color_mode to gradient', () => { + const params = { type: 'metrics', params: { series: [{}] } }; + const testDoc1 = generateDoc(params); + const migratedTestDoc1 = migrate(testDoc1); + const series = JSON.parse(migratedTestDoc1.attributes.visState).params.series; + + expect(series[0].split_color_mode).toEqual('gradient'); + }); + + it('should not change the color mode if it is set', () => { + const params = { type: 'metrics', params: { series: [{ split_color_mode: 'gradient' }] } }; + const testDoc1 = generateDoc(params); + const migratedTestDoc1 = migrate(testDoc1); + const series = JSON.parse(migratedTestDoc1.attributes.visState).params.series; + + expect(series[0].split_color_mode).toEqual('gradient'); + }); + + it('should not change the color mode if it is non-default', () => { + const params = { type: 'metrics', params: { series: [{ split_color_mode: 'rainbow' }] } }; + const testDoc1 = generateDoc(params); + const migratedTestDoc1 = migrate(testDoc1); + const series = JSON.parse(migratedTestDoc1.attributes.visState).params.series; + + expect(series[0].split_color_mode).toEqual('rainbow'); + }); + + it('should not migrate a visualization of unknown type', () => { + const params = { type: 'unknown', params: { series: [{}] } }; + const doc = generateDoc(params); + const migratedDoc = migrate(doc); + const series = JSON.parse(migratedDoc.attributes.visState).params.series; + + expect(series[0].split_color_mode).toBeUndefined(); + }); + }); }); diff --git a/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts b/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts index 80783e41863ea..94473e35a942d 100644 --- a/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts +++ b/src/plugins/visualizations/server/saved_objects/visualization_migrations.ts @@ -602,7 +602,39 @@ const migrateMatchAllQuery: SavedObjectMigrationFn = doc => { }; } } + return doc; +}; + +// [TSVB] Default color palette is changing, keep the default for older viz +const migrateTsvbDefaultColorPalettes: SavedObjectMigrationFn = doc => { + const visStateJSON = get(doc, 'attributes.visState'); + let visState; + + if (visStateJSON) { + try { + visState = JSON.parse(visStateJSON); + } catch (e) { + // Let it go, the data is invalid and we'll leave it as is + } + if (visState && visState.type === 'metrics') { + const series: any[] = get(visState, 'params.series') || []; + series.forEach(part => { + // The default value was not saved before + if (!part.split_color_mode) { + part.split_color_mode = 'gradient'; + } + }); + + return { + ...doc, + attributes: { + ...doc.attributes, + visState: JSON.stringify(visState), + }, + }; + } + } return doc; }; @@ -639,4 +671,5 @@ export const visualizationSavedObjectTypeMigrations = { '7.3.1': flow(migrateFiltersAggQueryStringQueries), '7.4.2': flow(transformSplitFiltersStringToQueryObject), '7.7.0': flow(migrateOperatorKeyTypo), + '7.8.0': flow(migrateTsvbDefaultColorPalettes), }; diff --git a/tasks/config/peg.js b/tasks/config/peg.js index 1d8667840faba..2de6ff4b5cff9 100644 --- a/tasks/config/peg.js +++ b/tasks/config/peg.js @@ -26,7 +26,7 @@ module.exports = { }, }, timelion_chain: { - src: 'src/legacy/core_plugins/vis_type_timelion/public/chain.peg', - dest: 'src/legacy/core_plugins/vis_type_timelion/public/_generated_/chain.js', + src: 'src/plugins/vis_type_timelion/public/chain.peg', + dest: 'src/plugins/vis_type_timelion/public/_generated_/chain.js', }, }; diff --git a/test/api_integration/apis/saved_objects/migrations.js b/test/api_integration/apis/saved_objects/migrations.js index bd207ccb41b20..9d908b95ca575 100644 --- a/test/api_integration/apis/saved_objects/migrations.js +++ b/test/api_integration/apis/saved_objects/migrations.js @@ -383,7 +383,7 @@ function migrationsToTypes(migrations) { return Object.entries(migrations).map(([type, migrations]) => ({ name: type, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: {} }, migrations: { ...migrations }, })); diff --git a/test/examples/config.js b/test/examples/config.js index 49d75da286075..2be34459d8d06 100644 --- a/test/examples/config.js +++ b/test/examples/config.js @@ -28,6 +28,7 @@ export default async function({ readConfigFile }) { require.resolve('./search'), require.resolve('./embeddables'), require.resolve('./ui_actions'), + require.resolve('./state_sync'), ], services: { ...functionalConfig.get('services'), diff --git a/test/examples/embeddables/adding_children.ts b/test/examples/embeddables/adding_children.ts index 5fe88b5dd33f0..9ec4b6cffd31a 100644 --- a/test/examples/embeddables/adding_children.ts +++ b/test/examples/embeddables/adding_children.ts @@ -25,7 +25,8 @@ export default function({ getService }: PluginFunctionalProviderContext) { const testSubjects = getService('testSubjects'); const flyout = getService('flyout'); - describe('creating and adding children', () => { + // FLAKY: https://github.com/elastic/kibana/issues/58692 + describe.skip('creating and adding children', () => { before(async () => { await testSubjects.click('embeddablePanelExamplae'); }); diff --git a/test/examples/state_sync/index.ts b/test/examples/state_sync/index.ts new file mode 100644 index 0000000000000..3c524f0feb619 --- /dev/null +++ b/test/examples/state_sync/index.ts @@ -0,0 +1,39 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { PluginFunctionalProviderContext } from 'test/plugin_functional/services'; + +// eslint-disable-next-line import/no-default-export +export default function({ + getService, + getPageObjects, + loadTestFile, +}: PluginFunctionalProviderContext) { + const browser = getService('browser'); + const PageObjects = getPageObjects(['common']); + + describe('state sync examples', function() { + before(async () => { + await browser.setWindowSize(1300, 900); + await PageObjects.common.navigateToApp('settings'); + }); + + loadTestFile(require.resolve('./todo_app')); + }); +} diff --git a/test/examples/state_sync/todo_app.ts b/test/examples/state_sync/todo_app.ts new file mode 100644 index 0000000000000..4933d746ca4fd --- /dev/null +++ b/test/examples/state_sync/todo_app.ts @@ -0,0 +1,189 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import expect from '@kbn/expect'; + +import { PluginFunctionalProviderContext } from 'test/plugin_functional/services'; + +// eslint-disable-next-line import/no-default-export +export default function({ getService, getPageObjects }: PluginFunctionalProviderContext) { + const testSubjects = getService('testSubjects'); + const find = getService('find'); + const retry = getService('retry'); + const appsMenu = getService('appsMenu'); + const browser = getService('browser'); + const PageObjects = getPageObjects(['common']); + const log = getService('log'); + + describe('TODO app', () => { + describe("TODO app with browser history (platform's ScopedHistory)", async () => { + const appId = 'stateContainersExampleBrowserHistory'; + let base: string; + + before(async () => { + base = await PageObjects.common.getHostPort(); + await appsMenu.clickLink('State containers example - browser history routing'); + }); + + it('links are rendered correctly and state is preserved in links', async () => { + const getHrefByLinkTestSubj = async (linkTestSubj: string) => + (await testSubjects.find(linkTestSubj)).getAttribute('href'); + + await expectPathname(await getHrefByLinkTestSubj('filterLinkCompleted'), '/completed'); + await expectPathname( + await getHrefByLinkTestSubj('filterLinkNotCompleted'), + '/not-completed' + ); + await expectPathname(await getHrefByLinkTestSubj('filterLinkAll'), '/'); + }); + + it('TODO app state is synced with url, back navigation works', async () => { + // checking that in initial state checkbox is unchecked and state is synced with url + expect(await testSubjects.isChecked('todoCheckbox-0')).to.be(false); + expect(await browser.getCurrentUrl()).to.contain('completed:!f'); + + // check the checkbox by clicking the label (clicking checkbox directly fails as it is "no intractable") + (await find.byCssSelector('label[for="0"]')).click(); + + // wait for react to update dom and checkbox in checked state + await retry.tryForTime(1000, async () => { + await expect(await testSubjects.isChecked('todoCheckbox-0')).to.be(true); + }); + // checking that url is updated with checked state + expect(await browser.getCurrentUrl()).to.contain('completed:!t'); + + // checking back and forward button + await browser.goBack(); + expect(await browser.getCurrentUrl()).to.contain('completed:!f'); + await retry.tryForTime(1000, async () => { + await expect(await testSubjects.isChecked('todoCheckbox-0')).to.be(false); + }); + + await browser.goForward(); + expect(await browser.getCurrentUrl()).to.contain('completed:!t'); + await retry.tryForTime(1000, async () => { + await expect(await testSubjects.isChecked('todoCheckbox-0')).to.be(true); + }); + }); + + it('links navigation works', async () => { + // click link to filter only not completed + await testSubjects.click('filterLinkNotCompleted'); + await expectPathname(await browser.getCurrentUrl(), '/not-completed'); + // checkbox should be missing because it is "completed" + await testSubjects.missingOrFail('todoCheckbox-0'); + }); + + /** + * Parses app's scoped pathname from absolute url and asserts it against `expectedPathname` + * Also checks that hashes are equal (detail of todo app that state is rendered in links) + * @param absoluteUrl + * @param expectedPathname + */ + async function expectPathname(absoluteUrl: string, expectedPathname: string) { + const scoped = await getScopedUrl(absoluteUrl); + const [pathname, newHash] = scoped.split('#'); + expect(pathname).to.be(expectedPathname); + const [, currentHash] = (await browser.getCurrentUrl()).split('#'); + expect(newHash.replace(/%27/g, "'")).to.be(currentHash.replace(/%27/g, "'")); + } + + /** + * Get's part of url scoped to this app (removed kibana's host and app's pathname) + * @param url - absolute url + */ + async function getScopedUrl(url: string): Promise { + expect(url).to.contain(base); + expect(url).to.contain(appId); + const scopedUrl = url.slice(url.indexOf(appId) + appId.length); + expect(scopedUrl).not.to.contain(appId); // app id in url only once + return scopedUrl; + } + }); + + describe('TODO app with hash history ', async () => { + before(async () => { + await appsMenu.clickLink('State containers example - hash history routing'); + }); + + it('Links are rendered correctly and state is preserved in links', async () => { + const getHrefByLinkTestSubj = async (linkTestSubj: string) => + (await testSubjects.find(linkTestSubj)).getAttribute('href'); + await expectHashPathname(await getHrefByLinkTestSubj('filterLinkCompleted'), '/completed'); + await expectHashPathname( + await getHrefByLinkTestSubj('filterLinkNotCompleted'), + '/not-completed' + ); + await expectHashPathname(await getHrefByLinkTestSubj('filterLinkAll'), '/'); + }); + + it('TODO app state is synced with url, back navigation works', async () => { + // checking that in initial state checkbox is unchecked and state is synced with url + expect(await testSubjects.isChecked('todoCheckbox-0')).to.be(false); + expect(await browser.getCurrentUrl()).to.contain('completed:!f'); + // check the checkbox by clicking the label (clicking checkbox directly fails as it is "no intractable") + (await find.byCssSelector('label[for="0"]')).click(); + + // wait for react to update dom and checkbox in checked state + await retry.tryForTime(1000, async () => { + await expect(await testSubjects.isChecked('todoCheckbox-0')).to.be(true); + }); + // checking that url is updated with checked state + expect(await browser.getCurrentUrl()).to.contain('completed:!t'); + + // checking back and forward button + await browser.goBack(); + expect(await browser.getCurrentUrl()).to.contain('completed:!f'); + await retry.tryForTime(1000, async () => { + await expect(await testSubjects.isChecked('todoCheckbox-0')).to.be(false); + }); + + await browser.goForward(); + expect(await browser.getCurrentUrl()).to.contain('completed:!t'); + await retry.tryForTime(1000, async () => { + await expect(await testSubjects.isChecked('todoCheckbox-0')).to.be(true); + }); + }); + + it('links navigation works', async () => { + // click link to filter only not completed + await testSubjects.click('filterLinkNotCompleted'); + await expectHashPathname(await browser.getCurrentUrl(), '/not-completed'); + // checkbox should be missing because it is "completed" + await testSubjects.missingOrFail('todoCheckbox-0'); + }); + + /** + * Parses app's pathname in hash from absolute url and asserts it against `expectedPathname` + * Also checks that queries in hashes are equal (detail of todo app that state is rendered in links) + * @param absoluteUrl + * @param expectedPathname + */ + async function expectHashPathname(hash: string, expectedPathname: string) { + log.debug(`expect hash pathname ${hash} to be ${expectedPathname}`); + const hashPath = hash.split('#')[1]; + const [hashPathname, hashQuery] = hashPath.split('?'); + const [, currentHash] = (await browser.getCurrentUrl()).split('#'); + const [, currentHashQuery] = currentHash.split('?'); + expect(currentHashQuery.replace(/%27/g, "'")).to.be(hashQuery.replace(/%27/g, "'")); + expect(hashPathname).to.be(expectedPathname); + } + }); + }); +} diff --git a/test/functional/apps/dashboard/dashboard_back_button.ts b/test/functional/apps/dashboard/dashboard_back_button.ts new file mode 100644 index 0000000000000..8a488c1780fcc --- /dev/null +++ b/test/functional/apps/dashboard/dashboard_back_button.ts @@ -0,0 +1,47 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function({ getService, getPageObjects }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const kibanaServer = getService('kibanaServer'); + const PageObjects = getPageObjects(['dashboard', 'header', 'common', 'visualize', 'timePicker']); + const browser = getService('browser'); + + describe('dashboard back button', () => { + before(async () => { + await esArchiver.loadIfNeeded('dashboard/current/kibana'); + await kibanaServer.uiSettings.replace({ + defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', + }); + await PageObjects.common.navigateToApp('dashboard'); + await PageObjects.dashboard.preserveCrossAppState(); + }); + + it('after navigation from listing page to dashboard back button works', async () => { + await PageObjects.dashboard.gotoDashboardLandingPage(); + await PageObjects.dashboard.loadSavedDashboard('dashboard with everything'); + await PageObjects.dashboard.waitForRenderComplete(); + await browser.goBack(); + expect(await PageObjects.dashboard.onDashboardLandingPage()).to.be(true); + }); + }); +} diff --git a/test/functional/apps/dashboard/index.js b/test/functional/apps/dashboard/index.js index 5e96a55b19014..6666ccc57d584 100644 --- a/test/functional/apps/dashboard/index.js +++ b/test/functional/apps/dashboard/index.js @@ -55,6 +55,7 @@ export default function({ getService, loadTestFile }) { loadTestFile(require.resolve('./dashboard_options')); loadTestFile(require.resolve('./data_shared_attributes')); loadTestFile(require.resolve('./embed_mode')); + loadTestFile(require.resolve('./dashboard_back_button')); // Note: This one must be last because it unloads some data for one of its tests! // No, this isn't ideal, but loading/unloading takes so much time and these are all bunched diff --git a/test/functional/apps/dashboard/panel_controls.js b/test/functional/apps/dashboard/panel_controls.js index 52c4a11360355..6e24b9f3570a3 100644 --- a/test/functional/apps/dashboard/panel_controls.js +++ b/test/functional/apps/dashboard/panel_controls.js @@ -113,6 +113,50 @@ export default function({ getService, getPageObjects }) { }); }); + describe('panel cloning', function() { + before(async () => { + await PageObjects.dashboard.clickNewDashboard(); + await PageObjects.timePicker.setHistoricalDataRange(); + await dashboardAddPanel.addVisualization(PIE_CHART_VIS_NAME); + }); + + after(async function() { + await PageObjects.dashboard.gotoDashboardLandingPage(); + }); + + it('clones a panel', async () => { + const initialPanelTitles = await PageObjects.dashboard.getPanelTitles(); + await dashboardPanelActions.clonePanelByTitle(PIE_CHART_VIS_NAME); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.dashboard.waitForRenderComplete(); + const postPanelTitles = await PageObjects.dashboard.getPanelTitles(); + expect(postPanelTitles.length).to.equal(initialPanelTitles.length + 1); + }); + + it('appends a clone title tag', async () => { + const panelTitles = await PageObjects.dashboard.getPanelTitles(); + expect(panelTitles[1]).to.equal(PIE_CHART_VIS_NAME + ' (copy)'); + }); + + it('retains original panel dimensions', async () => { + const panelDimensions = await PageObjects.dashboard.getPanelDimensions(); + expect(panelDimensions[0]).to.eql(panelDimensions[1]); + }); + + it('gives a correct title to the clone of a clone', async () => { + const initialPanelTitles = await PageObjects.dashboard.getPanelTitles(); + const clonedPanelName = initialPanelTitles[initialPanelTitles.length - 1]; + await dashboardPanelActions.clonePanelByTitle(clonedPanelName); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.dashboard.waitForRenderComplete(); + const postPanelTitles = await PageObjects.dashboard.getPanelTitles(); + expect(postPanelTitles.length).to.equal(initialPanelTitles.length + 1); + expect(postPanelTitles[postPanelTitles.length - 1]).to.equal( + PIE_CHART_VIS_NAME + ' (copy 1)' + ); + }); + }); + describe('panel edit controls', function() { before(async () => { await PageObjects.dashboard.clickNewDashboard(); @@ -137,6 +181,7 @@ export default function({ getService, getPageObjects }) { await dashboardPanelActions.expectExistsEditPanelAction(); await dashboardPanelActions.expectExistsReplacePanelAction(); + await dashboardPanelActions.expectExistsDuplicatePanelAction(); await dashboardPanelActions.expectExistsRemovePanelAction(); }); @@ -151,6 +196,7 @@ export default function({ getService, getPageObjects }) { await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.expectExistsEditPanelAction(); await dashboardPanelActions.expectExistsReplacePanelAction(); + await dashboardPanelActions.expectExistsDuplicatePanelAction(); await dashboardPanelActions.expectExistsRemovePanelAction(); // Get rid of the timestamp in the url. @@ -166,6 +212,7 @@ export default function({ getService, getPageObjects }) { await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.expectMissingEditPanelAction(); await dashboardPanelActions.expectMissingReplacePanelAction(); + await dashboardPanelActions.expectMissingDuplicatePanelAction(); await dashboardPanelActions.expectMissingRemovePanelAction(); }); @@ -174,6 +221,7 @@ export default function({ getService, getPageObjects }) { await dashboardPanelActions.openContextMenu(); await dashboardPanelActions.expectExistsEditPanelAction(); await dashboardPanelActions.expectExistsReplacePanelAction(); + await dashboardPanelActions.expectExistsDuplicatePanelAction(); await dashboardPanelActions.expectMissingRemovePanelAction(); await dashboardPanelActions.clickExpandPanelToggle(); }); diff --git a/test/functional/apps/visualize/_tsvb_time_series.ts b/test/functional/apps/visualize/_tsvb_time_series.ts index fa79190a5bf94..ac89c2b55e514 100644 --- a/test/functional/apps/visualize/_tsvb_time_series.ts +++ b/test/functional/apps/visualize/_tsvb_time_series.ts @@ -25,7 +25,6 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { const retry = getService('retry'); const log = getService('log'); const kibanaServer = getService('kibanaServer'); - const testSubjects = getService('testSubjects'); describe('visual builder', function describeIndexTests() { beforeEach(async () => { @@ -126,20 +125,18 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { expect(actualCountMin).to.be('3 hours'); }); - // --reversed class is not implemented in @elastic\chart - describe.skip('Dark mode', () => { + describe('Dark mode', () => { before(async () => { await kibanaServer.uiSettings.update({ 'theme:darkMode': true, }); }); - it(`viz should have 'reversed' class when background color is white`, async () => { + it(`viz should have light class when background color is white`, async () => { await visualBuilder.clickPanelOptions('timeSeries'); await visualBuilder.setBackgroundColor('#FFFFFF'); - const classNames = await testSubjects.getAttribute('timeseriesChart', 'class'); - expect(classNames.includes('tvbVisTimeSeries--reversed')).to.be(true); + expect(await visualBuilder.checkTimeSeriesIsLight()).to.be(true); }); after(async () => { diff --git a/test/functional/page_objects/visual_builder_page.ts b/test/functional/page_objects/visual_builder_page.ts index b8e6c812b46bd..12962b3a5cdef 100644 --- a/test/functional/page_objects/visual_builder_page.ts +++ b/test/functional/page_objects/visual_builder_page.ts @@ -71,6 +71,10 @@ export function VisualBuilderPageProvider({ getService, getPageObjects }: FtrPro } } + public async checkTimeSeriesIsLight() { + return await find.existsByCssSelector('.tvbVisTimeSeriesLight'); + } + public async checkTimeSeriesLegendIsPresent() { const isPresent = await find.existsByCssSelector('.echLegend'); if (!isPresent) { diff --git a/test/functional/services/dashboard/panel_actions.js b/test/functional/services/dashboard/panel_actions.js index baea2a52208c1..b155d747f3b93 100644 --- a/test/functional/services/dashboard/panel_actions.js +++ b/test/functional/services/dashboard/panel_actions.js @@ -20,6 +20,7 @@ const REMOVE_PANEL_DATA_TEST_SUBJ = 'embeddablePanelAction-deletePanel'; const EDIT_PANEL_DATA_TEST_SUBJ = 'embeddablePanelAction-editPanel'; const REPLACE_PANEL_DATA_TEST_SUBJ = 'embeddablePanelAction-replacePanel'; +const CLONE_PANEL_DATA_TEST_SUBJ = 'embeddablePanelAction-clonePanel'; const TOGGLE_EXPAND_PANEL_DATA_TEST_SUBJ = 'embeddablePanelAction-togglePanel'; const CUSTOMIZE_PANEL_DATA_TEST_SUBJ = 'embeddablePanelAction-ACTION_CUSTOMIZE_PANEL'; const OPEN_CONTEXT_MENU_ICON_DATA_TEST_SUBJ = 'embeddablePanelToggleMenuIcon'; @@ -97,6 +98,16 @@ export function DashboardPanelActionsProvider({ getService, getPageObjects }) { await testSubjects.click(REPLACE_PANEL_DATA_TEST_SUBJ); } + async clonePanelByTitle(title) { + log.debug(`clonePanel(${title})`); + let panelOptions = null; + if (title) { + panelOptions = await this.getPanelHeading(title); + } + await this.openContextMenu(panelOptions); + await testSubjects.click(CLONE_PANEL_DATA_TEST_SUBJ); + } + async openInspectorByTitle(title) { const header = await this.getPanelHeading(title); await this.openInspector(header); @@ -123,7 +134,12 @@ export function DashboardPanelActionsProvider({ getService, getPageObjects }) { } async expectExistsReplacePanelAction() { - log.debug('expectExistsEditPanelAction'); + log.debug('expectExistsReplacePanelAction'); + await testSubjects.existOrFail(REPLACE_PANEL_DATA_TEST_SUBJ); + } + + async expectExistsDuplicatePanelAction() { + log.debug('expectExistsDuplicatePanelAction'); await testSubjects.existOrFail(REPLACE_PANEL_DATA_TEST_SUBJ); } @@ -133,7 +149,12 @@ export function DashboardPanelActionsProvider({ getService, getPageObjects }) { } async expectMissingReplacePanelAction() { - log.debug('expectMissingEditPanelAction'); + log.debug('expectMissingReplacePanelAction'); + await testSubjects.missingOrFail(REPLACE_PANEL_DATA_TEST_SUBJ); + } + + async expectMissingDuplicatePanelAction() { + log.debug('expectMissingDuplicatePanelAction'); await testSubjects.missingOrFail(REPLACE_PANEL_DATA_TEST_SUBJ); } diff --git a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/tsconfig.json b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/tsconfig.json index d8096d9aab27a..544c27241f5cb 100644 --- a/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/tsconfig.json +++ b/test/plugin_functional/plugins/kbn_tp_embeddable_explorer/tsconfig.json @@ -6,7 +6,8 @@ "types": [ "node", "jest", - "react" + "react", + "flot" ] }, "include": [ @@ -16,4 +17,4 @@ "../../../../typings/**/*", ], "exclude": [] -} \ No newline at end of file +} diff --git a/test/scripts/jenkins_ci_group.sh b/test/scripts/jenkins_ci_group.sh index 23807a6e98dc2..c77ffe40db553 100755 --- a/test/scripts/jenkins_ci_group.sh +++ b/test/scripts/jenkins_ci_group.sh @@ -22,7 +22,7 @@ else echo " -> running tests from the clone folder" #yarn run grunt "run:functionalTests_ciGroup${CI_GROUP}"; - node scripts/functional_tests --debug --include-tag "ciGroup$CI_GROUP" --config test/functional/config.coverage.js || true; + node scripts/functional_tests --debug --include-tag "ciGroup$CI_GROUP" --exclude-tag "skipCoverage" || true; if [[ -d target/kibana-coverage/functional ]]; then echo " -> replacing kibana${CI_GROUP} with kibana in json files" diff --git a/test/scripts/jenkins_xpack.sh b/test/scripts/jenkins_xpack.sh index 5055997df642a..67d88b308ed91 100755 --- a/test/scripts/jenkins_xpack.sh +++ b/test/scripts/jenkins_xpack.sh @@ -17,7 +17,7 @@ if [[ -z "$CODE_COVERAGE" ]] ; then echo " -> Running SIEM cyclic dependency test" cd "$XPACK_DIR" - checks-reporter-with-killswitch "X-Pack SIEM cyclic dependency test" node legacy/plugins/siem/scripts/check_circular_deps + checks-reporter-with-killswitch "X-Pack SIEM cyclic dependency test" node plugins/siem/scripts/check_circular_deps echo "" echo "" @@ -39,7 +39,7 @@ else # build runtime for canvas echo "NODE_ENV=$NODE_ENV" node ./legacy/plugins/canvas/scripts/shareable_runtime - node scripts/jest --ci --verbose --coverage + node --max-old-space-size=6144 scripts/jest --ci --verbose --coverage # rename file in order to be unique one test -f ../target/kibana-coverage/jest/coverage-final.json \ && mv ../target/kibana-coverage/jest/coverage-final.json \ diff --git a/test/scripts/jenkins_xpack_ci_group.sh b/test/scripts/jenkins_xpack_ci_group.sh index 01b13293c10ba..a6e600630364e 100755 --- a/test/scripts/jenkins_xpack_ci_group.sh +++ b/test/scripts/jenkins_xpack_ci_group.sh @@ -23,7 +23,7 @@ else cd "kibana${CI_GROUP}/x-pack" echo " -> running tests from the clone folder" - node scripts/functional_tests --debug --include-tag "ciGroup$CI_GROUP" --config test/functional/config.coverage.js || true; + node scripts/functional_tests --debug --include-tag "ciGroup$CI_GROUP" --exclude-tag "skipCoverage" || true; if [[ -d ../target/kibana-coverage/functional ]]; then echo " -> replacing kibana${CI_GROUP} with kibana in json files" diff --git a/test/tsconfig.json b/test/tsconfig.json index 285d3db64a874..5a3716e620fed 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "types": [ "node", - "mocha" + "mocha", + "flot" ], "lib": [ "esnext", diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 50f36ddd21c97..c8715ac3447bd 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -32,11 +32,11 @@ "xpack.remoteClusters": "plugins/remote_clusters", "xpack.painlessLab": "plugins/painless_lab", "xpack.reporting": ["plugins/reporting", "legacy/plugins/reporting"], - "xpack.rollupJobs": "legacy/plugins/rollup", + "xpack.rollupJobs": ["legacy/plugins/rollup", "plugins/rollup"], "xpack.searchProfiler": "plugins/searchprofiler", "xpack.security": ["legacy/plugins/security", "plugins/security"], "xpack.server": "legacy/server", - "xpack.siem": "legacy/plugins/siem", + "xpack.siem": ["plugins/siem", "legacy/plugins/siem"], "xpack.snapshotRestore": "plugins/snapshot_restore", "xpack.spaces": ["legacy/plugins/spaces", "plugins/spaces"], "xpack.taskManager": "legacy/plugins/task_manager", diff --git a/x-pack/examples/README.md b/x-pack/examples/README.md new file mode 100644 index 0000000000000..babf744f9777d --- /dev/null +++ b/x-pack/examples/README.md @@ -0,0 +1,7 @@ +## Example plugins + +This folder contains X-Pack example plugins. To run the plugins in this folder, use the `--run-examples` flag, via + +``` +yarn start --run-examples +``` diff --git a/x-pack/examples/ui_actions_enhanced_examples/README.md b/x-pack/examples/ui_actions_enhanced_examples/README.md new file mode 100644 index 0000000000000..c9f53137d8687 --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/README.md @@ -0,0 +1,3 @@ +## Ui actions enhanced examples + +To run this example, use the command `yarn start --run-examples`. diff --git a/x-pack/examples/ui_actions_enhanced_examples/kibana.json b/x-pack/examples/ui_actions_enhanced_examples/kibana.json new file mode 100644 index 0000000000000..f75852edced5c --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/kibana.json @@ -0,0 +1,10 @@ +{ + "id": "uiActionsEnhancedExamples", + "version": "0.0.1", + "kibanaVersion": "kibana", + "configPath": ["ui_actions_enhanced_examples"], + "server": false, + "ui": true, + "requiredPlugins": ["uiActions", "data"], + "optionalPlugins": [] +} diff --git a/x-pack/examples/ui_actions_enhanced_examples/package.json b/x-pack/examples/ui_actions_enhanced_examples/package.json new file mode 100644 index 0000000000000..a9f004b075cec --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/package.json @@ -0,0 +1,17 @@ +{ + "name": "ui_actions_enhanced_examples", + "version": "1.0.0", + "main": "target/examples/ui_actions_enhanced_examples", + "kibana": { + "version": "kibana", + "templateVersion": "1.0.0" + }, + "license": "Apache-2.0", + "scripts": { + "kbn": "node ../../scripts/kbn.js", + "build": "rm -rf './target' && tsc" + }, + "devDependencies": { + "typescript": "3.7.2" + } +} diff --git a/x-pack/legacy/plugins/siem/scripts/check_circular_deps.js b/x-pack/examples/ui_actions_enhanced_examples/public/index.ts similarity index 66% rename from x-pack/legacy/plugins/siem/scripts/check_circular_deps.js rename to x-pack/examples/ui_actions_enhanced_examples/public/index.ts index 046cc010621d7..7f3f36089d576 100644 --- a/x-pack/legacy/plugins/siem/scripts/check_circular_deps.js +++ b/x-pack/examples/ui_actions_enhanced_examples/public/index.ts @@ -4,5 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -require('../../../../../src/setup_node_env'); -require('../dev_tools/circular_deps/run_check_circular_deps_cli'); +import { UiActionsEnhancedExamplesPlugin } from './plugin'; + +export const plugin = () => new UiActionsEnhancedExamplesPlugin(); diff --git a/x-pack/examples/ui_actions_enhanced_examples/public/plugin.ts b/x-pack/examples/ui_actions_enhanced_examples/public/plugin.ts new file mode 100644 index 0000000000000..a4c43753c8247 --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/public/plugin.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Plugin, CoreSetup, CoreStart } from '../../../../src/core/public'; +import { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actions/public'; +import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../../src/plugins/data/public'; + +export interface SetupDependencies { + data: DataPublicPluginSetup; + uiActions: UiActionsSetup; +} + +export interface StartDependencies { + data: DataPublicPluginStart; + uiActions: UiActionsStart; +} + +export class UiActionsEnhancedExamplesPlugin + implements Plugin { + public setup(core: CoreSetup, plugins: SetupDependencies) { + // eslint-disable-next-line + console.log('ui_actions_enhanced_examples'); + } + + public start(core: CoreStart, plugins: StartDependencies) {} + + public stop() {} +} diff --git a/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json b/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json new file mode 100644 index 0000000000000..d508076b33199 --- /dev/null +++ b/x-pack/examples/ui_actions_enhanced_examples/tsconfig.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./target", + "skipLibCheck": true + }, + "include": [ + "index.ts", + "public/**/*.ts", + "public/**/*.tsx", + "server/**/*.ts", + "../../typings/**/*", + ], + "exclude": [] +} diff --git a/x-pack/index.js b/x-pack/index.js index 61fd4f1752316..1a78c24b1221b 100644 --- a/x-pack/index.js +++ b/x-pack/index.js @@ -9,9 +9,7 @@ import { graph } from './legacy/plugins/graph'; import { monitoring } from './legacy/plugins/monitoring'; import { reporting } from './legacy/plugins/reporting'; import { security } from './legacy/plugins/security'; -import { tilemap } from './legacy/plugins/tilemap'; import { dashboardMode } from './legacy/plugins/dashboard_mode'; -import { logstash } from './legacy/plugins/logstash'; import { beats } from './legacy/plugins/beats_management'; import { apm } from './legacy/plugins/apm'; import { maps } from './legacy/plugins/maps'; @@ -40,9 +38,7 @@ module.exports = function(kibana) { reporting(kibana), spaces(kibana), security(kibana), - tilemap(kibana), dashboardMode(kibana), - logstash(kibana), beats(kibana), apm(kibana), maps(kibana), diff --git a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx b/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx index a1462c7637358..cc5c62e25b491 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/ServiceIntegrations/MachineLearningFlyout/index.tsx @@ -57,7 +57,8 @@ export class MachineLearningFlyout extends Component { }; public addErrorToast = () => { - const core = this.context; + const { core } = this.context; + const { urlParams } = this.props; const { serviceName } = urlParams; diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts index 416eb879d5974..d844ac8b5988d 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts +++ b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.test.ts @@ -166,6 +166,212 @@ describe('waterfall_helpers', () => { expect(waterfall.errorsCount).toEqual(0); expect(waterfall).toMatchSnapshot(); }); + it('should reparent spans', () => { + const traceItems = [ + { + processor: { event: 'transaction' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-node' }, + transaction: { + duration: { us: 49660 }, + name: 'GET /api', + id: 'myTransactionId1' + }, + timestamp: { us: 1549324795784006 } + } as Transaction, + { + parent: { id: 'mySpanIdD' }, + processor: { event: 'span' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-ruby' }, + transaction: { id: 'myTransactionId1' }, + timestamp: { us: 1549324795825633 }, + span: { + duration: { us: 481 }, + name: 'SELECT FROM products', + id: 'mySpanIdB' + }, + child_ids: ['mySpanIdA', 'mySpanIdC'] + } as Span, + { + parent: { id: 'mySpanIdD' }, + processor: { event: 'span' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-ruby' }, + transaction: { id: 'myTransactionId1' }, + span: { + duration: { us: 6161 }, + name: 'Api::ProductsController#index', + id: 'mySpanIdA' + }, + timestamp: { us: 1549324795824504 } + } as Span, + { + parent: { id: 'mySpanIdD' }, + processor: { event: 'span' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-ruby' }, + transaction: { id: 'myTransactionId1' }, + span: { + duration: { us: 532 }, + name: 'SELECT FROM product', + id: 'mySpanIdC' + }, + timestamp: { us: 1549324795827905 } + } as Span, + { + parent: { id: 'myTransactionId1' }, + processor: { event: 'span' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-node' }, + transaction: { id: 'myTransactionId1' }, + span: { + duration: { us: 47557 }, + name: 'GET opbeans-ruby:3000/api/products', + id: 'mySpanIdD' + }, + timestamp: { us: 1549324795785760 } + } as Span + ]; + const entryTransactionId = 'myTransactionId1'; + const waterfall = getWaterfall( + { + trace: { items: traceItems, errorDocs: [], exceedsMax: false }, + errorsPerTransaction: {} + }, + entryTransactionId + ); + const getIdAndParentId = (item: IWaterfallItem) => ({ + id: item.id, + parentId: item.parent?.id + }); + expect(waterfall.items.length).toBe(5); + expect(getIdAndParentId(waterfall.items[0])).toEqual({ + id: 'myTransactionId1', + parentId: undefined + }); + expect(getIdAndParentId(waterfall.items[1])).toEqual({ + id: 'mySpanIdD', + parentId: 'myTransactionId1' + }); + expect(getIdAndParentId(waterfall.items[2])).toEqual({ + id: 'mySpanIdB', + parentId: 'mySpanIdD' + }); + expect(getIdAndParentId(waterfall.items[3])).toEqual({ + id: 'mySpanIdA', + parentId: 'mySpanIdB' + }); + expect(getIdAndParentId(waterfall.items[4])).toEqual({ + id: 'mySpanIdC', + parentId: 'mySpanIdB' + }); + expect(waterfall.errorItems.length).toBe(0); + expect(waterfall.errorsCount).toEqual(0); + }); + it("shouldn't reparent spans when child id isn't found", () => { + const traceItems = [ + { + processor: { event: 'transaction' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-node' }, + transaction: { + duration: { us: 49660 }, + name: 'GET /api', + id: 'myTransactionId1' + }, + timestamp: { us: 1549324795784006 } + } as Transaction, + { + parent: { id: 'mySpanIdD' }, + processor: { event: 'span' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-ruby' }, + transaction: { id: 'myTransactionId1' }, + timestamp: { us: 1549324795825633 }, + span: { + duration: { us: 481 }, + name: 'SELECT FROM products', + id: 'mySpanIdB' + }, + child_ids: ['incorrectId', 'mySpanIdC'] + } as Span, + { + parent: { id: 'mySpanIdD' }, + processor: { event: 'span' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-ruby' }, + transaction: { id: 'myTransactionId1' }, + span: { + duration: { us: 6161 }, + name: 'Api::ProductsController#index', + id: 'mySpanIdA' + }, + timestamp: { us: 1549324795824504 } + } as Span, + { + parent: { id: 'mySpanIdD' }, + processor: { event: 'span' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-ruby' }, + transaction: { id: 'myTransactionId1' }, + span: { + duration: { us: 532 }, + name: 'SELECT FROM product', + id: 'mySpanIdC' + }, + timestamp: { us: 1549324795827905 } + } as Span, + { + parent: { id: 'myTransactionId1' }, + processor: { event: 'span' }, + trace: { id: 'myTraceId' }, + service: { name: 'opbeans-node' }, + transaction: { id: 'myTransactionId1' }, + span: { + duration: { us: 47557 }, + name: 'GET opbeans-ruby:3000/api/products', + id: 'mySpanIdD' + }, + timestamp: { us: 1549324795785760 } + } as Span + ]; + const entryTransactionId = 'myTransactionId1'; + const waterfall = getWaterfall( + { + trace: { items: traceItems, errorDocs: [], exceedsMax: false }, + errorsPerTransaction: {} + }, + entryTransactionId + ); + const getIdAndParentId = (item: IWaterfallItem) => ({ + id: item.id, + parentId: item.parent?.id + }); + expect(waterfall.items.length).toBe(5); + expect(getIdAndParentId(waterfall.items[0])).toEqual({ + id: 'myTransactionId1', + parentId: undefined + }); + expect(getIdAndParentId(waterfall.items[1])).toEqual({ + id: 'mySpanIdD', + parentId: 'myTransactionId1' + }); + expect(getIdAndParentId(waterfall.items[2])).toEqual({ + id: 'mySpanIdA', + parentId: 'mySpanIdD' + }); + expect(getIdAndParentId(waterfall.items[3])).toEqual({ + id: 'mySpanIdB', + parentId: 'mySpanIdD' + }); + expect(getIdAndParentId(waterfall.items[4])).toEqual({ + id: 'mySpanIdC', + parentId: 'mySpanIdB' + }); + expect(waterfall.errorItems.length).toBe(0); + expect(waterfall.errorsCount).toEqual(0); + }); }); describe('getWaterfallItems', () => { diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts index 58d9134c4d787..8a873b2ddf1c9 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts +++ b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/Waterfall/waterfall_helpers/waterfall_helpers.ts @@ -236,6 +236,29 @@ const getWaterfallItems = (items: TraceAPIResponse['trace']['items']) => } }); +/** + * Changes the parent_id of items based on the child_ids property. + * Solves the problem of Inferred spans that are created as child of trace spans + * when it actually should be its parent. + * @param waterfallItems + */ +const reparentSpans = (waterfallItems: IWaterfallItem[]) => { + return waterfallItems.map(waterfallItem => { + if (waterfallItem.docType === 'span') { + const { child_ids: childIds } = waterfallItem.doc; + if (childIds) { + childIds.forEach(childId => { + const item = waterfallItems.find(_item => _item.id === childId); + if (item) { + item.parentId = waterfallItem.id; + } + }); + } + } + return waterfallItem; + }); +}; + const getChildrenGroupedByParentId = (waterfallItems: IWaterfallItem[]) => groupBy(waterfallItems, item => (item.parentId ? item.parentId : ROOT_ID)); @@ -306,7 +329,9 @@ export function getWaterfall( const waterfallItems: IWaterfallItem[] = getWaterfallItems(trace.items); - const childrenByParentId = getChildrenGroupedByParentId(waterfallItems); + const childrenByParentId = getChildrenGroupedByParentId( + reparentSpans(waterfallItems) + ); const entryWaterfallTransaction = getEntryWaterfallTransaction( entryTransactionId, diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx index 938962cc9dd18..f681f4dfc675a 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx +++ b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/WaterfallContainer.stories.tsx @@ -14,7 +14,8 @@ import { urlParams, simpleTrace, traceWithErrors, - traceChildStartBeforeParent + traceChildStartBeforeParent, + inferredSpans } from './waterfallContainer.stories.data'; import { getWaterfall } from './Waterfall/waterfall_helpers/waterfall_helpers'; @@ -74,3 +75,22 @@ storiesOf('app/TransactionDetails/Waterfall', module).add( }, { info: { source: false } } ); + +storiesOf('app/TransactionDetails/Waterfall', module).add( + 'inferred spans', + () => { + const waterfall = getWaterfall( + inferredSpans as TraceAPIResponse, + 'f2387d37260d00bd' + ); + return ( + + ); + }, + { info: { source: false } } +); diff --git a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/waterfallContainer.stories.data.ts b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/waterfallContainer.stories.data.ts index 835183e73b298..306c8e4f3fedb 100644 --- a/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/waterfallContainer.stories.data.ts +++ b/x-pack/legacy/plugins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/WaterfallContainer/waterfallContainer.stories.data.ts @@ -1645,3 +1645,667 @@ export const traceChildStartBeforeParent = { }, errorsPerTransaction: {} }; + +export const inferredSpans = { + trace: { + items: [ + { + container: { + id: 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + agent: { + name: 'java', + ephemeral_id: '1cb5c830-c677-4b13-b340-ab1502f527c3', + version: '1.15.1-SNAPSHOT' + }, + process: { + pid: 6, + title: '/opt/java/openjdk/bin/java', + ppid: 1 + }, + source: { + ip: '172.18.0.8' + }, + processor: { + name: 'transaction', + event: 'transaction' + }, + url: { + path: '/api/products/2', + scheme: 'http', + port: 3000, + domain: '172.18.0.7', + full: 'http://172.18.0.7:3000/api/products/2' + }, + observer: { + hostname: '7189f754b5a3', + id: 'f32d8d9f-a9f9-4355-8370-548dfd8024dc', + ephemeral_id: 'bff20764-0195-4f78-aa84-d799fc47b954', + type: 'apm-server', + version: '8.0.0', + version_major: 8 + }, + trace: { + id: '3b0dc77f3754e5bcb9da0e4c15e0db97' + }, + '@timestamp': '2020-04-09T11:36:00.786Z', + ecs: { + version: '1.5.0' + }, + service: { + node: { + name: + 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + environment: 'production', + name: 'opbeans-java', + runtime: { + name: 'Java', + version: '11.0.6' + }, + language: { + name: 'Java', + version: '11.0.6' + }, + version: 'None' + }, + host: { + hostname: 'fc2ae281f56f', + os: { + platform: 'Linux' + }, + ip: '172.18.0.7', + name: 'fc2ae281f56f', + architecture: 'amd64' + }, + client: { + ip: '172.18.0.8' + }, + http: { + request: { + headers: { + Accept: ['*/*'], + 'User-Agent': ['Python/3.7 aiohttp/3.3.2'], + Host: ['172.18.0.7:3000'], + 'Accept-Encoding': ['gzip, deflate'] + }, + method: 'get', + socket: { + encrypted: false, + remote_address: '172.18.0.8' + } + }, + response: { + headers: { + 'Transfer-Encoding': ['chunked'], + Date: ['Thu, 09 Apr 2020 11:36:01 GMT'], + 'Content-Type': ['application/json;charset=UTF-8'] + }, + status_code: 200, + finished: true, + headers_sent: true + }, + version: '1.1' + }, + user_agent: { + original: 'Python/3.7 aiohttp/3.3.2', + name: 'Other', + device: { + name: 'Other' + } + }, + transaction: { + duration: { + us: 237537 + }, + result: 'HTTP 2xx', + name: 'APIRestController#product', + span_count: { + dropped: 0, + started: 3 + }, + id: 'f2387d37260d00bd', + type: 'request', + sampled: true + }, + timestamp: { + us: 1586432160786001 + } + }, + { + container: { + id: 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + parent: { + id: 'f2387d37260d00bd' + }, + agent: { + name: 'java', + ephemeral_id: '1cb5c830-c677-4b13-b340-ab1502f527c3', + version: '1.15.1-SNAPSHOT' + }, + process: { + pid: 6, + title: '/opt/java/openjdk/bin/java', + ppid: 1 + }, + processor: { + name: 'transaction', + event: 'span' + }, + observer: { + hostname: '7189f754b5a3', + id: 'f32d8d9f-a9f9-4355-8370-548dfd8024dc', + ephemeral_id: 'bff20764-0195-4f78-aa84-d799fc47b954', + type: 'apm-server', + version: '8.0.0', + version_major: 8 + }, + trace: { + id: '3b0dc77f3754e5bcb9da0e4c15e0db97' + }, + '@timestamp': '2020-04-09T11:36:00.810Z', + ecs: { + version: '1.5.0' + }, + service: { + node: { + name: + 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + environment: 'production', + name: 'opbeans-java', + runtime: { + name: 'Java', + version: '11.0.6' + }, + language: { + name: 'Java', + version: '11.0.6' + }, + version: 'None' + }, + host: { + hostname: 'fc2ae281f56f', + os: { + platform: 'Linux' + }, + ip: '172.18.0.7', + name: 'fc2ae281f56f', + architecture: 'amd64' + }, + transaction: { + id: 'f2387d37260d00bd' + }, + span: { + duration: { + us: 204574 + }, + subtype: 'inferred', + name: 'ServletInvocableHandlerMethod#invokeAndHandle', + id: 'a5df600bd7bd5e38', + type: 'app' + }, + timestamp: { + us: 1586432160810441 + } + }, + { + container: { + id: 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + parent: { + id: 'a5df600bd7bd5e38' + }, + agent: { + name: 'java', + ephemeral_id: '1cb5c830-c677-4b13-b340-ab1502f527c3', + version: '1.15.1-SNAPSHOT' + }, + process: { + pid: 6, + title: '/opt/java/openjdk/bin/java', + ppid: 1 + }, + processor: { + name: 'transaction', + event: 'span' + }, + observer: { + hostname: '7189f754b5a3', + id: 'f32d8d9f-a9f9-4355-8370-548dfd8024dc', + type: 'apm-server', + ephemeral_id: 'bff20764-0195-4f78-aa84-d799fc47b954', + version: '8.0.0', + version_major: 8 + }, + trace: { + id: '3b0dc77f3754e5bcb9da0e4c15e0db97' + }, + '@timestamp': '2020-04-09T11:36:00.810Z', + ecs: { + version: '1.5.0' + }, + service: { + node: { + name: + 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + environment: 'production', + name: 'opbeans-java', + runtime: { + name: 'Java', + version: '11.0.6' + }, + language: { + name: 'Java', + version: '11.0.6' + }, + version: 'None' + }, + host: { + hostname: 'fc2ae281f56f', + os: { + platform: 'Linux' + }, + ip: '172.18.0.7', + name: 'fc2ae281f56f', + architecture: 'amd64' + }, + transaction: { + id: 'f2387d37260d00bd' + }, + timestamp: { + us: 1586432160810441 + }, + span: { + duration: { + us: 102993 + }, + stacktrace: [ + { + library_frame: true, + exclude_from_grouping: false, + filename: 'InvocableHandlerMethod.java', + line: { + number: -1 + }, + function: 'doInvoke' + }, + { + exclude_from_grouping: false, + library_frame: true, + filename: 'InvocableHandlerMethod.java', + line: { + number: -1 + }, + function: 'invokeForRequest' + } + ], + subtype: 'inferred', + name: 'APIRestController#product', + id: '808dc34fc41ce522', + type: 'app' + } + }, + { + container: { + id: 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + parent: { + id: 'f2387d37260d00bd' + }, + agent: { + name: 'java', + ephemeral_id: '1cb5c830-c677-4b13-b340-ab1502f527c3', + version: '1.15.1-SNAPSHOT' + }, + process: { + pid: 6, + title: '/opt/java/openjdk/bin/java', + ppid: 1 + }, + processor: { + name: 'transaction', + event: 'span' + }, + labels: { + productId: '2' + }, + observer: { + hostname: '7189f754b5a3', + id: 'f32d8d9f-a9f9-4355-8370-548dfd8024dc', + ephemeral_id: 'bff20764-0195-4f78-aa84-d799fc47b954', + type: 'apm-server', + version: '8.0.0', + version_major: 8 + }, + trace: { + id: '3b0dc77f3754e5bcb9da0e4c15e0db97' + }, + '@timestamp': '2020-04-09T11:36:00.832Z', + ecs: { + version: '1.5.0' + }, + service: { + node: { + name: + 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + environment: 'production', + name: 'opbeans-java', + runtime: { + name: 'Java', + version: '11.0.6' + }, + language: { + name: 'Java', + version: '11.0.6' + }, + version: 'None' + }, + host: { + hostname: 'fc2ae281f56f', + os: { + platform: 'Linux' + }, + ip: '172.18.0.7', + name: 'fc2ae281f56f', + architecture: 'amd64' + }, + transaction: { + id: 'f2387d37260d00bd' + }, + timestamp: { + us: 1586432160832300 + }, + span: { + duration: { + us: 99295 + }, + name: 'OpenTracing product span', + id: '41226ae63af4f235', + type: 'unknown' + }, + child_ids: ['8d80de06aa11a6fc'] + }, + { + container: { + id: 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + parent: { + id: '808dc34fc41ce522' + }, + process: { + pid: 6, + title: '/opt/java/openjdk/bin/java', + ppid: 1 + }, + agent: { + name: 'java', + ephemeral_id: '1cb5c830-c677-4b13-b340-ab1502f527c3', + version: '1.15.1-SNAPSHOT' + }, + processor: { + name: 'transaction', + event: 'span' + }, + observer: { + hostname: '7189f754b5a3', + id: 'f32d8d9f-a9f9-4355-8370-548dfd8024dc', + ephemeral_id: 'bff20764-0195-4f78-aa84-d799fc47b954', + type: 'apm-server', + version: '8.0.0', + version_major: 8 + }, + trace: { + id: '3b0dc77f3754e5bcb9da0e4c15e0db97' + }, + '@timestamp': '2020-04-09T11:36:00.859Z', + ecs: { + version: '1.5.0' + }, + service: { + node: { + name: + 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + environment: 'production', + name: 'opbeans-java', + runtime: { + name: 'Java', + version: '11.0.6' + }, + language: { + name: 'Java', + version: '11.0.6' + }, + version: 'None' + }, + host: { + hostname: 'fc2ae281f56f', + os: { + platform: 'Linux' + }, + ip: '172.18.0.7', + name: 'fc2ae281f56f', + architecture: 'amd64' + }, + transaction: { + id: 'f2387d37260d00bd' + }, + timestamp: { + us: 1586432160859600 + }, + span: { + duration: { + us: 53835 + }, + subtype: 'inferred', + name: 'Loader#executeQueryStatement', + id: '8d80de06aa11a6fc', + type: 'app' + } + }, + { + container: { + id: 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + parent: { + id: '41226ae63af4f235' + }, + agent: { + name: 'java', + ephemeral_id: '1cb5c830-c677-4b13-b340-ab1502f527c3', + version: '1.15.1-SNAPSHOT' + }, + process: { + pid: 6, + title: '/opt/java/openjdk/bin/java', + ppid: 1 + }, + destination: { + address: 'postgres', + port: 5432 + }, + processor: { + name: 'transaction', + event: 'span' + }, + observer: { + hostname: '7189f754b5a3', + id: 'f32d8d9f-a9f9-4355-8370-548dfd8024dc', + ephemeral_id: 'bff20764-0195-4f78-aa84-d799fc47b954', + type: 'apm-server', + version: '8.0.0', + version_major: 8 + }, + trace: { + id: '3b0dc77f3754e5bcb9da0e4c15e0db97' + }, + '@timestamp': '2020-04-09T11:36:00.903Z', + ecs: { + version: '1.5.0' + }, + service: { + node: { + name: + 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + environment: 'production', + name: 'opbeans-java', + runtime: { + name: 'Java', + version: '11.0.6' + }, + language: { + name: 'Java', + version: '11.0.6' + }, + version: 'None' + }, + host: { + hostname: 'fc2ae281f56f', + os: { + platform: 'Linux' + }, + ip: '172.18.0.7', + name: 'fc2ae281f56f', + architecture: 'amd64' + }, + transaction: { + id: 'f2387d37260d00bd' + }, + timestamp: { + us: 1586432160903236 + }, + span: { + duration: { + us: 10211 + }, + subtype: 'postgresql', + destination: { + service: { + resource: 'postgresql', + name: 'postgresql', + type: 'db' + } + }, + name: 'SELECT FROM products', + action: 'query', + id: '3708d5623658182f', + type: 'db', + db: { + statement: + 'select product0_.id as col_0_0_, product0_.sku as col_1_0_, product0_.name as col_2_0_, product0_.description as col_3_0_, product0_.cost as col_4_0_, product0_.selling_price as col_5_0_, product0_.stock as col_6_0_, producttyp1_.id as col_7_0_, producttyp1_.name as col_8_0_, (select sum(orderline2_.amount) from order_lines orderline2_ where orderline2_.product_id=product0_.id) as col_9_0_ from products product0_ left outer join product_types producttyp1_ on product0_.type_id=producttyp1_.id where product0_.id=?', + type: 'sql', + user: { + name: 'postgres' + } + } + } + }, + { + container: { + id: 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + parent: { + id: '41226ae63af4f235' + }, + process: { + pid: 6, + title: '/opt/java/openjdk/bin/java', + ppid: 1 + }, + agent: { + name: 'java', + ephemeral_id: '1cb5c830-c677-4b13-b340-ab1502f527c3', + version: '1.15.1-SNAPSHOT' + }, + destination: { + address: 'postgres', + port: 5432 + }, + processor: { + name: 'transaction', + event: 'span' + }, + observer: { + hostname: '7189f754b5a3', + id: 'f32d8d9f-a9f9-4355-8370-548dfd8024dc', + ephemeral_id: 'bff20764-0195-4f78-aa84-d799fc47b954', + type: 'apm-server', + version: '8.0.0', + version_major: 8 + }, + trace: { + id: '3b0dc77f3754e5bcb9da0e4c15e0db97' + }, + '@timestamp': '2020-04-09T11:36:00.859Z', + ecs: { + version: '1.5.0' + }, + service: { + node: { + name: + 'fc2ae281f56fb84728bc9b5e6c17f3d13bbb7f4efd461158558e5c38e655abad' + }, + environment: 'production', + name: 'opbeans-java', + runtime: { + name: 'Java', + version: '11.0.6' + }, + language: { + name: 'Java', + version: '11.0.6' + }, + version: 'None' + }, + host: { + hostname: 'fc2ae281f56f', + os: { + platform: 'Linux' + }, + ip: '172.18.0.7', + name: 'fc2ae281f56f', + architecture: 'amd64' + }, + transaction: { + id: 'f2387d37260d00bd' + }, + timestamp: { + us: 1586432160859508 + }, + span: { + duration: { + us: 4503 + }, + subtype: 'postgresql', + destination: { + service: { + resource: 'postgresql', + name: 'postgresql', + type: 'db' + } + }, + name: 'empty query', + action: 'query', + id: '9871cfd612368932', + type: 'db', + db: { + rows_affected: 0, + statement: '(empty query)', + type: 'sql', + user: { + name: 'postgres' + } + } + } + } + ], + exceedsMax: false, + errorDocs: [] + }, + errorsPerTransaction: {} +}; diff --git a/x-pack/legacy/plugins/apm/public/services/rest/ml.ts b/x-pack/legacy/plugins/apm/public/services/rest/ml.ts index 1c618098b36e3..0cd1bdf907531 100644 --- a/x-pack/legacy/plugins/apm/public/services/rest/ml.ts +++ b/x-pack/legacy/plugins/apm/public/services/rest/ml.ts @@ -12,7 +12,8 @@ import { } from '../../../../../../plugins/apm/common/elasticsearch_fieldnames'; import { getMlJobId, - getMlPrefix + getMlPrefix, + encodeForMlApi } from '../../../../../../plugins/apm/common/ml_job_constants'; import { callApi } from './callApi'; import { ESFilter } from '../../../../../../plugins/apm/typings/elasticsearch'; @@ -53,13 +54,16 @@ export async function startMLJob({ http: HttpSetup; }) { const transactionIndices = await getTransactionIndices(http); - const groups = ['apm', serviceName.toLowerCase()]; + const groups = [ + 'apm', + encodeForMlApi(serviceName), + encodeForMlApi(transactionType) + ]; const filter: ESFilter[] = [ { term: { [SERVICE_NAME]: serviceName } }, { term: { [PROCESSOR_EVENT]: 'transaction' } }, { term: { [TRANSACTION_TYPE]: transactionType } } ]; - groups.push(transactionType.toLowerCase()); return callApi(http, { method: 'POST', pathname: `/api/ml/modules/setup/apm_transaction`, diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.scss b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.scss index 04f2f393d1e80..ae26a1bee99a6 100644 --- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.scss +++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.scss @@ -26,8 +26,4 @@ .euiTable { background: none; } - - .lnsExpressionRenderer { - @include euiScrollBar; - } -} \ No newline at end of file +} diff --git a/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/app/services/api.js b/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/app/services/api.js index b50c36aa8df9f..24bc7e17356e2 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/app/services/api.js +++ b/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/app/services/api.js @@ -145,9 +145,35 @@ export const updateFollowerIndex = (id, followerIndex) => { if (isUsingAdvancedSettings) { uiMetrics.push(UIM_FOLLOWER_INDEX_USE_ADVANCED_OPTIONS); } + + const { + maxReadRequestOperationCount, + maxOutstandingReadRequests, + maxReadRequestSize, + maxWriteRequestOperationCount, + maxWriteRequestSize, + maxOutstandingWriteRequests, + maxWriteBufferCount, + maxWriteBufferSize, + maxRetryDelay, + readPollTimeout, + } = followerIndex; + const request = httpClient.put(`${API_BASE_PATH}/follower_indices/${encodeURIComponent(id)}`, { - body: JSON.stringify(followerIndex), + body: JSON.stringify({ + maxReadRequestOperationCount, + maxOutstandingReadRequests, + maxReadRequestSize, + maxWriteRequestOperationCount, + maxWriteRequestSize, + maxOutstandingWriteRequests, + maxWriteBufferCount, + maxWriteBufferSize, + maxRetryDelay, + readPollTimeout, + }), }); + return trackUserRequest(request, uiMetrics); }; diff --git a/x-pack/legacy/plugins/cross_cluster_replication/server/np_ready/routes/api/follower_index.ts b/x-pack/legacy/plugins/cross_cluster_replication/server/np_ready/routes/api/follower_index.ts index 3896e1c02c915..1d7dacf4a8688 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/server/np_ready/routes/api/follower_index.ts +++ b/x-pack/legacy/plugins/cross_cluster_replication/server/np_ready/routes/api/follower_index.ts @@ -164,6 +164,18 @@ export const registerFollowerIndexRoutes = ({ router, __LEGACY }: RouteDependenc path: `${API_BASE_PATH}/follower_indices/{id}`, validate: { params: schema.object({ id: schema.string() }), + body: schema.object({ + maxReadRequestOperationCount: schema.maybe(schema.number()), + maxOutstandingReadRequests: schema.maybe(schema.number()), + maxReadRequestSize: schema.maybe(schema.string()), // byte value + maxWriteRequestOperationCount: schema.maybe(schema.number()), + maxWriteRequestSize: schema.maybe(schema.string()), // byte value + maxOutstandingWriteRequests: schema.maybe(schema.number()), + maxWriteBufferCount: schema.maybe(schema.number()), + maxWriteBufferSize: schema.maybe(schema.string()), // byte value + maxRetryDelay: schema.maybe(schema.string()), // time value + readPollTimeout: schema.maybe(schema.string()), // time value + }), }, }, licensePreRoutingFactory({ diff --git a/x-pack/legacy/plugins/logstash/README.md b/x-pack/legacy/plugins/logstash/README.md deleted file mode 100755 index 7d181249300fa..0000000000000 --- a/x-pack/legacy/plugins/logstash/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## Logstash Plugin - -This plugin adds Logstash specific UI code to x-pack. Currently this plugin adds just the management features. diff --git a/x-pack/legacy/plugins/logstash/common/lib/__tests__/get_moment.js b/x-pack/legacy/plugins/logstash/common/lib/__tests__/get_moment.js deleted file mode 100755 index 2e63b231bec32..0000000000000 --- a/x-pack/legacy/plugins/logstash/common/lib/__tests__/get_moment.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { getMoment } from '../get_moment'; - -describe('get_moment', () => { - describe('getMoment', () => { - it(`returns a moment object when passed a date`, () => { - const moment = getMoment('2017-03-30T14:53:08.121Z'); - - expect(moment.constructor.name).to.be('Moment'); - }); - - it(`returns null when passed falsy`, () => { - const results = [ - getMoment(false), - getMoment(0), - getMoment(''), - getMoment(null), - getMoment(undefined), - getMoment(NaN), - ]; - - results.forEach(result => { - expect(result).to.be(null); - }); - }); - }); -}); diff --git a/x-pack/legacy/plugins/logstash/index.js b/x-pack/legacy/plugins/logstash/index.js deleted file mode 100755 index 29f01032f3413..0000000000000 --- a/x-pack/legacy/plugins/logstash/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { resolve } from 'path'; -import { registerLicenseChecker } from './server/lib/register_license_checker'; -import { PLUGIN } from '../../../plugins/logstash/common/constants'; - -export const logstash = kibana => - new kibana.Plugin({ - id: PLUGIN.ID, - publicDir: resolve(__dirname, 'public'), - require: ['kibana', 'elasticsearch', 'xpack_main'], - configPrefix: 'xpack.logstash', - config(Joi) { - return Joi.object({ - enabled: Joi.boolean().default(true), - }).default(); - }, - uiExports: { - managementSections: [ - 'plugins/logstash/sections/pipeline_list', - 'plugins/logstash/sections/pipeline_edit', - ], - home: ['plugins/logstash/lib/register_home_feature'], - }, - init: server => { - registerLicenseChecker(server); - }, - }); diff --git a/x-pack/legacy/plugins/logstash/public/lib/register_home_feature.ts b/x-pack/legacy/plugins/logstash/public/lib/register_home_feature.ts deleted file mode 100644 index 2e1ee2afb9ce6..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/lib/register_home_feature.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { i18n } from '@kbn/i18n'; -import { npSetup } from 'ui/new_platform'; -// @ts-ignore -import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; -import { FeatureCatalogueCategory } from '../../../../../../src/plugins/home/public'; -// @ts-ignore -import { PLUGIN } from '../../../../../plugins/logstash/common/constants'; - -const { - plugins: { home }, -} = npSetup; - -const enableLinks = Boolean(xpackInfo.get(`features.${PLUGIN.ID}.enableLinks`)); - -if (enableLinks) { - home.featureCatalogue.register({ - id: 'management_logstash', - title: i18n.translate('xpack.logstash.homeFeature.logstashPipelinesTitle', { - defaultMessage: 'Logstash Pipelines', - }), - description: i18n.translate('xpack.logstash.homeFeature.logstashPipelinesDescription', { - defaultMessage: 'Create, delete, update, and clone data ingestion pipelines.', - }), - icon: 'pipelineApp', - path: '/app/kibana#/management/logstash/pipelines', - showOnHomePage: true, - category: FeatureCatalogueCategory.ADMIN, - }); -} diff --git a/x-pack/legacy/plugins/logstash/public/lib/update_management_sections/update_logstash_sections.js b/x-pack/legacy/plugins/logstash/public/lib/update_management_sections/update_logstash_sections.js deleted file mode 100755 index 8da687529c846..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/lib/update_management_sections/update_logstash_sections.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { management } from 'ui/management'; - -export function updateLogstashSections(pipelineId) { - const editSection = management.getSection('logstash/pipelines/pipeline/edit'); - const newSection = management.getSection('logstash/pipelines/pipeline/new'); - - newSection.hide(); - editSection.hide(); - - if (pipelineId) { - editSection.url = `#/management/logstash/pipelines/pipeline/${pipelineId}/edit`; - editSection.show(); - } else { - newSection.show(); - } -} diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/pipeline_edit/pipeline_edit.js b/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/pipeline_edit/pipeline_edit.js deleted file mode 100755 index 83446278fdeca..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/pipeline_edit/pipeline_edit.js +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React from 'react'; -import { render } from 'react-dom'; -import { isEmpty } from 'lodash'; -import { uiModules } from 'ui/modules'; -import { npSetup } from 'ui/new_platform'; -import { toastNotifications } from 'ui/notify'; -import { I18nContext } from 'ui/i18n'; -import { PipelineEditor } from '../../../../components/pipeline_editor'; -import 'plugins/logstash/services/license'; -import { logstashSecurity } from 'plugins/logstash/services/security'; -import 'ace'; - -const app = uiModules.get('xpack/logstash'); - -app.directive('pipelineEdit', function($injector) { - const pipelineService = $injector.get('pipelineService'); - const licenseService = $injector.get('logstashLicenseService'); - const kbnUrl = $injector.get('kbnUrl'); - const $route = $injector.get('$route'); - - return { - restrict: 'E', - link: async (scope, el) => { - const close = () => scope.$evalAsync(kbnUrl.change('/management/logstash/pipelines', {})); - const open = id => - scope.$evalAsync(kbnUrl.change(`/management/logstash/pipelines/${id}/edit`)); - - const userResource = logstashSecurity.isSecurityEnabled() - ? await npSetup.plugins.security.authc.getCurrentUser() - : null; - - render( - - - , - el[0] - ); - }, - scope: { - pipeline: '=', - }, - }; -}); diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/upgrade_failure/upgrade_failure.js b/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/upgrade_failure/upgrade_failure.js deleted file mode 100755 index 2ef99d3b47672..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/upgrade_failure/upgrade_failure.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React from 'react'; -import { render } from 'react-dom'; -import { isEmpty } from 'lodash'; -import { uiModules } from 'ui/modules'; -import { I18nContext } from 'ui/i18n'; -import { UpgradeFailure } from '../../../../components/upgrade_failure'; - -const app = uiModules.get('xpack/logstash'); - -app.directive('upgradeFailure', $injector => { - const $route = $injector.get('$route'); - const kbnUrl = $injector.get('kbnUrl'); - - return { - link: (scope, el) => { - const onRetry = () => { - $route.updateParams({ retry: true }); - $route.reload(); - }; - const onClose = () => { - scope.$evalAsync(kbnUrl.change('management/logstash/pipelines', {})); - }; - const isNewPipeline = isEmpty(scope.pipeline.id); - const isManualUpgrade = !!$route.current.params.retry; - - render( - - - , - el[0] - ); - }, - restrict: 'E', - scope: { - pipeline: '=', - }, - }; -}); diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/pipeline_edit_route.html b/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/pipeline_edit_route.html deleted file mode 100755 index e1c422d46dfdb..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/pipeline_edit_route.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/pipeline_edit_route.js b/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/pipeline_edit_route.js deleted file mode 100755 index 733f7dc3ae2e6..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/pipeline_edit_route.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import routes from 'ui/routes'; -import { toastNotifications } from 'ui/notify'; -import { i18n } from '@kbn/i18n'; -import template from './pipeline_edit_route.html'; -import 'plugins/logstash/services/pipeline'; -import 'plugins/logstash/services/license'; -import 'plugins/logstash/services/upgrade'; -import './components/pipeline_edit'; -import './components/upgrade_failure'; -import { updateLogstashSections } from 'plugins/logstash/lib/update_management_sections'; -import { Pipeline } from 'plugins/logstash/models/pipeline'; -import { getPipelineCreateBreadcrumbs, getPipelineEditBreadcrumbs } from '../breadcrumbs'; - -routes - .when('/management/logstash/pipelines/pipeline/:id/edit', { - k7Breadcrumbs: getPipelineEditBreadcrumbs, - }) - .when('/management/logstash/pipelines/new-pipeline', { - k7Breadcrumbs: getPipelineCreateBreadcrumbs, - }) - .defaults(/management\/logstash\/pipelines\/(new-pipeline|pipeline\/:id\/edit)/, { - template: template, - controller: class PipelineEditRouteController { - constructor($injector) { - const $route = $injector.get('$route'); - this.pipeline = $route.current.locals.pipeline; - this.isUpgraded = $route.current.locals.isUpgraded; - } - }, - controllerAs: 'pipelineEditRoute', - resolve: { - logstashTabs: $injector => { - const $route = $injector.get('$route'); - const pipelineId = $route.current.params.id; - updateLogstashSections(pipelineId); - }, - pipeline: function($injector) { - const $route = $injector.get('$route'); - const pipelineService = $injector.get('pipelineService'); - const licenseService = $injector.get('logstashLicenseService'); - const kbnUrl = $injector.get('kbnUrl'); - - const pipelineId = $route.current.params.id; - - if (!pipelineId) return new Pipeline(); - - return pipelineService - .loadPipeline(pipelineId) - .then(pipeline => (!!$route.current.params.clone ? pipeline.clone : pipeline)) - .catch(err => { - return licenseService.checkValidity().then(() => { - if (err.status !== 403) { - toastNotifications.addDanger( - i18n.translate('xpack.logstash.couldNotLoadPipelineErrorNotification', { - defaultMessage: `Couldn't load pipeline. Error: '{errStatusText}'.`, - values: { - errStatusText: err.statusText, - }, - }) - ); - } - - kbnUrl.redirect('/management/logstash/pipelines'); - return Promise.reject(); - }); - }); - }, - checkLicense: $injector => { - const licenseService = $injector.get('logstashLicenseService'); - return licenseService.checkValidity(); - }, - isUpgraded: $injector => { - const upgradeService = $injector.get('upgradeService'); - return upgradeService.executeUpgrade(); - }, - }, - }); - -routes.when('/management/logstash/pipelines/pipeline/:id', { - redirectTo: '/management/logstash/pipelines/pipeline/:id/edit', -}); diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/components/pipeline_list/index.js b/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/components/pipeline_list/index.js deleted file mode 100755 index 7e8ca0e4c2c57..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/components/pipeline_list/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import './pipeline_list'; diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/components/pipeline_list/pipeline_list.js b/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/components/pipeline_list/pipeline_list.js deleted file mode 100755 index b856979aed8b6..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/components/pipeline_list/pipeline_list.js +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React from 'react'; -import { render } from 'react-dom'; -import { uiModules } from 'ui/modules'; -import { toastNotifications } from 'ui/notify'; -import { I18nContext } from 'ui/i18n'; -import { PipelineList } from '../../../../components/pipeline_list'; -import 'plugins/logstash/services/pipelines'; -import 'plugins/logstash/services/license'; -import 'plugins/logstash/services/cluster'; -import 'plugins/logstash/services/monitoring'; - -const app = uiModules.get('xpack/logstash'); - -app.directive('pipelineList', function($injector) { - const pipelinesService = $injector.get('pipelinesService'); - const licenseService = $injector.get('logstashLicenseService'); - const clusterService = $injector.get('xpackLogstashClusterService'); - const monitoringService = $injector.get('xpackLogstashMonitoringService'); - const kbnUrl = $injector.get('kbnUrl'); - - return { - restrict: 'E', - link: (scope, el) => { - const openPipeline = id => - scope.$evalAsync(kbnUrl.change(`management/logstash/pipelines/pipeline/${id}/edit`)); - const createPipeline = () => - scope.$evalAsync(kbnUrl.change('management/logstash/pipelines/new-pipeline')); - const clonePipeline = id => - scope.$evalAsync(kbnUrl.change(`management/logstash/pipelines/pipeline/${id}/edit?clone`)); - render( - - - , - el[0] - ); - }, - scope: {}, - controllerAs: 'pipelineList', - }; -}); diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/index.js b/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/index.js deleted file mode 100755 index f60decd1378d5..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/index.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import './register_management_section'; -import './pipeline_list_route'; diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/pipeline_list_route.html b/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/pipeline_list_route.html deleted file mode 100755 index 55b3fabd70161..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/pipeline_list_route.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/pipeline_list_route.js b/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/pipeline_list_route.js deleted file mode 100755 index eb593207572c2..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/pipeline_list_route.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import routes from 'ui/routes'; -import { management } from 'ui/management'; -import template from './pipeline_list_route.html'; -import './components/pipeline_list'; -import 'plugins/logstash/services/license'; -import { getPipelineListBreadcrumbs } from '../breadcrumbs'; - -routes.when('/management/logstash/pipelines/', { - template, - k7Breadcrumbs: getPipelineListBreadcrumbs, -}); - -routes.defaults(/\/management/, { - resolve: { - logstashManagementSection: $injector => { - const licenseService = $injector.get('logstashLicenseService'); - const logstashSection = management.getSection('logstash/pipelines'); - - if (licenseService.enableLinks) { - logstashSection.show(); - logstashSection.enable(); - } else { - logstashSection.hide(); - } - }, - }, -}); diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/register_management_section.js b/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/register_management_section.js deleted file mode 100755 index e285418f5f2ae..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_list/register_management_section.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { management } from 'ui/management'; -import { i18n } from '@kbn/i18n'; - -management.getSection('logstash').register('pipelines', { - display: i18n.translate('xpack.logstash.managementSection.pipelinesTitle', { - defaultMessage: 'Pipelines', - }), - order: 10, - url: '#/management/logstash/pipelines/', -}); - -management.getSection('logstash/pipelines').register('pipeline', { - visible: false, -}); - -management.getSection('logstash/pipelines/pipeline').register('edit', { - display: i18n.translate('xpack.logstash.managementSection.editPipelineTitle', { - defaultMessage: 'Edit pipeline', - }), - order: 1, - visible: false, -}); - -management.getSection('logstash/pipelines/pipeline').register('new', { - display: i18n.translate('xpack.logstash.managementSection.createPipelineTitle', { - defaultMessage: 'Create pipeline', - }), - order: 1, - visible: false, -}); diff --git a/x-pack/legacy/plugins/logstash/public/services/cluster/cluster_service.factory.js b/x-pack/legacy/plugins/logstash/public/services/cluster/cluster_service.factory.js deleted file mode 100755 index 0fee2804c704d..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/cluster/cluster_service.factory.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { uiModules } from 'ui/modules'; -import { ClusterService } from './cluster_service'; - -uiModules.get('xpack/logstash').factory('xpackLogstashClusterService', $injector => { - const $http = $injector.get('$http'); - return new ClusterService($http); -}); diff --git a/x-pack/legacy/plugins/logstash/public/services/cluster/index.js b/x-pack/legacy/plugins/logstash/public/services/cluster/index.js deleted file mode 100755 index ba52657a27ca8..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/cluster/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import './cluster_service.factory'; diff --git a/x-pack/legacy/plugins/logstash/public/services/license/index.js b/x-pack/legacy/plugins/logstash/public/services/license/index.js deleted file mode 100755 index 8be8fb5ccbc64..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/license/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import './license_service.factory'; diff --git a/x-pack/legacy/plugins/logstash/public/services/license/license_service.factory.js b/x-pack/legacy/plugins/logstash/public/services/license/license_service.factory.js deleted file mode 100755 index 0e131f9b94008..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/license/license_service.factory.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { uiModules } from 'ui/modules'; -import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; -import 'ui/url'; -import { LogstashLicenseService } from './logstash_license_service'; - -uiModules.get('xpack/logstash').factory('logstashLicenseService', ($timeout, kbnUrl) => { - return new LogstashLicenseService(xpackInfo, kbnUrl, $timeout); -}); diff --git a/x-pack/legacy/plugins/logstash/public/services/license/logstash_license_service.js b/x-pack/legacy/plugins/logstash/public/services/license/logstash_license_service.js deleted file mode 100755 index 69cc8614a6ae2..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/license/logstash_license_service.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React from 'react'; -import { toastNotifications } from 'ui/notify'; -import { MarkdownSimple } from '../../../../../../../src/plugins/kibana_react/public'; -import { PLUGIN } from '../../../../../../plugins/logstash/common/constants'; - -export class LogstashLicenseService { - constructor(xpackInfoService, kbnUrlService, $timeout) { - this.xpackInfoService = xpackInfoService; - this.kbnUrlService = kbnUrlService; - this.$timeout = $timeout; - } - - get enableLinks() { - return Boolean(this.xpackInfoService.get(`features.${PLUGIN.ID}.enableLinks`)); - } - - get isAvailable() { - return Boolean(this.xpackInfoService.get(`features.${PLUGIN.ID}.isAvailable`)); - } - - get isReadOnly() { - return Boolean(this.xpackInfoService.get(`features.${PLUGIN.ID}.isReadOnly`)); - } - - get message() { - return this.xpackInfoService.get(`features.${PLUGIN.ID}.message`); - } - - notifyAndRedirect() { - toastNotifications.addDanger({ - title: ( - - {this.xpackInfoService.get(`features.${PLUGIN.ID}.message`)} - - ), - }); - this.kbnUrlService.redirect('/management'); - } - - /** - * Checks if the license is valid or the license can perform downgraded UI tasks. - * Otherwise, notifies and redirects. - */ - checkValidity() { - return new Promise((resolve, reject) => { - this.$timeout(() => { - if (this.isAvailable) { - return resolve(); - } - - this.notifyAndRedirect(); - return reject(); - }, 10); // To allow latest XHR call to update license info - }); - } -} diff --git a/x-pack/legacy/plugins/logstash/public/services/monitoring/index.js b/x-pack/legacy/plugins/logstash/public/services/monitoring/index.js deleted file mode 100755 index 83b2105beb5ef..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/monitoring/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import './monitoring_service.factory'; diff --git a/x-pack/legacy/plugins/logstash/public/services/monitoring/monitoring_service.factory.js b/x-pack/legacy/plugins/logstash/public/services/monitoring/monitoring_service.factory.js deleted file mode 100755 index 271c776dd6f69..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/monitoring/monitoring_service.factory.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { uiModules } from 'ui/modules'; -import { MonitoringService } from './monitoring_service'; -import '../cluster'; - -uiModules.get('xpack/logstash').factory('xpackLogstashMonitoringService', $injector => { - const $http = $injector.get('$http'); - const Promise = $injector.get('Promise'); - const monitoringUiEnabled = - $injector.has('monitoringUiEnabled') && $injector.get('monitoringUiEnabled'); - const clusterService = $injector.get('xpackLogstashClusterService'); - return new MonitoringService($http, Promise, monitoringUiEnabled, clusterService); -}); diff --git a/x-pack/legacy/plugins/logstash/public/services/pipeline/index.js b/x-pack/legacy/plugins/logstash/public/services/pipeline/index.js deleted file mode 100755 index 3b0e28bd555e6..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/pipeline/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import './pipeline_service.factory'; diff --git a/x-pack/legacy/plugins/logstash/public/services/pipeline/pipeline_service.factory.js b/x-pack/legacy/plugins/logstash/public/services/pipeline/pipeline_service.factory.js deleted file mode 100755 index cf93915425213..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/pipeline/pipeline_service.factory.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { uiModules } from 'ui/modules'; -import { PipelineService } from './pipeline_service'; - -uiModules.get('xpack/logstash').factory('pipelineService', $injector => { - const $http = $injector.get('$http'); - const pipelinesService = $injector.get('pipelinesService'); - return new PipelineService($http, pipelinesService); -}); diff --git a/x-pack/legacy/plugins/logstash/public/services/pipeline/pipeline_service.js b/x-pack/legacy/plugins/logstash/public/services/pipeline/pipeline_service.js deleted file mode 100755 index b5d0dbeb852d5..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/pipeline/pipeline_service.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; -import { ROUTES } from '../../../../../../plugins/logstash/common/constants'; -import { Pipeline } from 'plugins/logstash/models/pipeline'; - -export class PipelineService { - constructor($http, pipelinesService) { - this.$http = $http; - this.pipelinesService = pipelinesService; - this.basePath = chrome.addBasePath(ROUTES.API_ROOT); - } - - loadPipeline(id) { - return this.$http.get(`${this.basePath}/pipeline/${id}`).then(response => { - return Pipeline.fromUpstreamJSON(response.data); - }); - } - - savePipeline(pipelineModel) { - return this.$http - .put(`${this.basePath}/pipeline/${pipelineModel.id}`, pipelineModel.upstreamJSON) - .catch(e => { - throw e.data.message; - }); - } - - deletePipeline(id) { - return this.$http - .delete(`${this.basePath}/pipeline/${id}`) - .then(() => this.pipelinesService.addToRecentlyDeleted(id)) - .catch(e => { - throw e.data.message; - }); - } -} diff --git a/x-pack/legacy/plugins/logstash/public/services/pipelines/index.js b/x-pack/legacy/plugins/logstash/public/services/pipelines/index.js deleted file mode 100755 index e273e12d46c6d..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/pipelines/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import './pipelines_service.factory'; diff --git a/x-pack/legacy/plugins/logstash/public/services/pipelines/pipelines_service.factory.js b/x-pack/legacy/plugins/logstash/public/services/pipelines/pipelines_service.factory.js deleted file mode 100755 index 9295949e001eb..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/pipelines/pipelines_service.factory.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { uiModules } from 'ui/modules'; -import { PipelinesService } from './pipelines_service'; -import '../monitoring'; - -uiModules.get('xpack/logstash').factory('pipelinesService', $injector => { - const $http = $injector.get('$http'); - const $window = $injector.get('$window'); - const Promise = $injector.get('Promise'); - const monitoringService = $injector.get('xpackLogstashMonitoringService'); - return new PipelinesService($http, $window, Promise, monitoringService); -}); diff --git a/x-pack/legacy/plugins/logstash/public/services/pipelines/pipelines_service.js b/x-pack/legacy/plugins/logstash/public/services/pipelines/pipelines_service.js deleted file mode 100755 index d70c8be06fde4..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/pipelines/pipelines_service.js +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; -import { ROUTES, MONITORING } from '../../../../../../plugins/logstash/common/constants'; -import { PipelineListItem } from 'plugins/logstash/models/pipeline_list_item'; - -const RECENTLY_DELETED_PIPELINE_IDS_STORAGE_KEY = 'xpack.logstash.recentlyDeletedPipelines'; - -export class PipelinesService { - constructor($http, $window, Promise, monitoringService) { - this.$http = $http; - this.$window = $window; - this.Promise = Promise; - this.monitoringService = monitoringService; - this.basePath = chrome.addBasePath(ROUTES.API_ROOT); - } - - getPipelineList() { - return this.Promise.all([ - this.getManagementPipelineList(), - this.getMonitoringPipelineList(), - ]).then(([managementPipelines, monitoringPipelines]) => { - const now = Date.now(); - - // Monitoring will report centrally-managed pipelines as well, including recently-deleted centrally-managed ones. - // If there's a recently-deleted pipeline we're keeping track of BUT monitoring doesn't report it, that means - // it's not running in Logstash any more. So we can stop tracking it as a recently-deleted pipeline. - const monitoringPipelineIds = monitoringPipelines.map(pipeline => pipeline.id); - this.getRecentlyDeleted().forEach(recentlyDeletedPipeline => { - // We don't want to stop tracking the recently-deleted pipeline until Monitoring has had some - // time to report on it. Otherwise, if we stop tracking first, *then* Monitoring reports it, we'll - // still end up showing it in the list until Monitoring stops reporting it. - if (now - recentlyDeletedPipeline.deletedOn < MONITORING.ACTIVE_PIPELINE_RANGE_S * 1000) { - return; - } - - // If Monitoring is still reporting the pipeline, don't stop tracking it yet - if (monitoringPipelineIds.includes(recentlyDeletedPipeline.id)) { - return; - } - - this.removeFromRecentlyDeleted(recentlyDeletedPipeline.id); - }); - - // Merge centrally-managed pipelines with pipelines reported by monitoring. Take care to dedupe - // while merging because monitoring will (rightly) report centrally-managed pipelines as well, - // including recently-deleted ones! - const managementPipelineIds = managementPipelines.map(pipeline => pipeline.id); - return managementPipelines.concat( - monitoringPipelines.filter( - monitoringPipeline => - !managementPipelineIds.includes(monitoringPipeline.id) && - !this.isRecentlyDeleted(monitoringPipeline.id) - ) - ); - }); - } - - getManagementPipelineList() { - return this.$http - .get(`${this.basePath}/pipelines`) - .then(response => - response.data.pipelines.map(pipeline => PipelineListItem.fromUpstreamJSON(pipeline)) - ); - } - - getMonitoringPipelineList() { - return this.monitoringService.getPipelineList(); - } - - /** - * Delete a collection of pipelines - * - * @param pipelineIds Array of pipeline IDs - * @return Promise { numSuccesses, numErrors } - */ - deletePipelines(pipelineIds) { - const body = { - pipelineIds, - }; - return this.$http.post(`${this.basePath}/pipelines/delete`, body).then(response => { - this.addToRecentlyDeleted(...pipelineIds); - return response.data.results; - }); - } - - addToRecentlyDeleted(...pipelineIds) { - const recentlyDeletedPipelines = this.getRecentlyDeleted(); - const recentlyDeletedPipelineIds = recentlyDeletedPipelines.map(pipeline => pipeline.id); - pipelineIds.forEach(pipelineId => { - if (!recentlyDeletedPipelineIds.includes(pipelineId)) { - recentlyDeletedPipelines.push({ - id: pipelineId, - deletedOn: Date.now(), - }); - } - }); - this.setRecentlyDeleted(recentlyDeletedPipelines); - } - - removeFromRecentlyDeleted(...pipelineIds) { - const recentlyDeletedPipelinesToKeep = this.getRecentlyDeleted().filter( - recentlyDeletedPipeline => !pipelineIds.includes(recentlyDeletedPipeline.id) - ); - this.setRecentlyDeleted(recentlyDeletedPipelinesToKeep); - } - - isRecentlyDeleted(pipelineId) { - return this.getRecentlyDeleted() - .map(pipeline => pipeline.id) - .includes(pipelineId); - } - - getRecentlyDeleted() { - const recentlyDeletedPipelines = this.$window.localStorage.getItem( - RECENTLY_DELETED_PIPELINE_IDS_STORAGE_KEY - ); - if (!recentlyDeletedPipelines) { - return []; - } - - return JSON.parse(recentlyDeletedPipelines); - } - - setRecentlyDeleted(recentlyDeletedPipelineIds) { - this.$window.localStorage.setItem( - RECENTLY_DELETED_PIPELINE_IDS_STORAGE_KEY, - JSON.stringify(recentlyDeletedPipelineIds) - ); - } -} diff --git a/x-pack/legacy/plugins/logstash/public/services/security/index.js b/x-pack/legacy/plugins/logstash/public/services/security/index.js deleted file mode 100755 index c9ff911723156..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/security/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { logstashSecurity } from './logstash_security'; diff --git a/x-pack/legacy/plugins/logstash/public/services/upgrade/index.js b/x-pack/legacy/plugins/logstash/public/services/upgrade/index.js deleted file mode 100755 index 345d0d0ff68c6..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/upgrade/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import './upgrade_service.factory'; diff --git a/x-pack/legacy/plugins/logstash/public/services/upgrade/upgrade_service.factory.js b/x-pack/legacy/plugins/logstash/public/services/upgrade/upgrade_service.factory.js deleted file mode 100755 index 925c6ae677bdf..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/upgrade/upgrade_service.factory.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { uiModules } from 'ui/modules'; -import { UpgradeService } from './upgrade_service'; - -uiModules.get('xpack/logstash').factory('upgradeService', $injector => { - const $http = $injector.get('$http'); - return new UpgradeService($http); -}); diff --git a/x-pack/legacy/plugins/logstash/public/services/upgrade/upgrade_service.js b/x-pack/legacy/plugins/logstash/public/services/upgrade/upgrade_service.js deleted file mode 100755 index 2019bdc1bf1aa..0000000000000 --- a/x-pack/legacy/plugins/logstash/public/services/upgrade/upgrade_service.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import chrome from 'ui/chrome'; -import { ROUTES } from '../../../../../../plugins/logstash/common/constants'; - -export class UpgradeService { - constructor($http) { - this.$http = $http; - this.basePath = chrome.addBasePath(ROUTES.API_ROOT); - } - - executeUpgrade() { - return this.$http - .post(`${this.basePath}/upgrade`) - .then(response => response.data.is_upgraded) - .catch(e => { - throw e.data.message; - }); - } -} diff --git a/x-pack/legacy/plugins/logstash/server/lib/check_license/__tests__/check_license.js b/x-pack/legacy/plugins/logstash/server/lib/check_license/__tests__/check_license.js deleted file mode 100755 index 5fcce0aaa1219..0000000000000 --- a/x-pack/legacy/plugins/logstash/server/lib/check_license/__tests__/check_license.js +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { set } from 'lodash'; -import { checkLicense } from '../check_license'; - -describe('check_license', function() { - let mockLicenseInfo; - beforeEach(() => (mockLicenseInfo = {})); - - describe('license information is undefined', () => { - beforeEach(() => (mockLicenseInfo = undefined)); - - it('should set isAvailable to false', () => { - expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false); - }); - - it('should set enableLinks to false', () => { - expect(checkLicense(mockLicenseInfo).enableLinks).to.be(false); - }); - - it('should set isReadOnly to false', () => { - expect(checkLicense(mockLicenseInfo).isReadOnly).to.be(false); - }); - - it('should set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined); - }); - }); - - describe('license information is not available', () => { - beforeEach(() => (mockLicenseInfo.isAvailable = () => false)); - - it('should set isAvailable to false', () => { - expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false); - }); - - it('should set enableLinks to false', () => { - expect(checkLicense(mockLicenseInfo).enableLinks).to.be(false); - }); - - it('should set isReadOnly to false', () => { - expect(checkLicense(mockLicenseInfo).isReadOnly).to.be(false); - }); - - it('should set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined); - }); - }); - - describe('license information is available', () => { - beforeEach(() => { - mockLicenseInfo.isAvailable = () => true; - set(mockLicenseInfo, 'license.getType', () => 'basic'); - }); - - describe('& license is > basic', () => { - beforeEach(() => { - set(mockLicenseInfo, 'license.isOneOf', () => true); - mockLicenseInfo.feature = () => ({ isEnabled: () => true }); // Security feature is enabled - }); - - describe('& license is active', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => true)); - - it('should set isAvailable to true', () => { - expect(checkLicense(mockLicenseInfo).isAvailable).to.be(true); - }); - - it('should set enableLinks to true', () => { - expect(checkLicense(mockLicenseInfo).enableLinks).to.be(true); - }); - - it('should set isReadOnly to false', () => { - expect(checkLicense(mockLicenseInfo).isReadOnly).to.be(false); - }); - - it('should not set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.be(undefined); - }); - }); - - describe('& license is expired', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => false)); - - it('should set isAvailable to true', () => { - expect(checkLicense(mockLicenseInfo).isAvailable).to.be(true); - }); - - it('should set enableLinks to true', () => { - expect(checkLicense(mockLicenseInfo).enableLinks).to.be(true); - }); - - it('should set isReadOnly to true', () => { - expect(checkLicense(mockLicenseInfo).isReadOnly).to.be(true); - }); - - it('should set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined); - }); - }); - }); - - describe('& license is basic', () => { - beforeEach(() => { - set(mockLicenseInfo, 'license.isOneOf', () => false); - mockLicenseInfo.feature = () => ({ isEnabled: () => true }); // Security feature is enabled - }); - - describe('& license is active', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => true)); - - it('should set isAvailable to false', () => { - expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false); - }); - - it('should set enableLinks to false', () => { - expect(checkLicense(mockLicenseInfo).enableLinks).to.be(false); - }); - - it('should set isReadOnly to false', () => { - expect(checkLicense(mockLicenseInfo).isReadOnly).to.be(false); - }); - - it('should set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined); - }); - }); - - describe('& license is expired', () => { - beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => false)); - - it('should set isAvailable to false', () => { - expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false); - }); - - it('should set enableLinks to false', () => { - expect(checkLicense(mockLicenseInfo).enableLinks).to.be(false); - }); - - it('should set isReadOnly to false', () => { - expect(checkLicense(mockLicenseInfo).isReadOnly).to.be(false); - }); - - it('should set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined); - }); - }); - }); - - describe('& security is disabled', () => { - beforeEach(() => { - mockLicenseInfo.feature = () => ({ isEnabled: () => false }); // Security feature is disabled - set(mockLicenseInfo, 'license.isOneOf', () => true); - set(mockLicenseInfo, 'license.isActive', () => true); - }); - - it('should set isAvailable to false', () => { - expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false); - }); - - it('should set enableLinks to false', () => { - expect(checkLicense(mockLicenseInfo).enableLinks).to.be(false); - }); - - it('should set isReadOnly to false', () => { - expect(checkLicense(mockLicenseInfo).isReadOnly).to.be(false); - }); - - it('should set a message', () => { - expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined); - }); - }); - }); -}); diff --git a/x-pack/legacy/plugins/logstash/server/lib/check_license/check_license.js b/x-pack/legacy/plugins/logstash/server/lib/check_license/check_license.js deleted file mode 100755 index 31136ae1c72a5..0000000000000 --- a/x-pack/legacy/plugins/logstash/server/lib/check_license/check_license.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { i18n } from '@kbn/i18n'; - -export function checkLicense(xpackLicenseInfo) { - // If, for some reason, we cannot get the license information - // from Elasticsearch, assume worst case and disable the Logstash pipeline UI - if (!xpackLicenseInfo || !xpackLicenseInfo.isAvailable()) { - return { - isAvailable: false, - enableLinks: false, - isReadOnly: false, - message: i18n.translate( - 'xpack.logstash.managementSection.notPossibleToManagePipelinesMessage', - { - defaultMessage: - 'You cannot manage Logstash pipelines because license information is not available at this time.', - } - ), - }; - } - - const VALID_LICENSE_MODES = ['trial', 'standard', 'gold', 'platinum', 'enterprise']; - - const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_LICENSE_MODES); - const isLicenseActive = xpackLicenseInfo.license.isActive(); - const licenseType = xpackLicenseInfo.license.getType(); - const isSecurityEnabled = xpackLicenseInfo.feature('security').isEnabled(); - - // Security is not enabled in ES - if (!isSecurityEnabled) { - const message = i18n.translate('xpack.logstash.managementSection.enableSecurityDescription', { - defaultMessage: - 'Security must be enabled in order to use Logstash pipeline management features.' + - ' Please set xpack.security.enabled: true in your elasticsearch.yml.', - }); - return { - isAvailable: false, - enableLinks: false, - isReadOnly: false, - message, - }; - } - - // License is not valid - if (!isLicenseModeValid) { - return { - isAvailable: false, - enableLinks: false, - isReadOnly: false, - message: i18n.translate('xpack.logstash.managementSection.licenseDoesNotSupportDescription', { - defaultMessage: - 'Your {licenseType} license does not support Logstash pipeline management features. Please upgrade your license.', - values: { licenseType }, - }), - }; - } - - // License is valid but not active, we go into a read-only mode. - if (!isLicenseActive) { - return { - isAvailable: true, - enableLinks: true, - isReadOnly: true, - message: i18n.translate( - 'xpack.logstash.managementSection.pipelineCrudOperationsNotAllowedDescription', - { - defaultMessage: - 'You cannot edit, create, or delete your Logstash pipelines because your {licenseType} license has expired.', - values: { licenseType }, - } - ), - }; - } - - // License is valid and active - return { - isAvailable: true, - enableLinks: true, - isReadOnly: false, - }; -} diff --git a/x-pack/legacy/plugins/logstash/server/lib/check_license/index.js b/x-pack/legacy/plugins/logstash/server/lib/check_license/index.js deleted file mode 100755 index f2c070fd44b6e..0000000000000 --- a/x-pack/legacy/plugins/logstash/server/lib/check_license/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { checkLicense } from './check_license'; diff --git a/x-pack/legacy/plugins/logstash/server/lib/register_license_checker/index.js b/x-pack/legacy/plugins/logstash/server/lib/register_license_checker/index.js deleted file mode 100755 index 7b0f97c38d129..0000000000000 --- a/x-pack/legacy/plugins/logstash/server/lib/register_license_checker/index.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { registerLicenseChecker } from './register_license_checker'; diff --git a/x-pack/legacy/plugins/logstash/server/lib/register_license_checker/register_license_checker.js b/x-pack/legacy/plugins/logstash/server/lib/register_license_checker/register_license_checker.js deleted file mode 100755 index a0d06e77b410d..0000000000000 --- a/x-pack/legacy/plugins/logstash/server/lib/register_license_checker/register_license_checker.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { mirrorPluginStatus } from '../../../../../server/lib/mirror_plugin_status'; -import { checkLicense } from '../check_license'; -import { PLUGIN } from '../../../../../../plugins/logstash/common/constants'; - -export function registerLicenseChecker(server) { - const xpackMainPlugin = server.plugins.xpack_main; - const logstashPlugin = server.plugins.logstash; - - mirrorPluginStatus(xpackMainPlugin, logstashPlugin); - xpackMainPlugin.status.once('green', () => { - // Register a function that is called whenever the xpack info changes, - // to re-compute the license check results for this plugin - xpackMainPlugin.info.feature(PLUGIN.ID).registerLicenseCheckResultsGenerator(checkLicense); - }); -} diff --git a/x-pack/legacy/plugins/maps/common/constants.ts b/x-pack/legacy/plugins/maps/common/constants.ts deleted file mode 100644 index 98945653c25dc..0000000000000 --- a/x-pack/legacy/plugins/maps/common/constants.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export * from '../../../../plugins/maps/common/constants'; diff --git a/x-pack/legacy/plugins/maps/common/descriptor_types.ts b/x-pack/legacy/plugins/maps/common/descriptor_types.ts deleted file mode 100644 index 1f0eda26e7f7d..0000000000000 --- a/x-pack/legacy/plugins/maps/common/descriptor_types.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export * from '../../../../plugins/maps/common/descriptor_types'; diff --git a/x-pack/legacy/plugins/maps/common/i18n_getters.ts b/x-pack/legacy/plugins/maps/common/i18n_getters.ts deleted file mode 100644 index f9d186dea2e2b..0000000000000 --- a/x-pack/legacy/plugins/maps/common/i18n_getters.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export * from '../../../../plugins/maps/common/i18n_getters'; diff --git a/x-pack/legacy/plugins/maps/common/parse_xml_string.js b/x-pack/legacy/plugins/maps/common/parse_xml_string.js deleted file mode 100644 index 34ec144472828..0000000000000 --- a/x-pack/legacy/plugins/maps/common/parse_xml_string.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export * from '../../../../plugins/maps/common/parse_xml_string'; diff --git a/x-pack/legacy/plugins/maps/index.js b/x-pack/legacy/plugins/maps/index.js index 1a7f478d3bbad..8546e3712c763 100644 --- a/x-pack/legacy/plugins/maps/index.js +++ b/x-pack/legacy/plugins/maps/index.js @@ -9,9 +9,14 @@ import mappings from './mappings.json'; import { i18n } from '@kbn/i18n'; import { resolve } from 'path'; import { migrations } from './migrations'; -import { getAppTitle } from './common/i18n_getters'; +import { getAppTitle } from '../../../plugins/maps/common/i18n_getters'; import { MapPlugin } from './server/plugin'; -import { APP_ID, APP_ICON, createMapPath, MAP_SAVED_OBJECT_TYPE } from './common/constants'; +import { + APP_ID, + APP_ICON, + createMapPath, + MAP_SAVED_OBJECT_TYPE, +} from '../../../plugins/maps/common/constants'; import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/utils'; export function maps(kibana) { @@ -38,6 +43,7 @@ export function maps(kibana) { return { showMapVisualizationTypes: serverConfig.get('xpack.maps.showMapVisualizationTypes'), showMapsInspectorAdapter: serverConfig.get('xpack.maps.showMapsInspectorAdapter'), + enableVectorTiles: serverConfig.get('xpack.maps.enableVectorTiles'), preserveDrawingBuffer: serverConfig.get('xpack.maps.preserveDrawingBuffer'), isEmsEnabled: mapConfig.includeElasticMapsService, emsFontLibraryUrl: mapConfig.emsFontLibraryUrl, @@ -52,7 +58,6 @@ export function maps(kibana) { }; }, embeddableFactories: ['plugins/maps/embeddable/map_embeddable_factory'], - home: ['plugins/maps/legacy_register_feature'], styleSheetPaths: `${__dirname}/public/index.scss`, savedObjectSchemas: { 'maps-telemetry': { @@ -77,7 +82,6 @@ export function maps(kibana) { }, mappings, migrations, - hacks: ['plugins/maps/register_vis_type_alias'], }, config(Joi) { return Joi.object({ @@ -85,6 +89,7 @@ export function maps(kibana) { showMapVisualizationTypes: Joi.boolean().default(false), showMapsInspectorAdapter: Joi.boolean().default(false), // flag used in functional testing preserveDrawingBuffer: Joi.boolean().default(false), // flag used in functional testing + enableVectorTiles: Joi.boolean().default(false), // flag used to enable/disable vector-tiles }).default(); }, diff --git a/x-pack/legacy/plugins/maps/migrations.js b/x-pack/legacy/plugins/maps/migrations.js index 6a1f5bc937497..d3666025082b7 100644 --- a/x-pack/legacy/plugins/maps/migrations.js +++ b/x-pack/legacy/plugins/maps/migrations.js @@ -4,13 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { extractReferences } from './common/migrations/references'; -import { emsRasterTileToEmsVectorTile } from './common/migrations/ems_raster_tile_to_ems_vector_tile'; -import { topHitsTimeToSort } from './common/migrations/top_hits_time_to_sort'; -import { moveApplyGlobalQueryToSources } from './common/migrations/move_apply_global_query'; -import { addFieldMetaOptions } from './common/migrations/add_field_meta_options'; -import { migrateSymbolStyleDescriptor } from './common/migrations/migrate_symbol_style_descriptor'; -import { migrateUseTopHitsToScalingType } from './common/migrations/scaling_type'; +import { extractReferences } from '../../../plugins/maps/common/migrations/references'; +import { emsRasterTileToEmsVectorTile } from '../../../plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile'; +import { topHitsTimeToSort } from '../../../plugins/maps/common/migrations/top_hits_time_to_sort'; +import { moveApplyGlobalQueryToSources } from '../../../plugins/maps/common/migrations/move_apply_global_query'; +import { addFieldMetaOptions } from '../../../plugins/maps/common/migrations/add_field_meta_options'; +import { migrateSymbolStyleDescriptor } from '../../../plugins/maps/common/migrations/migrate_symbol_style_descriptor'; +import { migrateUseTopHitsToScalingType } from '../../../plugins/maps/common/migrations/scaling_type'; +import { migrateJoinAggKey } from '../../../plugins/maps/common/migrations/join_agg_key'; export const migrations = { map: { @@ -57,5 +58,13 @@ export const migrations = { attributes: attributesPhase2, }; }, + '7.8.0': doc => { + const attributes = migrateJoinAggKey(doc); + + return { + ...doc, + attributes, + }; + }, }, }; diff --git a/x-pack/legacy/plugins/maps/public/actions/map_actions.d.ts b/x-pack/legacy/plugins/maps/public/actions/map_actions.d.ts deleted file mode 100644 index 34f8c30b51874..0000000000000 --- a/x-pack/legacy/plugins/maps/public/actions/map_actions.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -/* eslint-disable @typescript-eslint/consistent-type-definitions */ - -export * from '../../../../../plugins/maps/public/actions/map_actions'; diff --git a/x-pack/legacy/plugins/maps/public/actions/map_actions.js b/x-pack/legacy/plugins/maps/public/actions/map_actions.js deleted file mode 100644 index 7bfbf5761c5b8..0000000000000 --- a/x-pack/legacy/plugins/maps/public/actions/map_actions.js +++ /dev/null @@ -1,978 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import _ from 'lodash'; -import turf from 'turf'; -import turfBooleanContains from '@turf/boolean-contains'; -import uuid from 'uuid/v4'; -import { - getLayerList, - getLayerListRaw, - getDataFilters, - getSelectedLayerId, - getMapReady, - getWaitingForMapReadyLayerListRaw, - getTransientLayerId, - getOpenTooltips, - getQuery, - getDataRequestDescriptor, -} from '../selectors/map_selectors'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { FLYOUT_STATE } from '../../../../../plugins/maps/public/reducers/ui'; -import { - cancelRequest, - registerCancelCallback, - unregisterCancelCallback, - getEventHandlers, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../plugins/maps/public/reducers/non_serializable_instances'; -import { updateFlyout } from '../actions/ui_actions'; -import { - FEATURE_ID_PROPERTY_NAME, - LAYER_TYPE, - SOURCE_DATA_ID_ORIGIN, -} from '../../common/constants'; - -import { - SET_SELECTED_LAYER, - SET_TRANSIENT_LAYER, - UPDATE_LAYER_ORDER, - ADD_LAYER, - SET_LAYER_ERROR_STATUS, - ADD_WAITING_FOR_MAP_READY_LAYER, - CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST, - REMOVE_LAYER, - SET_LAYER_VISIBILITY, - MAP_EXTENT_CHANGED, - MAP_READY, - MAP_DESTROYED, - LAYER_DATA_LOAD_STARTED, - LAYER_DATA_LOAD_ENDED, - LAYER_DATA_LOAD_ERROR, - UPDATE_SOURCE_DATA_REQUEST, - SET_JOINS, - SET_QUERY, - TRIGGER_REFRESH_TIMER, - UPDATE_LAYER_PROP, - UPDATE_LAYER_STYLE, - SET_LAYER_STYLE_META, - UPDATE_SOURCE_PROP, - SET_REFRESH_CONFIG, - SET_MOUSE_COORDINATES, - CLEAR_MOUSE_COORDINATES, - SET_GOTO, - CLEAR_GOTO, - TRACK_CURRENT_LAYER_STATE, - ROLLBACK_TO_TRACKED_LAYER_STATE, - REMOVE_TRACKED_LAYER_STATE, - SET_OPEN_TOOLTIPS, - UPDATE_DRAW_STATE, - SET_SCROLL_ZOOM, - SET_MAP_INIT_ERROR, - SET_INTERACTIVE, - DISABLE_TOOLTIP_CONTROL, - HIDE_TOOLBAR_OVERLAY, - HIDE_LAYER_CONTROL, - HIDE_VIEW_CONTROL, - SET_WAITING_FOR_READY_HIDDEN_LAYERS, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../plugins/maps/public/actions/map_actions'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export * from '../../../../../plugins/maps/public/actions/map_actions'; - -function getLayerLoadingCallbacks(dispatch, getState, layerId) { - return { - startLoading: (dataId, requestToken, meta) => - dispatch(startDataLoad(layerId, dataId, requestToken, meta)), - stopLoading: (dataId, requestToken, data, meta) => - dispatch(endDataLoad(layerId, dataId, requestToken, data, meta)), - onLoadError: (dataId, requestToken, errorMessage) => - dispatch(onDataLoadError(layerId, dataId, requestToken, errorMessage)), - updateSourceData: newData => { - dispatch(updateSourceDataRequest(layerId, newData)); - }, - isRequestStillActive: (dataId, requestToken) => { - const dataRequest = getDataRequestDescriptor(getState(), layerId, dataId); - if (!dataRequest) { - return false; - } - return dataRequest.dataRequestToken === requestToken; - }, - registerCancelCallback: (requestToken, callback) => - dispatch(registerCancelCallback(requestToken, callback)), - }; -} - -function getLayerById(layerId, state) { - return getLayerList(state).find(layer => { - return layerId === layer.getId(); - }); -} - -async function syncDataForAllLayers(dispatch, getState, dataFilters) { - const state = getState(); - const layerList = getLayerList(state); - const syncs = layerList.map(layer => { - const loadingFunctions = getLayerLoadingCallbacks(dispatch, getState, layer.getId()); - return layer.syncData({ ...loadingFunctions, dataFilters }); - }); - await Promise.all(syncs); -} - -export function cancelAllInFlightRequests() { - return (dispatch, getState) => { - getLayerList(getState()).forEach(layer => { - dispatch(clearDataRequests(layer)); - }); - }; -} - -function clearDataRequests(layer) { - return dispatch => { - layer.getInFlightRequestTokens().forEach(requestToken => { - dispatch(cancelRequest(requestToken)); - }); - dispatch({ - type: UPDATE_LAYER_PROP, - id: layer.getId(), - propName: '__dataRequests', - newValue: [], - }); - }; -} - -export function setMapInitError(errorMessage) { - return { - type: SET_MAP_INIT_ERROR, - errorMessage, - }; -} - -export function trackCurrentLayerState(layerId) { - return { - type: TRACK_CURRENT_LAYER_STATE, - layerId: layerId, - }; -} - -export function rollbackToTrackedLayerStateForSelectedLayer() { - return async (dispatch, getState) => { - const layerId = getSelectedLayerId(getState()); - await dispatch({ - type: ROLLBACK_TO_TRACKED_LAYER_STATE, - layerId: layerId, - }); - - // Ensure updateStyleMeta is triggered - // syncDataForLayer may not trigger endDataLoad if no re-fetch is required - dispatch(updateStyleMeta(layerId)); - - dispatch(syncDataForLayer(layerId)); - }; -} - -export function removeTrackedLayerStateForSelectedLayer() { - return (dispatch, getState) => { - const layerId = getSelectedLayerId(getState()); - dispatch({ - type: REMOVE_TRACKED_LAYER_STATE, - layerId: layerId, - }); - }; -} - -export function replaceLayerList(newLayerList) { - return (dispatch, getState) => { - const isMapReady = getMapReady(getState()); - if (!isMapReady) { - dispatch({ - type: CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST, - }); - } else { - getLayerListRaw(getState()).forEach(({ id }) => { - dispatch(removeLayerFromLayerList(id)); - }); - } - - newLayerList.forEach(layerDescriptor => { - dispatch(addLayer(layerDescriptor)); - }); - }; -} - -export function cloneLayer(layerId) { - return async (dispatch, getState) => { - const layer = getLayerById(layerId, getState()); - if (!layer) { - return; - } - - const clonedDescriptor = await layer.cloneDescriptor(); - dispatch(addLayer(clonedDescriptor)); - }; -} - -export function addLayer(layerDescriptor) { - return (dispatch, getState) => { - const isMapReady = getMapReady(getState()); - if (!isMapReady) { - dispatch({ - type: ADD_WAITING_FOR_MAP_READY_LAYER, - layer: layerDescriptor, - }); - return; - } - - dispatch({ - type: ADD_LAYER, - layer: layerDescriptor, - }); - dispatch(syncDataForLayer(layerDescriptor.id)); - }; -} - -// Do not use when rendering a map. Method exists to enable selectors for getLayerList when -// rendering is not needed. -export function addLayerWithoutDataSync(layerDescriptor) { - return { - type: ADD_LAYER, - layer: layerDescriptor, - }; -} - -function setLayerDataLoadErrorStatus(layerId, errorMessage) { - return dispatch => { - dispatch({ - type: SET_LAYER_ERROR_STATUS, - isInErrorState: errorMessage !== null, - layerId, - errorMessage, - }); - }; -} - -export function cleanTooltipStateForLayer(layerId, layerFeatures = []) { - return (dispatch, getState) => { - let featuresRemoved = false; - const openTooltips = getOpenTooltips(getState()) - .map(tooltipState => { - const nextFeatures = tooltipState.features.filter(tooltipFeature => { - if (tooltipFeature.layerId !== layerId) { - // feature from another layer, keep it - return true; - } - - // Keep feature if it is still in layer - return layerFeatures.some(layerFeature => { - return layerFeature.properties[FEATURE_ID_PROPERTY_NAME] === tooltipFeature.id; - }); - }); - - if (tooltipState.features.length !== nextFeatures.length) { - featuresRemoved = true; - } - - return { ...tooltipState, features: nextFeatures }; - }) - .filter(tooltipState => { - return tooltipState.features.length > 0; - }); - - if (featuresRemoved) { - dispatch({ - type: SET_OPEN_TOOLTIPS, - openTooltips, - }); - } - }; -} - -export function setLayerVisibility(layerId, makeVisible) { - return async (dispatch, getState) => { - //if the current-state is invisible, we also want to sync data - //e.g. if a layer was invisible at start-up, it won't have any data loaded - const layer = getLayerById(layerId, getState()); - - // If the layer visibility is already what we want it to be, do nothing - if (!layer || layer.isVisible() === makeVisible) { - return; - } - - if (!makeVisible) { - dispatch(cleanTooltipStateForLayer(layerId)); - } - - await dispatch({ - type: SET_LAYER_VISIBILITY, - layerId, - visibility: makeVisible, - }); - if (makeVisible) { - dispatch(syncDataForLayer(layerId)); - } - }; -} - -export function toggleLayerVisible(layerId) { - return async (dispatch, getState) => { - const layer = getLayerById(layerId, getState()); - if (!layer) { - return; - } - const makeVisible = !layer.isVisible(); - - dispatch(setLayerVisibility(layerId, makeVisible)); - }; -} - -export function setSelectedLayer(layerId) { - return async (dispatch, getState) => { - const oldSelectedLayer = getSelectedLayerId(getState()); - if (oldSelectedLayer) { - await dispatch(rollbackToTrackedLayerStateForSelectedLayer()); - } - if (layerId) { - dispatch(trackCurrentLayerState(layerId)); - } - dispatch({ - type: SET_SELECTED_LAYER, - selectedLayerId: layerId, - }); - }; -} - -export function removeTransientLayer() { - return async (dispatch, getState) => { - const transientLayerId = getTransientLayerId(getState()); - if (transientLayerId) { - await dispatch(removeLayerFromLayerList(transientLayerId)); - await dispatch(setTransientLayer(null)); - } - }; -} - -export function setTransientLayer(layerId) { - return { - type: SET_TRANSIENT_LAYER, - transientLayerId: layerId, - }; -} - -export function clearTransientLayerStateAndCloseFlyout() { - return async dispatch => { - await dispatch(updateFlyout(FLYOUT_STATE.NONE)); - await dispatch(setSelectedLayer(null)); - await dispatch(removeTransientLayer()); - }; -} - -export function updateLayerOrder(newLayerOrder) { - return { - type: UPDATE_LAYER_ORDER, - newLayerOrder, - }; -} - -export function mapReady() { - return (dispatch, getState) => { - dispatch({ - type: MAP_READY, - }); - - getWaitingForMapReadyLayerListRaw(getState()).forEach(layerDescriptor => { - dispatch(addLayer(layerDescriptor)); - }); - - dispatch({ - type: CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST, - }); - }; -} - -export function mapDestroyed() { - return { - type: MAP_DESTROYED, - }; -} - -export function mapExtentChanged(newMapConstants) { - return async (dispatch, getState) => { - const state = getState(); - const dataFilters = getDataFilters(state); - const { extent, zoom: newZoom } = newMapConstants; - const { buffer, zoom: currentZoom } = dataFilters; - - if (extent) { - let doesBufferContainExtent = false; - if (buffer) { - const bufferGeometry = turf.bboxPolygon([ - buffer.minLon, - buffer.minLat, - buffer.maxLon, - buffer.maxLat, - ]); - const extentGeometry = turf.bboxPolygon([ - extent.minLon, - extent.minLat, - extent.maxLon, - extent.maxLat, - ]); - - doesBufferContainExtent = turfBooleanContains(bufferGeometry, extentGeometry); - } - - if (!doesBufferContainExtent || currentZoom !== newZoom) { - const scaleFactor = 0.5; // TODO put scale factor in store and fetch with selector - const width = extent.maxLon - extent.minLon; - const height = extent.maxLat - extent.minLat; - dataFilters.buffer = { - minLon: extent.minLon - width * scaleFactor, - minLat: extent.minLat - height * scaleFactor, - maxLon: extent.maxLon + width * scaleFactor, - maxLat: extent.maxLat + height * scaleFactor, - }; - } - } - - dispatch({ - type: MAP_EXTENT_CHANGED, - mapState: { - ...dataFilters, - ...newMapConstants, - }, - }); - const newDataFilters = { ...dataFilters, ...newMapConstants }; - await syncDataForAllLayers(dispatch, getState, newDataFilters); - }; -} - -export function closeOnClickTooltip(tooltipId) { - return (dispatch, getState) => { - dispatch({ - type: SET_OPEN_TOOLTIPS, - openTooltips: getOpenTooltips(getState()).filter(({ id }) => { - return tooltipId !== id; - }), - }); - }; -} - -export function openOnClickTooltip(tooltipState) { - return (dispatch, getState) => { - const openTooltips = getOpenTooltips(getState()).filter(({ features, location, isLocked }) => { - return ( - isLocked && - !_.isEqual(location, tooltipState.location) && - !_.isEqual(features, tooltipState.features) - ); - }); - - openTooltips.push({ - ...tooltipState, - isLocked: true, - id: uuid(), - }); - - dispatch({ - type: SET_OPEN_TOOLTIPS, - openTooltips, - }); - }; -} - -export function closeOnHoverTooltip() { - return (dispatch, getState) => { - if (getOpenTooltips(getState()).length) { - dispatch({ - type: SET_OPEN_TOOLTIPS, - openTooltips: [], - }); - } - }; -} - -export function openOnHoverTooltip(tooltipState) { - return { - type: SET_OPEN_TOOLTIPS, - openTooltips: [ - { - ...tooltipState, - isLocked: false, - id: uuid(), - }, - ], - }; -} - -export function setMouseCoordinates({ lat, lon }) { - let safeLon = lon; - if (lon > 180) { - const overlapWestOfDateLine = lon - 180; - safeLon = -180 + overlapWestOfDateLine; - } else if (lon < -180) { - const overlapEastOfDateLine = Math.abs(lon) - 180; - safeLon = 180 - overlapEastOfDateLine; - } - - return { - type: SET_MOUSE_COORDINATES, - lat, - lon: safeLon, - }; -} - -export function clearMouseCoordinates() { - return { type: CLEAR_MOUSE_COORDINATES }; -} - -export function disableScrollZoom() { - return { type: SET_SCROLL_ZOOM, scrollZoom: false }; -} - -export function fitToLayerExtent(layerId) { - return async function(dispatch, getState) { - const targetLayer = getLayerById(layerId, getState()); - - if (targetLayer) { - const dataFilters = getDataFilters(getState()); - const bounds = await targetLayer.getBounds(dataFilters); - if (bounds) { - await dispatch(setGotoWithBounds(bounds)); - } - } - }; -} - -export function setGotoWithBounds(bounds) { - return { - type: SET_GOTO, - bounds: bounds, - }; -} - -export function setGotoWithCenter({ lat, lon, zoom }) { - return { - type: SET_GOTO, - center: { lat, lon, zoom }, - }; -} - -export function clearGoto() { - return { type: CLEAR_GOTO }; -} - -export function startDataLoad(layerId, dataId, requestToken, meta = {}) { - return (dispatch, getState) => { - const layer = getLayerById(layerId, getState()); - if (layer) { - dispatch(cancelRequest(layer.getPrevRequestToken(dataId))); - } - - const eventHandlers = getEventHandlers(getState()); - if (eventHandlers && eventHandlers.onDataLoad) { - eventHandlers.onDataLoad({ - layerId, - dataId, - }); - } - - dispatch({ - meta, - type: LAYER_DATA_LOAD_STARTED, - layerId, - dataId, - requestToken, - }); - }; -} - -export function updateSourceDataRequest(layerId, newData) { - return dispatch => { - dispatch({ - type: UPDATE_SOURCE_DATA_REQUEST, - dataId: SOURCE_DATA_ID_ORIGIN, - layerId, - newData, - }); - - dispatch(updateStyleMeta(layerId)); - }; -} - -export function endDataLoad(layerId, dataId, requestToken, data, meta) { - return async (dispatch, getState) => { - dispatch(unregisterCancelCallback(requestToken)); - - const features = data && data.features ? data.features : []; - - const eventHandlers = getEventHandlers(getState()); - if (eventHandlers && eventHandlers.onDataLoadEnd) { - const layer = getLayerById(layerId, getState()); - const resultMeta = {}; - if (layer && layer.getType() === LAYER_TYPE.VECTOR) { - resultMeta.featuresCount = features.length; - } - - eventHandlers.onDataLoadEnd({ - layerId, - dataId, - resultMeta, - }); - } - - dispatch(cleanTooltipStateForLayer(layerId, features)); - dispatch({ - type: LAYER_DATA_LOAD_ENDED, - layerId, - dataId, - data, - meta, - requestToken, - }); - - //Clear any data-load errors when there is a succesful data return. - //Co this on end-data-load iso at start-data-load to avoid blipping the error status between true/false. - //This avoids jitter in the warning icon of the TOC when the requests continues to return errors. - dispatch(setLayerDataLoadErrorStatus(layerId, null)); - - dispatch(updateStyleMeta(layerId)); - }; -} - -export function onDataLoadError(layerId, dataId, requestToken, errorMessage) { - return async (dispatch, getState) => { - dispatch(unregisterCancelCallback(requestToken)); - - const eventHandlers = getEventHandlers(getState()); - if (eventHandlers && eventHandlers.onDataLoadError) { - eventHandlers.onDataLoadError({ - layerId, - dataId, - errorMessage, - }); - } - - dispatch(cleanTooltipStateForLayer(layerId)); - dispatch({ - type: LAYER_DATA_LOAD_ERROR, - data: null, - layerId, - dataId, - requestToken, - }); - - dispatch(setLayerDataLoadErrorStatus(layerId, errorMessage)); - }; -} - -export function updateSourceProp(layerId, propName, value, newLayerType) { - return async dispatch => { - dispatch({ - type: UPDATE_SOURCE_PROP, - layerId, - propName, - value, - }); - if (newLayerType) { - dispatch(updateLayerType(layerId, newLayerType)); - } - await dispatch(clearMissingStyleProperties(layerId)); - dispatch(syncDataForLayer(layerId)); - }; -} - -function updateLayerType(layerId, newLayerType) { - return (dispatch, getState) => { - const layer = getLayerById(layerId, getState()); - if (!layer || layer.getType() === newLayerType) { - return; - } - dispatch(clearDataRequests(layer)); - dispatch({ - type: UPDATE_LAYER_PROP, - id: layerId, - propName: 'type', - newValue: newLayerType, - }); - }; -} - -export function syncDataForLayer(layerId) { - return async (dispatch, getState) => { - const targetLayer = getLayerById(layerId, getState()); - if (targetLayer) { - const dataFilters = getDataFilters(getState()); - const loadingFunctions = getLayerLoadingCallbacks(dispatch, getState, layerId); - await targetLayer.syncData({ - ...loadingFunctions, - dataFilters, - }); - } - }; -} - -export function updateLayerLabel(id, newLabel) { - return { - type: UPDATE_LAYER_PROP, - id, - propName: 'label', - newValue: newLabel, - }; -} - -export function updateLayerMinZoom(id, minZoom) { - return { - type: UPDATE_LAYER_PROP, - id, - propName: 'minZoom', - newValue: minZoom, - }; -} - -export function updateLayerMaxZoom(id, maxZoom) { - return { - type: UPDATE_LAYER_PROP, - id, - propName: 'maxZoom', - newValue: maxZoom, - }; -} - -export function updateLayerAlpha(id, alpha) { - return { - type: UPDATE_LAYER_PROP, - id, - propName: 'alpha', - newValue: alpha, - }; -} - -export function setLayerQuery(id, query) { - return dispatch => { - dispatch({ - type: UPDATE_LAYER_PROP, - id, - propName: 'query', - newValue: query, - }); - - dispatch(syncDataForLayer(id)); - }; -} - -export function removeSelectedLayer() { - return (dispatch, getState) => { - const state = getState(); - const layerId = getSelectedLayerId(state); - dispatch(removeLayer(layerId)); - }; -} - -export function removeLayer(layerId) { - return async (dispatch, getState) => { - const state = getState(); - const selectedLayerId = getSelectedLayerId(state); - if (layerId === selectedLayerId) { - dispatch(updateFlyout(FLYOUT_STATE.NONE)); - await dispatch(setSelectedLayer(null)); - } - dispatch(removeLayerFromLayerList(layerId)); - }; -} - -function removeLayerFromLayerList(layerId) { - return (dispatch, getState) => { - const layerGettingRemoved = getLayerById(layerId, getState()); - if (!layerGettingRemoved) { - return; - } - - layerGettingRemoved.getInFlightRequestTokens().forEach(requestToken => { - dispatch(cancelRequest(requestToken)); - }); - dispatch(cleanTooltipStateForLayer(layerId)); - layerGettingRemoved.destroy(); - dispatch({ - type: REMOVE_LAYER, - id: layerId, - }); - }; -} - -export function setQuery({ query, timeFilters, filters = [], refresh = false }) { - function generateQueryTimestamp() { - return new Date().toISOString(); - } - return async (dispatch, getState) => { - const prevQuery = getQuery(getState()); - const prevTriggeredAt = - prevQuery && prevQuery.queryLastTriggeredAt - ? prevQuery.queryLastTriggeredAt - : generateQueryTimestamp(); - - dispatch({ - type: SET_QUERY, - timeFilters, - query: { - ...query, - // ensure query changes to trigger re-fetch when "Refresh" clicked - queryLastTriggeredAt: refresh ? generateQueryTimestamp() : prevTriggeredAt, - }, - filters, - }); - - const dataFilters = getDataFilters(getState()); - await syncDataForAllLayers(dispatch, getState, dataFilters); - }; -} - -export function setRefreshConfig({ isPaused, interval }) { - return { - type: SET_REFRESH_CONFIG, - isPaused, - interval, - }; -} - -export function triggerRefreshTimer() { - return async (dispatch, getState) => { - dispatch({ - type: TRIGGER_REFRESH_TIMER, - }); - - const dataFilters = getDataFilters(getState()); - await syncDataForAllLayers(dispatch, getState, dataFilters); - }; -} - -export function clearMissingStyleProperties(layerId) { - return async (dispatch, getState) => { - const targetLayer = getLayerById(layerId, getState()); - if (!targetLayer) { - return; - } - - const style = targetLayer.getCurrentStyle(); - if (!style) { - return; - } - - const nextFields = await targetLayer.getFields(); //take into account all fields, since labels can be driven by any field (source or join) - const { hasChanges, nextStyleDescriptor } = style.getDescriptorWithMissingStylePropsRemoved( - nextFields - ); - if (hasChanges) { - dispatch(updateLayerStyle(layerId, nextStyleDescriptor)); - } - }; -} - -export function updateLayerStyle(layerId, styleDescriptor) { - return dispatch => { - dispatch({ - type: UPDATE_LAYER_STYLE, - layerId, - style: { - ...styleDescriptor, - }, - }); - - // Ensure updateStyleMeta is triggered - // syncDataForLayer may not trigger endDataLoad if no re-fetch is required - dispatch(updateStyleMeta(layerId)); - - // Style update may require re-fetch, for example ES search may need to retrieve field used for dynamic styling - dispatch(syncDataForLayer(layerId)); - }; -} - -export function updateStyleMeta(layerId) { - return async (dispatch, getState) => { - const layer = getLayerById(layerId, getState()); - if (!layer) { - return; - } - const sourceDataRequest = layer.getSourceDataRequest(); - const style = layer.getCurrentStyle(); - if (!style || !sourceDataRequest) { - return; - } - const styleMeta = await style.pluckStyleMetaFromSourceDataRequest(sourceDataRequest); - dispatch({ - type: SET_LAYER_STYLE_META, - layerId, - styleMeta, - }); - }; -} - -export function updateLayerStyleForSelectedLayer(styleDescriptor) { - return (dispatch, getState) => { - const selectedLayerId = getSelectedLayerId(getState()); - if (!selectedLayerId) { - return; - } - dispatch(updateLayerStyle(selectedLayerId, styleDescriptor)); - }; -} - -export function setJoinsForLayer(layer, joins) { - return async dispatch => { - await dispatch({ - type: SET_JOINS, - layer: layer, - joins: joins, - }); - - await dispatch(clearMissingStyleProperties(layer.getId())); - dispatch(syncDataForLayer(layer.getId())); - }; -} - -export function updateDrawState(drawState) { - return dispatch => { - if (drawState !== null) { - dispatch({ type: SET_OPEN_TOOLTIPS, openTooltips: [] }); // tooltips just get in the way - } - dispatch({ - type: UPDATE_DRAW_STATE, - drawState: drawState, - }); - }; -} - -export function disableInteractive() { - return { type: SET_INTERACTIVE, disableInteractive: true }; -} - -export function disableTooltipControl() { - return { type: DISABLE_TOOLTIP_CONTROL, disableTooltipControl: true }; -} - -export function hideToolbarOverlay() { - return { type: HIDE_TOOLBAR_OVERLAY, hideToolbarOverlay: true }; -} - -export function hideLayerControl() { - return { type: HIDE_LAYER_CONTROL, hideLayerControl: true }; -} -export function hideViewControl() { - return { type: HIDE_VIEW_CONTROL, hideViewControl: true }; -} - -export function setHiddenLayers(hiddenLayerIds) { - return (dispatch, getState) => { - const isMapReady = getMapReady(getState()); - - if (!isMapReady) { - dispatch({ type: SET_WAITING_FOR_READY_HIDDEN_LAYERS, hiddenLayerIds }); - } else { - getLayerListRaw(getState()).forEach(layer => - dispatch(setLayerVisibility(layer.id, !hiddenLayerIds.includes(layer.id))) - ); - } - }; -} diff --git a/x-pack/legacy/plugins/maps/public/actions/ui_actions.js b/x-pack/legacy/plugins/maps/public/actions/ui_actions.js deleted file mode 100644 index 33ab2fd74122a..0000000000000 --- a/x-pack/legacy/plugins/maps/public/actions/ui_actions.js +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { - UPDATE_FLYOUT, - CLOSE_SET_VIEW, - OPEN_SET_VIEW, - SET_IS_LAYER_TOC_OPEN, - SET_FULL_SCREEN, - SET_READ_ONLY, - SET_OPEN_TOC_DETAILS, - SHOW_TOC_DETAILS, - HIDE_TOC_DETAILS, - UPDATE_INDEXING_STAGE, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../plugins/maps/public/actions/ui_actions'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -export * from '../../../../../plugins/maps/public/actions/ui_actions'; - -export function exitFullScreen() { - return { - type: SET_FULL_SCREEN, - isFullScreen: false, - }; -} - -export function updateFlyout(display) { - return { - type: UPDATE_FLYOUT, - display, - }; -} -export function closeSetView() { - return { - type: CLOSE_SET_VIEW, - }; -} -export function openSetView() { - return { - type: OPEN_SET_VIEW, - }; -} -export function setIsLayerTOCOpen(isLayerTOCOpen) { - return { - type: SET_IS_LAYER_TOC_OPEN, - isLayerTOCOpen, - }; -} -export function enableFullScreen() { - return { - type: SET_FULL_SCREEN, - isFullScreen: true, - }; -} -export function setReadOnly(isReadOnly) { - return { - type: SET_READ_ONLY, - isReadOnly, - }; -} - -export function setOpenTOCDetails(layerIds) { - return { - type: SET_OPEN_TOC_DETAILS, - layerIds, - }; -} - -export function showTOCDetails(layerId) { - return { - type: SHOW_TOC_DETAILS, - layerId, - }; -} - -export function hideTOCDetails(layerId) { - return { - type: HIDE_TOC_DETAILS, - layerId, - }; -} - -export function updateIndexingStage(stage) { - return { - type: UPDATE_INDEXING_STAGE, - stage, - }; -} diff --git a/x-pack/legacy/plugins/maps/public/angular/get_initial_layers.js b/x-pack/legacy/plugins/maps/public/angular/get_initial_layers.js deleted file mode 100644 index 686259aeaaba4..0000000000000 --- a/x-pack/legacy/plugins/maps/public/angular/get_initial_layers.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import _ from 'lodash'; -// Import each layer type, even those not used, to init in registry -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../../plugins/maps/public/layers/sources/wms_source'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../../plugins/maps/public/layers/sources/ems_file_source'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../../plugins/maps/public/layers/sources/es_search_source'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../../plugins/maps/public/layers/sources/es_pew_pew_source/es_pew_pew_source'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../../plugins/maps/public/layers/sources/kibana_regionmap_source'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../../plugins/maps/public/layers/sources/es_geo_grid_source'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../../plugins/maps/public/layers/sources/xyz_tms_source'; - -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { KibanaTilemapSource } from '../../../../../plugins/maps/public/layers/sources/kibana_tilemap_source'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { EMSTMSSource } from '../../../../../plugins/maps/public/layers/sources/ems_tms_source'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getInjectedVarFunc } from '../../../../../plugins/maps/public/kibana_services'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getKibanaTileMap } from '../../../../../plugins/maps/public/meta'; - -export function getInitialLayers(layerListJSON, initialLayers = []) { - if (layerListJSON) { - return JSON.parse(layerListJSON); - } - - const tilemapSourceFromKibana = getKibanaTileMap(); - if (_.get(tilemapSourceFromKibana, 'url')) { - const sourceDescriptor = KibanaTilemapSource.createDescriptor(); - const source = new KibanaTilemapSource(sourceDescriptor); - const layer = source.createDefaultLayer(); - return [layer.toLayerDescriptor(), ...initialLayers]; - } - - const isEmsEnabled = getInjectedVarFunc()('isEmsEnabled', true); - if (isEmsEnabled) { - const descriptor = EMSTMSSource.createDescriptor({ isAutoSelect: true }); - const source = new EMSTMSSource(descriptor); - const layer = source.createDefaultLayer(); - return [layer.toLayerDescriptor(), ...initialLayers]; - } - - return initialLayers; -} diff --git a/x-pack/legacy/plugins/maps/public/angular/map_controller.js b/x-pack/legacy/plugins/maps/public/angular/map_controller.js index 6bc8a4d0be5ac..9522fd12ad37d 100644 --- a/x-pack/legacy/plugins/maps/public/angular/map_controller.js +++ b/x-pack/legacy/plugins/maps/public/angular/map_controller.js @@ -28,8 +28,10 @@ import { // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { createMapStore } from '../../../../../plugins/maps/public/reducers/store'; import { Provider } from 'react-redux'; -import { GisMap } from '../connected_components/gis_map'; -import { addHelpMenuToAppChrome } from '../help_menu_util'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { GisMap } from '../../../../../plugins/maps/public/connected_components/gis_map'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { addHelpMenuToAppChrome } from '../../../../../plugins/maps/public/help_menu_util'; import { setSelectedLayer, setRefreshConfig, @@ -37,7 +39,8 @@ import { replaceLayerList, setQuery, clearTransientLayerStateAndCloseFlyout, -} from '../actions/map_actions'; + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../plugins/maps/public/actions/map_actions'; import { DEFAULT_IS_LAYER_TOC_OPEN, FLYOUT_STATE, @@ -49,22 +52,29 @@ import { setReadOnly, setIsLayerTOCOpen, setOpenTOCDetails, -} from '../actions/ui_actions'; -import { getIsFullScreen } from '../selectors/ui_selectors'; + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../plugins/maps/public/actions/ui_actions'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getIsFullScreen } from '../../../../../plugins/maps/public/selectors/ui_selectors'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { copyPersistentState } from '../../../../../plugins/maps/public/reducers/util'; import { getQueryableUniqueIndexPatternIds, hasDirtyState, getLayerListRaw, -} from '../selectors/map_selectors'; + // eslint-disable-next-line @kbn/eslint/no-restricted-paths +} from '../../../../../plugins/maps/public/selectors/map_selectors'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { getInspectorAdapters } from '../../../../../plugins/maps/public/reducers/non_serializable_instances'; -import { getInitialLayers } from './get_initial_layers'; -import { getInitialQuery } from './get_initial_query'; -import { getInitialTimeFilters } from './get_initial_time_filters'; -import { getInitialRefreshConfig } from './get_initial_refresh_config'; -import { MAP_SAVED_OBJECT_TYPE, MAP_APP_PATH } from '../../common/constants'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInitialLayers } from '../../../../../plugins/maps/public/angular/get_initial_layers'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInitialQuery } from '../../../../../plugins/maps/public/angular/get_initial_query'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInitialTimeFilters } from '../../../../../plugins/maps/public/angular/get_initial_time_filters'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getInitialRefreshConfig } from '../../../../../plugins/maps/public/angular/get_initial_refresh_config'; +import { MAP_SAVED_OBJECT_TYPE, MAP_APP_PATH } from '../../../../../plugins/maps/common/constants'; import { npSetup, npStart } from 'ui/new_platform'; import { esFilters } from '../../../../../../src/plugins/data/public'; import { diff --git a/x-pack/legacy/plugins/maps/public/components/_index.scss b/x-pack/legacy/plugins/maps/public/components/_index.scss deleted file mode 100644 index 0b32719442424..0000000000000 --- a/x-pack/legacy/plugins/maps/public/components/_index.scss +++ /dev/null @@ -1,3 +0,0 @@ -@import './metric_editors'; -@import './geometry_filter'; -@import './tooltip_selector'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/_index.scss b/x-pack/legacy/plugins/maps/public/connected_components/_index.scss deleted file mode 100644 index 99a2e222ea6c1..0000000000000 --- a/x-pack/legacy/plugins/maps/public/connected_components/_index.scss +++ /dev/null @@ -1,6 +0,0 @@ -@import './gis_map/gis_map'; -@import './layer_addpanel/source_select/index'; -@import './layer_panel/index'; -@import './widget_overlay/index'; -@import './toolbar_overlay/index'; -@import './map/features_tooltip/index'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_select/_index.scss b/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_select/_index.scss deleted file mode 100644 index 7fe1396fcca16..0000000000000 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_select/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import './source_select'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/_index.scss b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/_index.scss deleted file mode 100644 index fd074edf032fa..0000000000000 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/_index.scss +++ /dev/null @@ -1,4 +0,0 @@ -@import './layer_panel'; -@import './filter_editor/filter_editor'; -@import './join_editor/resources/join'; -@import './style_settings/style_settings'; \ No newline at end of file diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.d.ts b/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.d.ts deleted file mode 100644 index cf4fdc7be70c6..0000000000000 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -/* eslint-disable @typescript-eslint/consistent-type-definitions */ - -export * from '../../../../../../plugins/maps/public/connected_components/layer_panel/view'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/utils.js b/x-pack/legacy/plugins/maps/public/connected_components/map/mb/utils.js deleted file mode 100644 index a1d1341b7c4f7..0000000000000 --- a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/utils.js +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import _ from 'lodash'; -import { - loadSpriteSheetImageData, - addSpriteSheetToMapFromImageData, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../../../plugins/maps/public/connected_components/map/mb/utils'; - -export { loadSpriteSheetImageData, addSpriteSheetToMapFromImageData }; - -export function removeOrphanedSourcesAndLayers(mbMap, layerList) { - const mbStyle = mbMap.getStyle(); - - const mbLayerIdsToRemove = []; - mbStyle.layers.forEach(mbLayer => { - const layer = layerList.find(layer => { - return layer.ownsMbLayerId(mbLayer.id); - }); - if (!layer) { - mbLayerIdsToRemove.push(mbLayer.id); - } - }); - mbLayerIdsToRemove.forEach(mbLayerId => mbMap.removeLayer(mbLayerId)); - - const mbSourcesToRemove = []; - for (const mbSourceId in mbStyle.sources) { - if (mbStyle.sources.hasOwnProperty(mbSourceId)) { - const layer = layerList.find(layer => { - return layer.ownsMbSourceId(mbSourceId); - }); - if (!layer) { - mbSourcesToRemove.push(mbSourceId); - } - } - } - mbSourcesToRemove.forEach(mbSourceId => mbMap.removeSource(mbSourceId)); -} - -/** - * This is function assumes only a single layer moved in the layerList, compared to mbMap - * It is optimized to minimize the amount of mbMap.moveLayer calls. - * @param mbMap - * @param layerList - */ -export function syncLayerOrderForSingleLayer(mbMap, layerList) { - if (!layerList || layerList.length === 0) { - return; - } - - const mbLayers = mbMap.getStyle().layers.slice(); - const layerIds = mbLayers.map(mbLayer => { - const layer = layerList.find(layer => layer.ownsMbLayerId(mbLayer.id)); - return layer.getId(); - }); - - const currentLayerOrderLayerIds = _.uniq(layerIds); - - const newLayerOrderLayerIdsUnfiltered = layerList.map(l => l.getId()); - const newLayerOrderLayerIds = newLayerOrderLayerIdsUnfiltered.filter(layerId => - currentLayerOrderLayerIds.includes(layerId) - ); - - let netPos = 0; - let netNeg = 0; - const movementArr = currentLayerOrderLayerIds.reduce((accu, id, idx) => { - const movement = newLayerOrderLayerIds.findIndex(newOId => newOId === id) - idx; - movement > 0 ? netPos++ : movement < 0 && netNeg++; - accu.push({ id, movement }); - return accu; - }, []); - if (netPos === 0 && netNeg === 0) { - return; - } - const movedLayerId = - (netPos >= netNeg && movementArr.find(l => l.movement < 0).id) || - (netPos < netNeg && movementArr.find(l => l.movement > 0).id); - const nextLayerIdx = newLayerOrderLayerIds.findIndex(layerId => layerId === movedLayerId) + 1; - - let nextMbLayerId; - if (nextLayerIdx === newLayerOrderLayerIds.length) { - nextMbLayerId = null; - } else { - const foundLayer = mbLayers.find(({ id: mbLayerId }) => { - const layerId = newLayerOrderLayerIds[nextLayerIdx]; - const layer = layerList.find(layer => layer.getId() === layerId); - return layer.ownsMbLayerId(mbLayerId); - }); - nextMbLayerId = foundLayer.id; - } - - const movedLayer = layerList.find(layer => layer.getId() === movedLayerId); - mbLayers.forEach(({ id: mbLayerId }) => { - if (movedLayer.ownsMbLayerId(mbLayerId)) { - mbMap.moveLayer(mbLayerId, nextMbLayerId); - } - }); -} - -export async function addSpritesheetToMap(json, imgUrl, mbMap) { - const imgData = await loadSpriteSheetImageData(imgUrl); - addSpriteSheetToMapFromImageData(json, imgData, mbMap); -} diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/_index.scss b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/_index.scss deleted file mode 100644 index cc1ab35039dac..0000000000000 --- a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/_index.scss +++ /dev/null @@ -1,6 +0,0 @@ -@import './mixins'; - -@import './widget_overlay'; -@import './attribution_control/attribution_control'; -@import './layer_control/index'; -@import './view_control/view_control'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/_index.scss b/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/_index.scss deleted file mode 100644 index 761ef9d17b4c2..0000000000000 --- a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/_index.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import './layer_control'; -@import './layer_toc/toc_entry/toc_entry'; diff --git a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts index 96c3baf634a83..90b17412377f5 100644 --- a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts +++ b/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable_factory.ts @@ -4,153 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ -import _ from 'lodash'; -import { i18n } from '@kbn/i18n'; +/* + Maintain legacy embeddable legacy present while apps switch over + */ + import { npSetup, npStart } from 'ui/new_platform'; -import { IIndexPattern } from 'src/plugins/data/public'; -// @ts-ignore -import { getMapsSavedObjectLoader } from '../angular/services/gis_map_saved_object_loader'; -import { MapEmbeddable, MapEmbeddableInput } from './map_embeddable'; import { - getIndexPatternService, - getHttp, - getMapsCapabilities, + bindSetupCoreAndPlugins, + bindStartCoreAndPlugins, // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../plugins/maps/public/kibana_services'; -import { - EmbeddableFactoryDefinition, - IContainer, -} from '../../../../../../src/plugins/embeddable/public'; - -import { createMapPath, MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants'; +} from '../../../../../plugins/maps/public/plugin'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { createMapStore } from '../../../../../plugins/maps/public/reducers/store'; -import { addLayerWithoutDataSync } from '../actions/map_actions'; -import { getQueryableUniqueIndexPatternIds } from '../selectors/map_selectors'; -import { getInitialLayers } from '../angular/get_initial_layers'; -import { mergeInputWithSavedMap } from './merge_input_with_saved_map'; -import '../angular/services/gis_map_saved_object_loader'; -// @ts-ignore -import { - bindSetupCoreAndPlugins as bindNpSetupCoreAndPlugins, - bindStartCoreAndPlugins as bindNpStartCoreAndPlugins, -} from '../../../../../plugins/maps/public/plugin'; // eslint-disable-line @kbn/eslint/no-restricted-paths - -export class MapEmbeddableFactory implements EmbeddableFactoryDefinition { - type = MAP_SAVED_OBJECT_TYPE; - savedObjectMetaData = { - name: i18n.translate('xpack.maps.mapSavedObjectLabel', { - defaultMessage: 'Map', - }), - type: MAP_SAVED_OBJECT_TYPE, - getIconForSavedObject: () => APP_ICON, - }; - constructor() { - // Init required services. Necessary while in legacy - bindNpSetupCoreAndPlugins(npSetup.core, npSetup.plugins); - bindNpStartCoreAndPlugins(npStart.core, npStart.plugins); - } - - async isEditable() { - return getMapsCapabilities().save as boolean; - } - - // Not supported yet for maps types. - canCreateNew() { - return false; - } - - getDisplayName() { - return i18n.translate('xpack.maps.embeddableDisplayName', { - defaultMessage: 'map', - }); - } - - async _getIndexPatterns(layerList: unknown[]): Promise { - // Need to extract layerList from store to get queryable index pattern ids - const store = createMapStore(); - let queryableIndexPatternIds; - try { - layerList.forEach((layerDescriptor: unknown) => { - store.dispatch(addLayerWithoutDataSync(layerDescriptor)); - }); - queryableIndexPatternIds = getQueryableUniqueIndexPatternIds(store.getState()); - } catch (error) { - throw new Error( - i18n.translate('xpack.maps.mapEmbeddableFactory.invalidLayerList', { - defaultMessage: 'Unable to load map, malformed layer list', - }) - ); - } - - const promises = queryableIndexPatternIds.map(async indexPatternId => { - try { - return await getIndexPatternService().get(indexPatternId); - } catch (error) { - // Unable to load index pattern, better to not throw error so map embeddable can render - // Error will be surfaced by map embeddable since it too will be unable to locate the index pattern - return null; - } - }); - const indexPatterns = await Promise.all(promises); - return _.compact(indexPatterns) as IIndexPattern[]; - } - - async _fetchSavedMap(savedObjectId: string) { - const savedObjectLoader = getMapsSavedObjectLoader(); - return await savedObjectLoader.get(savedObjectId); - } - - createFromSavedObject = async ( - savedObjectId: string, - input: MapEmbeddableInput, - parent?: IContainer - ) => { - const savedMap = await this._fetchSavedMap(savedObjectId); - const layerList = getInitialLayers(savedMap.layerListJSON); - const indexPatterns = await this._getIndexPatterns(layerList); - - const embeddable = new MapEmbeddable( - { - layerList, - title: savedMap.title, - editUrl: getHttp().basePath.prepend(createMapPath(savedObjectId)), - indexPatterns, - editable: await this.isEditable(), - }, - input, - parent - ); - - try { - embeddable.updateInput(mergeInputWithSavedMap(input, savedMap)); - } catch (error) { - throw new Error( - i18n.translate('xpack.maps.mapEmbeddableFactory.invalidSavedObject', { - defaultMessage: 'Unable to load map, malformed saved object', - }) - ); - } - - return embeddable; - }; +import { MAP_SAVED_OBJECT_TYPE } from '../../../../../plugins/maps/common/constants'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { MapEmbeddableFactory } from '../../../../../plugins/maps/public/embeddable'; - create = async (input: MapEmbeddableInput, parent?: IContainer) => { - const layerList = getInitialLayers(); - const indexPatterns = await this._getIndexPatterns(layerList); +bindSetupCoreAndPlugins(npSetup.core, npSetup.plugins); +bindStartCoreAndPlugins(npStart.core, npStart.plugins); - return new MapEmbeddable( - { - layerList, - title: input.title ?? '', - indexPatterns, - editable: false, - }, - input, - parent - ); - }; -} +export * from '../../../../../plugins/maps/public/embeddable/map_embeddable_factory'; npSetup.plugins.embeddable.registerEmbeddableFactory( MAP_SAVED_OBJECT_TYPE, diff --git a/x-pack/legacy/plugins/maps/public/index.scss b/x-pack/legacy/plugins/maps/public/index.scss index b2ac514299d80..b2a228f01b921 100644 --- a/x-pack/legacy/plugins/maps/public/index.scss +++ b/x-pack/legacy/plugins/maps/public/index.scss @@ -1,17 +1,3 @@ -// Import the EUI global scope so we can use EUI constants -@import 'src/legacy/ui/public/styles/_styling_constants'; - /* GIS plugin styles */ -// Prefix all styles with "map" to avoid conflicts. -// Examples -// mapChart -// mapChart__legend -// mapChart__legend--small -// mapChart__legend-isLoading - -@import './main'; -@import './mapbox_hacks'; -@import './connected_components/index'; -@import './components/index'; -@import '../../../../plugins/maps/public/layers/index'; +@import '../../../../plugins/maps/public/index'; diff --git a/x-pack/legacy/plugins/maps/public/index.ts b/x-pack/legacy/plugins/maps/public/index.ts index 8555594e909d3..98db26859297b 100644 --- a/x-pack/legacy/plugins/maps/public/index.ts +++ b/x-pack/legacy/plugins/maps/public/index.ts @@ -15,15 +15,14 @@ import 'uiExports/embeddableActions'; import 'ui/autoload/all'; import 'react-vis/dist/style.css'; - -import './angular/services/gis_map_saved_object_loader'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import '../../../../plugins/maps/public/angular/services/gis_map_saved_object_loader'; import './angular/map_controller'; import './routes'; // @ts-ignore -import { PluginInitializerContext } from 'kibana/public'; import { MapsPlugin } from './plugin'; -export const plugin = (initializerContext: PluginInitializerContext) => { +export const plugin = () => { return new MapsPlugin(); }; @@ -32,4 +31,4 @@ export { RenderTooltipContentParams, ITooltipProperty, } from '../../../../plugins/maps/public/layers/tooltips/tooltip_property'; -export { MapEmbeddable, MapEmbeddableInput } from './embeddable'; +export { MapEmbeddable, MapEmbeddableInput } from '../../../../plugins/maps/public/embeddable'; diff --git a/x-pack/legacy/plugins/maps/public/legacy.ts b/x-pack/legacy/plugins/maps/public/legacy.ts index 96d9e09c1d09a..bcbfca17755fb 100644 --- a/x-pack/legacy/plugins/maps/public/legacy.ts +++ b/x-pack/legacy/plugins/maps/public/legacy.ts @@ -7,10 +7,9 @@ import { npSetup, npStart } from 'ui/new_platform'; // @ts-ignore Untyped Module import { uiModules } from 'ui/modules'; -import { PluginInitializerContext } from 'kibana/public'; // eslint-disable-line import/order import { plugin } from '.'; -const pluginInstance = plugin({} as PluginInitializerContext); +const pluginInstance = plugin(); const setupPlugins = { __LEGACY: { diff --git a/x-pack/legacy/plugins/maps/public/legacy_register_feature.ts b/x-pack/legacy/plugins/maps/public/legacy_register_feature.ts deleted file mode 100644 index 00f788f267d4b..0000000000000 --- a/x-pack/legacy/plugins/maps/public/legacy_register_feature.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { npSetup } from 'ui/new_platform'; -import { featureCatalogueEntry } from './feature_catalogue_entry'; - -const { - plugins: { home }, -} = npSetup; - -home.featureCatalogue.register(featureCatalogueEntry); diff --git a/x-pack/legacy/plugins/maps/public/plugin.ts b/x-pack/legacy/plugins/maps/public/plugin.ts index 4ec068ff44029..0123e32b6d3b9 100644 --- a/x-pack/legacy/plugins/maps/public/plugin.ts +++ b/x-pack/legacy/plugins/maps/public/plugin.ts @@ -4,20 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../plugins/maps/public/layers/layer_wizard_registry'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../plugins/maps/public/layers/sources/source_registry'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import '../../../../plugins/maps/public/layers/load_layer_wizards'; - import { Plugin, CoreStart, CoreSetup } from 'src/core/public'; // @ts-ignore import { Start as InspectorStartContract } from 'src/plugins/inspector/public'; // @ts-ignore import { wrapInI18nContext } from 'ui/i18n'; // @ts-ignore -import { MapListing } from './components/map_listing'; +import { MapListing } from '../../../../plugins/maps/public/components/map_listing'; // eslint-disable-line @kbn/eslint/no-restricted-paths // @ts-ignore import { bindSetupCoreAndPlugins as bindNpSetupCoreAndPlugins, @@ -25,7 +18,6 @@ import { } from '../../../../plugins/maps/public/plugin'; // eslint-disable-line @kbn/eslint/no-restricted-paths import { HomePublicPluginSetup } from '../../../../../src/plugins/home/public'; import { LicensingPluginSetup } from '../../../../plugins/licensing/public'; -import { featureCatalogueEntry } from './feature_catalogue_entry'; import { DataPublicPluginSetup, DataPublicPluginStart, @@ -64,8 +56,6 @@ export class MapsPlugin implements Plugin { }); bindNpSetupCoreAndPlugins(core, np); - - np.home.featureCatalogue.register(featureCatalogueEntry); } public start(core: CoreStart, plugins: MapsPluginStartDependencies) { diff --git a/x-pack/legacy/plugins/maps/public/register_vis_type_alias.js b/x-pack/legacy/plugins/maps/public/register_vis_type_alias.js deleted file mode 100644 index 9dc07bcb5dc0e..0000000000000 --- a/x-pack/legacy/plugins/maps/public/register_vis_type_alias.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { i18n } from '@kbn/i18n'; -import { APP_ID, APP_ICON, MAP_BASE_URL } from '../common/constants'; -import { - getInjectedVarFunc, - getVisualizations, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../plugins/maps/public/kibana_services'; -import { npSetup } from 'ui/new_platform'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { bindSetupCoreAndPlugins } from '../../../../plugins/maps/public/plugin'; - -bindSetupCoreAndPlugins(npSetup.core, npSetup.plugins); - -const showMapVisualizationTypes = getInjectedVarFunc()('showMapVisualizationTypes', false); - -const description = i18n.translate('xpack.maps.visTypeAlias.description', { - defaultMessage: 'Create and style maps with multiple layers and indices.', -}); - -const legacyMapVisualizationWarning = i18n.translate( - 'xpack.maps.visTypeAlias.legacyMapVizWarning', - { - defaultMessage: `Use the Maps app instead of Coordinate Map and Region Map. -The Maps app offers more functionality and is easier to use.`, - } -); - -getVisualizations().registerAlias({ - aliasUrl: MAP_BASE_URL, - name: APP_ID, - title: i18n.translate('xpack.maps.visTypeAlias.title', { - defaultMessage: 'Maps', - }), - description: showMapVisualizationTypes - ? `${description} ${legacyMapVisualizationWarning}` - : description, - icon: APP_ICON, - stage: 'production', -}); - -if (!showMapVisualizationTypes) { - getVisualizations().hideTypes(['region_map', 'tile_map']); -} diff --git a/x-pack/legacy/plugins/maps/public/routes.js b/x-pack/legacy/plugins/maps/public/routes.js index c082e0e1352c0..70c1c4a50efd4 100644 --- a/x-pack/legacy/plugins/maps/public/routes.js +++ b/x-pack/legacy/plugins/maps/public/routes.js @@ -6,15 +6,18 @@ import { i18n } from '@kbn/i18n'; import routes from 'ui/routes'; -import listingTemplate from './angular/listing_ng_wrapper.html'; -import mapTemplate from './angular/map.html'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import listingTemplate from '../../../../plugins/maps/public/angular/listing_ng_wrapper.html'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import mapTemplate from '../../../../plugins/maps/public/angular/map.html'; import { getSavedObjectsClient, getCoreChrome, getMapsCapabilities, // eslint-disable-next-line @kbn/eslint/no-restricted-paths } from '../../../../plugins/maps/public/kibana_services'; -import { getMapsSavedObjectLoader } from './angular/services/gis_map_saved_object_loader'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { getMapsSavedObjectLoader } from '../../../../plugins/maps/public/angular/services/gis_map_saved_object_loader'; routes.enable(); diff --git a/x-pack/legacy/plugins/maps/server/lib/get_index_pattern_settings.js b/x-pack/legacy/plugins/maps/server/lib/get_index_pattern_settings.js index c5522b7ba21c5..e2a758075155a 100644 --- a/x-pack/legacy/plugins/maps/server/lib/get_index_pattern_settings.js +++ b/x-pack/legacy/plugins/maps/server/lib/get_index_pattern_settings.js @@ -5,7 +5,10 @@ */ import _ from 'lodash'; -import { DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_INNER_RESULT_WINDOW } from '../../common/constants'; +import { + DEFAULT_MAX_RESULT_WINDOW, + DEFAULT_MAX_INNER_RESULT_WINDOW, +} from '../../../../../plugins/maps/common/constants'; export function getIndexPatternSettings(indicesSettingsResp) { let maxResultWindow = Infinity; diff --git a/x-pack/legacy/plugins/maps/server/lib/get_index_pattern_settings.test.js b/x-pack/legacy/plugins/maps/server/lib/get_index_pattern_settings.test.js index 01a1ba2703cba..c152f5bfffc31 100644 --- a/x-pack/legacy/plugins/maps/server/lib/get_index_pattern_settings.test.js +++ b/x-pack/legacy/plugins/maps/server/lib/get_index_pattern_settings.test.js @@ -5,7 +5,10 @@ */ import { getIndexPatternSettings } from './get_index_pattern_settings'; -import { DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_INNER_RESULT_WINDOW } from '../../common/constants'; +import { + DEFAULT_MAX_RESULT_WINDOW, + DEFAULT_MAX_INNER_RESULT_WINDOW, +} from '../../../../../plugins/maps/common/constants'; describe('max_result_window and max_inner_result_window are not set', () => { test('Should provide default values when values not set', () => { diff --git a/x-pack/legacy/plugins/maps/server/maps_telemetry/collectors/register.ts b/x-pack/legacy/plugins/maps/server/maps_telemetry/collectors/register.ts index 652bb83a0d781..d34e306d1fff9 100644 --- a/x-pack/legacy/plugins/maps/server/maps_telemetry/collectors/register.ts +++ b/x-pack/legacy/plugins/maps/server/maps_telemetry/collectors/register.ts @@ -9,7 +9,7 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { SavedObjectsClientContract } from 'src/core/server'; import { getMapsTelemetry } from '../maps_telemetry'; // @ts-ignore -import { TELEMETRY_TYPE } from '../../../common/constants'; +import { TELEMETRY_TYPE } from '../../../../../../plugins/maps/common/constants'; export function registerMapsUsageCollector( usageCollection: UsageCollectionSetup, diff --git a/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts b/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts index 27c0211446e85..4610baabad3fe 100644 --- a/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts +++ b/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_telemetry.ts @@ -16,8 +16,8 @@ import { ES_GEO_FIELD_TYPE, MAP_SAVED_OBJECT_TYPE, TELEMETRY_TYPE, -} from '../../common/constants'; -import { LayerDescriptor } from '../../common/descriptor_types'; +} from '../../../../../plugins/maps/common/constants'; +import { LayerDescriptor } from '../../../../../plugins/maps/common/descriptor_types'; import { MapSavedObject } from '../../../../../plugins/maps/common/map_saved_object_type'; interface IStats { diff --git a/x-pack/legacy/plugins/maps/server/plugin.js b/x-pack/legacy/plugins/maps/server/plugin.js index 25c552433e9f8..79f3dcf76b82e 100644 --- a/x-pack/legacy/plugins/maps/server/plugin.js +++ b/x-pack/legacy/plugins/maps/server/plugin.js @@ -4,7 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ import { i18n } from '@kbn/i18n'; -import { APP_ID, APP_ICON, createMapPath, MAP_SAVED_OBJECT_TYPE } from '../common/constants'; +import { + APP_ID, + APP_ICON, + createMapPath, + MAP_SAVED_OBJECT_TYPE, +} from '../../../../plugins/maps/common/constants'; import { getEcommerceSavedObjects } from './sample_data/ecommerce_saved_objects'; import { getFlightsSavedObjects } from './sample_data/flights_saved_objects.js'; import { getWebLogsSavedObjects } from './sample_data/web_logs_saved_objects.js'; diff --git a/x-pack/legacy/plugins/maps/server/routes.js b/x-pack/legacy/plugins/maps/server/routes.js index 20e022001577a..d49f9827e3ea0 100644 --- a/x-pack/legacy/plugins/maps/server/routes.js +++ b/x-pack/legacy/plugins/maps/server/routes.js @@ -21,7 +21,7 @@ import { GIS_API_PATH, EMS_SPRITES_PATH, INDEX_SETTINGS_API_PATH, -} from '../common/constants'; +} from '../../../../plugins/maps/common/constants'; import { EMSClient } from '@elastic/ems-client'; import fetch from 'node-fetch'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/legacy/plugins/reporting/common/constants.ts b/x-pack/legacy/plugins/reporting/common/constants.ts index e3d6a4274e7df..f30a7cc87f318 100644 --- a/x-pack/legacy/plugins/reporting/common/constants.ts +++ b/x-pack/legacy/plugins/reporting/common/constants.ts @@ -20,6 +20,7 @@ export const API_GENERATE_IMMEDIATE = `${API_BASE_URL_V1}/generate/immediate/csv export const CONTENT_TYPE_CSV = 'text/csv'; export const CSV_REPORTING_ACTION = 'downloadCsvReport'; export const CSV_BOM_CHARS = '\ufeff'; +export const CSV_FORMULA_CHARS = ['=', '+', '-', '@']; export const WHITELISTED_JOB_CONTENT_TYPES = [ 'application/json', diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.ts b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.ts index f0afade8629ab..ad35aaf003094 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.test.ts @@ -300,7 +300,7 @@ describe('CSV Execute Job', function() { }); }); - describe('Cells with formula values', () => { + describe('Warning when cells have formulas', () => { it('returns `csv_contains_formulas` when cells contain formulas', async function() { configGetStub.withArgs('csv', 'checkForFormulas').returns(true); callAsCurrentUserStub.onFirstCall().returns({ @@ -353,6 +353,7 @@ describe('CSV Execute Job', function() { it('returns no warnings when cells have no formulas', async function() { configGetStub.withArgs('csv', 'checkForFormulas').returns(true); + configGetStub.withArgs('csv', 'escapeFormulaValues').returns(false); callAsCurrentUserStub.onFirstCall().returns({ hits: { hits: [{ _source: { one: 'foo', two: 'bar' } }], @@ -376,6 +377,33 @@ describe('CSV Execute Job', function() { expect(csvContainsFormulas).toEqual(false); }); + it('returns no warnings when cells have formulas but are escaped', async function() { + configGetStub.withArgs('csv', 'checkForFormulas').returns(true); + configGetStub.withArgs('csv', 'escapeFormulaValues').returns(true); + callAsCurrentUserStub.onFirstCall().returns({ + hits: { + hits: [{ _source: { '=SUM(A1:A2)': 'foo', two: 'bar' } }], + }, + _scroll_id: 'scrollId', + }); + + const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const jobParams = getJobDocPayload({ + headers: encryptedHeaders, + fields: ['=SUM(A1:A2)', 'two'], + conflictedTypesFields: [], + searchRequest: { index: null, body: null }, + }); + + const { csv_contains_formulas: csvContainsFormulas } = await executeJob( + 'job123', + jobParams, + cancellationToken + ); + + expect(csvContainsFormulas).toEqual(false); + }); + it('returns no warnings when configured not to', async () => { configGetStub.withArgs('csv', 'checkForFormulas').returns(false); callAsCurrentUserStub.onFirstCall().returns({ @@ -446,6 +474,50 @@ describe('CSV Execute Job', function() { }); }); + describe('Escaping cells with formulas', () => { + it('escapes values with formulas', async () => { + configGetStub.withArgs('csv', 'escapeFormulaValues').returns(true); + callAsCurrentUserStub.onFirstCall().returns({ + hits: { + hits: [{ _source: { one: `=cmd|' /C calc'!A0`, two: 'bar' } }], + }, + _scroll_id: 'scrollId', + }); + + const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const jobParams = getJobDocPayload({ + headers: encryptedHeaders, + fields: ['one', 'two'], + conflictedTypesFields: [], + searchRequest: { index: null, body: null }, + }); + const { content } = await executeJob('job123', jobParams, cancellationToken); + + expect(content).toEqual("one,two\n\"'=cmd|' /C calc'!A0\",bar\n"); + }); + + it('does not escapes values with formulas', async () => { + configGetStub.withArgs('csv', 'escapeFormulaValues').returns(false); + callAsCurrentUserStub.onFirstCall().returns({ + hits: { + hits: [{ _source: { one: `=cmd|' /C calc'!A0`, two: 'bar' } }], + }, + _scroll_id: 'scrollId', + }); + + const executeJob = await executeJobFactory(mockReportingPlugin, mockLogger); + const jobParams = getJobDocPayload({ + headers: encryptedHeaders, + fields: ['one', 'two'], + conflictedTypesFields: [], + searchRequest: { index: null, body: null }, + }); + const { content } = await executeJob('job123', jobParams, cancellationToken); + + expect(content).toEqual('one,two\n"=cmd|\' /C calc\'!A0",bar\n'); + }); + }); + describe('Elasticsearch call errors', function() { it('should reject Promise if search call errors out', async function() { callAsCurrentUserStub.rejects(new Error()); diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts index 376a398da274f..dbe305bc452db 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/execute_job.ts @@ -123,7 +123,7 @@ export const executeJobFactory: ExecuteJobFactory + CSV_FORMULA_CHARS.some(formulaChar => startsWith(val, formulaChar)); diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.ts b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.ts index 09f7cd2061ffb..0ec39c527d656 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/check_cells_for_formulas.ts @@ -5,8 +5,7 @@ */ import * as _ from 'lodash'; - -const formulaValues = ['=', '+', '-', '@']; +import { cellHasFormulas } from './cell_has_formula'; interface IFlattened { [header: string]: string; @@ -14,7 +13,7 @@ interface IFlattened { export const checkIfRowsHaveFormulas = (flattened: IFlattened, fields: string[]) => { const pruned = _.pick(flattened, fields); - const csvValues = [..._.keys(pruned), ...(_.values(pruned) as string[])]; + const cells = [..._.keys(pruned), ...(_.values(pruned) as string[])]; - return _.some(csvValues, cell => _.some(formulaValues, char => _.startsWith(cell, char))); + return _.some(cells, cell => cellHasFormulas(cell)); }; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.test.ts b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.test.ts index 64b021a2aeea8..dd0f9d08b864b 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.test.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.test.ts @@ -11,7 +11,7 @@ describe('escapeValue', function() { describe('quoteValues is true', function() { let escapeValue: (val: string) => string; beforeEach(function() { - escapeValue = createEscapeValue(true); + escapeValue = createEscapeValue(true, false); }); it('should escape value with spaces', function() { @@ -46,7 +46,7 @@ describe('escapeValue', function() { describe('quoteValues is false', function() { let escapeValue: (val: string) => string; beforeEach(function() { - escapeValue = createEscapeValue(false); + escapeValue = createEscapeValue(false, false); }); it('should return the value unescaped', function() { @@ -54,4 +54,34 @@ describe('escapeValue', function() { expect(escapeValue(value)).to.be(value); }); }); + + describe('escapeValues', () => { + describe('when true', () => { + let escapeValue: (val: string) => string; + beforeEach(function() { + escapeValue = createEscapeValue(true, true); + }); + + ['@', '+', '-', '='].forEach(badChar => { + it(`should escape ${badChar} injection values`, function() { + expect(escapeValue(`${badChar}cmd|' /C calc'!A0`)).to.be( + `"'${badChar}cmd|' /C calc'!A0"` + ); + }); + }); + }); + + describe('when false', () => { + let escapeValue: (val: string) => string; + beforeEach(function() { + escapeValue = createEscapeValue(true, false); + }); + + ['@', '+', '-', '='].forEach(badChar => { + it(`should not escape ${badChar} injection values`, function() { + expect(escapeValue(`${badChar}cmd|' /C calc'!A0`)).to.be(`"${badChar}cmd|' /C calc'!A0"`); + }); + }); + }); + }); }); diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.ts b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.ts index 563de563350e9..60e75d74b2f98 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/escape_value.ts @@ -5,15 +5,20 @@ */ import { RawValue } from './types'; +import { cellHasFormulas } from './cell_has_formula'; const nonAlphaNumRE = /[^a-zA-Z0-9]/; const allDoubleQuoteRE = /"/g; -export function createEscapeValue(quoteValues: boolean): (val: RawValue) => string { +export function createEscapeValue( + quoteValues: boolean, + escapeFormulas: boolean +): (val: RawValue) => string { return function escapeValue(val: RawValue) { if (val && typeof val === 'string') { - if (quoteValues && nonAlphaNumRE.test(val)) { - return `"${val.replace(allDoubleQuoteRE, '""')}"`; + const formulasEscaped = escapeFormulas && cellHasFormulas(val) ? "'" + val : val; + if (quoteValues && nonAlphaNumRE.test(formulasEscaped)) { + return `"${formulasEscaped.replace(allDoubleQuoteRE, '""')}"`; } } diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts index 1986e68917ba8..c7996ebf832a1 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/lib/generate_csv.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { Logger } from '../../../../types'; import { GenerateCsvParams, SavedSearchGeneratorResult } from '../../types'; import { createFlattenHit } from './flatten_hit'; @@ -26,14 +27,17 @@ export function createGenerateCsv(logger: Logger) { cancellationToken, settings, }: GenerateCsvParams): Promise { - const escapeValue = createEscapeValue(settings.quoteValues); + const escapeValue = createEscapeValue(settings.quoteValues, settings.escapeFormulaValues); const builder = new MaxSizeStringBuilder(settings.maxSizeBytes); const header = `${fields.map(escapeValue).join(settings.separator)}\n`; + const warnings: string[] = []; + if (!builder.tryAppend(header)) { return { size: 0, content: '', maxSizeReached: true, + warnings: [], }; } @@ -82,11 +86,20 @@ export function createGenerateCsv(logger: Logger) { const size = builder.getSizeInBytes(); logger.debug(`finished generating, total size in bytes: ${size}`); + if (csvContainsFormulas && settings.escapeFormulaValues) { + warnings.push( + i18n.translate('xpack.reporting.exportTypes.csv.generateCsv.escapedFormulaValues', { + defaultMessage: 'CSV may contain formulas whose values have been escaped', + }) + ); + } + return { content: builder.getString(), - csvContainsFormulas, + csvContainsFormulas: csvContainsFormulas && !settings.escapeFormulaValues, maxSizeReached, size, + warnings, }; }; } diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts b/x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts index 529c195486bc6..40a42db352635 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/types.d.ts @@ -87,6 +87,7 @@ export interface SavedSearchGeneratorResult { size: number; maxSizeReached: boolean; csvContainsFormulas?: boolean; + warnings: string[]; } export interface CsvResultFromSearch { @@ -109,5 +110,6 @@ export interface GenerateCsvParams { maxSizeBytes: number; scroll: ScrollConfig; checkForFormulas?: boolean; + escapeFormulaValues: boolean; }; } diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts index 9757c71c19cf4..2611b74c83de9 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/lib/generate_csv_search.ts @@ -173,6 +173,7 @@ export async function generateCsvSearch( ...uiSettings, maxSizeBytes: config.get('csv', 'maxSizeBytes'), scroll: config.get('csv', 'scroll'), + escapeFormulaValues: config.get('csv', 'escapeFormulaValues'), timezone, }, }; diff --git a/x-pack/legacy/plugins/rollup/README.md b/x-pack/legacy/plugins/rollup/README.md index 6d04973de591e..3647be38b6a09 100644 --- a/x-pack/legacy/plugins/rollup/README.md +++ b/x-pack/legacy/plugins/rollup/README.md @@ -14,7 +14,7 @@ The rest of this doc dives into the implementation details of each of the above ## Create and manage rollup jobs -The most straight forward part of this plugin! A new app called Rollup Jobs is registered in the Management section and follows a typical CRUD UI pattern. This app allows users to create, start, stop, clone, and delete rollup jobs. There is no way to edit an existing rollup job; instead, the UI offers a cloning ability. The client-side portion of this app lives [here](public/crud_app) and uses endpoints registered [here](server/routes/api/jobs.js). +The most straight forward part of this plugin! A new app called Rollup Jobs is registered in the Management section and follows a typical CRUD UI pattern. This app allows users to create, start, stop, clone, and delete rollup jobs. There is no way to edit an existing rollup job; instead, the UI offers a cloning ability. The client-side portion of this app lives [here](../../../plugins/rollup/public/crud_app) and uses endpoints registered [here](server/routes/api/jobs.js). Refer to the [Elasticsearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-getting-started.html) to understand rollup indices and how to create rollup jobs. @@ -22,22 +22,22 @@ Refer to the [Elasticsearch documentation](https://www.elastic.co/guide/en/elast Kibana uses index patterns to consume and visualize rollup indices. Typically, Kibana can inspect the indices captured by an index pattern, identify its aggregations and fields, and determine how to consume the data. Rollup indices don't contain this type of information, so we predefine how to consume a rollup index pattern with the type and typeMeta fields on the index pattern saved object. All rollup index patterns have `type` defined as "rollup" and `typeMeta` defined as an object of the index pattern's capabilities. -In the Index Pattern app, the "Create index pattern" button includes a context menu when a rollup index is detected. This menu offers items for creating a standard index pattern and a rollup index pattern. A [rollup config is registered to index pattern creation extension point](public/index_pattern_creation/rollup_index_pattern_creation_config.js). The context menu behavior in particular uses the `getIndexPatternCreationOption()` method. When the user chooses to create a rollup index pattern, this config changes the behavior of the index pattern creation wizard: +In the Index Pattern app, the "Create index pattern" button includes a context menu when a rollup index is detected. This menu offers items for creating a standard index pattern and a rollup index pattern. A [rollup config is registered to index pattern creation extension point](../../../plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js). The context menu behavior in particular uses the `getIndexPatternCreationOption()` method. When the user chooses to create a rollup index pattern, this config changes the behavior of the index pattern creation wizard: 1. Adds a `Rollup` badge to rollup indices using `getIndexTags()`. 2. Enforces index pattern rules using `checkIndicesForErrors()`. Rollup index patterns must match **one** rollup index, and optionally, any number of regular indices. A rollup index pattern configured with one or more regular indices is known as a "hybrid" index pattern. This allows the user to visualize historical (rollup) data and live (regular) data in the same visualization. 3. Routes to this plugin's [rollup `_fields_for_wildcard` endpoint](server/routes/api/index_patterns.js), instead of the standard one, using `getFetchForWildcardOptions()`, so that the internal rollup data field names are mapped to the original field names. 4. Writes additional information about aggregations, fields, histogram interval, and date histogram interval and timezone to the rollup index pattern saved object using `getIndexPatternMappings()`. This collection of information is referred to as its "capabilities". -Once a rollup index pattern is created, it is tagged with `Rollup` in the list of index patterns, and its details page displays capabilities information. This is done by registering [yet another config for the index pattern list](public/index_pattern_list/rollup_index_pattern_list_config.js) extension points. +Once a rollup index pattern is created, it is tagged with `Rollup` in the list of index patterns, and its details page displays capabilities information. This is done by registering [yet another config for the index pattern list](../../../plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js) extension points. ## Create visualizations from rollup index patterns This plugin enables the user to create visualizations from rollup data using the Visualize app, excluding TSVB, Vega, and Timelion. When Visualize sends search requests, this plugin routes the requests to the [Elasticsearch rollup search endpoint](https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-search.html), which searches the special document structure within rollup indices. The visualization options available to users are based on the capabilities of the rollup index pattern they're visualizing. -Routing to the Elasticsearch rollup search endpoint is done by creating an extension point in Courier, effectively allowing multiple "search strategies" to be registered. A [rollup search strategy](public/search/register.js) is registered by this plugin that queries [this plugin's rollup search endpoint](server/routes/api/search.js). +Routing to the Elasticsearch rollup search endpoint is done by creating an extension point in Courier, effectively allowing multiple "search strategies" to be registered. A [rollup search strategy](../../../plugins/rollup/public/search/register.js) is registered by this plugin that queries [this plugin's rollup search endpoint](server/routes/api/search.js). -Limiting visualization editor options is done by [registering configs](public/visualize/index.js) to various vis extension points. These configs use information stored on the rollup index pattern to limit: +Limiting visualization editor options is done by [registering configs](../../../plugins/rollup/public/visualize/index.js) to various vis extension points. These configs use information stored on the rollup index pattern to limit: * Available aggregation types * Available fields for a particular aggregation * Default and base interval for histogram aggregation @@ -47,6 +47,6 @@ Limiting visualization editor options is done by [registering configs](public/vi In Index Management, similar to system indices, rollup indices are hidden by default. A toggle is provided to show rollup indices and add a badge to the table rows. This is done by using Index Management's extension points. -The toggle and badge are registered on client-side [here](public/extend_index_management/index.js). +The toggle and badge are registered on client-side [here](../../../plugins/rollup/public/extend_index_management/index.js). Additional data needed to filter rollup indices in Index Management is provided with a [data enricher](rollup_data_enricher.js). diff --git a/x-pack/legacy/plugins/rollup/common/index.ts b/x-pack/legacy/plugins/rollup/common/index.ts index 4229803462203..526af055a3ef6 100644 --- a/x-pack/legacy/plugins/rollup/common/index.ts +++ b/x-pack/legacy/plugins/rollup/common/index.ts @@ -16,24 +16,4 @@ export const PLUGIN = { }, }; -export const CONFIG_ROLLUPS = 'rollups:enableIndexPatterns'; - -export const API_BASE_PATH = '/api/rollup'; - -export { - UIM_APP_NAME, - UIM_APP_LOAD, - UIM_JOB_CREATE, - UIM_JOB_DELETE, - UIM_JOB_DELETE_MANY, - UIM_JOB_START, - UIM_JOB_START_MANY, - UIM_JOB_STOP, - UIM_JOB_STOP_MANY, - UIM_SHOW_DETAILS_CLICK, - UIM_DETAIL_PANEL_SUMMARY_TAB_CLICK, - UIM_DETAIL_PANEL_TERMS_TAB_CLICK, - UIM_DETAIL_PANEL_HISTOGRAM_TAB_CLICK, - UIM_DETAIL_PANEL_METRICS_TAB_CLICK, - UIM_DETAIL_PANEL_JSON_TAB_CLICK, -} from './ui_metric'; +export * from '../../../../plugins/rollup/common'; diff --git a/x-pack/legacy/plugins/rollup/index.ts b/x-pack/legacy/plugins/rollup/index.ts index 621667f3618b2..f33ae7cfee0a2 100644 --- a/x-pack/legacy/plugins/rollup/index.ts +++ b/x-pack/legacy/plugins/rollup/index.ts @@ -4,40 +4,16 @@ * you may not use this file except in compliance with the Elastic License. */ -import { resolve } from 'path'; -import { i18n } from '@kbn/i18n'; import { PluginInitializerContext } from 'src/core/server'; import { RollupSetup } from '../../../plugins/rollup/server'; -import { PLUGIN, CONFIG_ROLLUPS } from './common'; +import { PLUGIN } from './common'; import { plugin } from './server'; export function rollup(kibana: any) { return new kibana.Plugin({ id: PLUGIN.ID, configPrefix: 'xpack.rollup', - publicDir: resolve(__dirname, 'public'), require: ['kibana', 'elasticsearch', 'xpack_main'], - uiExports: { - styleSheetPaths: resolve(__dirname, 'public/index.scss'), - managementSections: ['plugins/rollup/legacy'], - uiSettingDefaults: { - [CONFIG_ROLLUPS]: { - name: i18n.translate('xpack.rollupJobs.rollupIndexPatternsTitle', { - defaultMessage: 'Enable rollup index patterns', - }), - value: true, - description: i18n.translate('xpack.rollupJobs.rollupIndexPatternsDescription', { - defaultMessage: `Enable the creation of index patterns which capture rollup indices, - which in turn enable visualizations based on rollup data. Refresh - the page to apply the changes.`, - }), - category: ['rollups'], - }, - }, - indexManagement: ['plugins/rollup/legacy'], - visualize: ['plugins/rollup/legacy'], - search: ['plugins/rollup/legacy'], - }, init(server: any) { const { core: coreSetup, plugins } = server.newPlatform.setup; const { usageCollection, visTypeTimeseries, indexManagement } = plugins; diff --git a/x-pack/legacy/plugins/rollup/public/legacy.ts b/x-pack/legacy/plugins/rollup/public/legacy.ts deleted file mode 100644 index 83945110c2c76..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/legacy.ts +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { npSetup, npStart } from 'ui/new_platform'; -import { RollupPlugin } from './plugin'; - -const plugin = new RollupPlugin(); - -export const setup = plugin.setup(npSetup.core, npSetup.plugins); -export const start = plugin.start(npStart.core, npStart.plugins); diff --git a/x-pack/legacy/plugins/rollup/public/legacy_imports.ts b/x-pack/legacy/plugins/rollup/public/legacy_imports.ts deleted file mode 100644 index e82a41f60b1ca..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/legacy_imports.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { PluginsStart } from 'ui/new_platform/new_platform'; diff --git a/x-pack/legacy/plugins/rollup/public/search/rollup_search_strategy.ts b/x-pack/legacy/plugins/rollup/public/search/rollup_search_strategy.ts deleted file mode 100644 index 4709c0aa498f8..0000000000000 --- a/x-pack/legacy/plugins/rollup/public/search/rollup_search_strategy.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { HttpSetup } from 'src/core/public'; -import { - SearchError, - getSearchErrorType, - IIndexPattern, - SearchStrategyProvider, - SearchResponse, - SearchRequest, -} from '../../../../../../src/plugins/data/public'; - -function serializeFetchParams(searchRequests: SearchRequest[]) { - return JSON.stringify( - searchRequests.map(searchRequestWithFetchParams => { - const indexPattern = - searchRequestWithFetchParams.index.title || searchRequestWithFetchParams.index; - const { - body: { size, aggs, query: _query }, - } = searchRequestWithFetchParams; - - const query = { - size, - aggregations: aggs, - query: _query, - }; - - return { index: indexPattern, query }; - }) - ); -} - -// Rollup search always returns 0 hits, but visualizations expect search responses -// to return hits > 0, otherwise they do not render. We fake the number of hits here -// by counting the number of aggregation buckets/values returned by rollup search. -function shimHitsInFetchResponse(response: SearchResponse[]) { - return response.map(result => { - const buckets = result.aggregations - ? Object.keys(result.aggregations).reduce((allBuckets, agg) => { - return allBuckets.concat( - result.aggregations[agg].buckets || [result.aggregations[agg].value] || [] - ); - }, []) - : []; - return buckets && buckets.length - ? { - ...result, - hits: { - ...result.hits, - total: buckets.length, - }, - } - : result; - }); -} - -export const getRollupSearchStrategy = (fetch: HttpSetup['fetch']): SearchStrategyProvider => ({ - id: 'rollup', - - search: ({ searchRequests }) => { - // Serialize the fetch params into a format suitable for the body of an ES query. - const serializedFetchParams = serializeFetchParams(searchRequests); - - const controller = new AbortController(); - const promise = fetch('../api/rollup/search', { - signal: controller.signal, - method: 'POST', - body: serializedFetchParams, - }); - - return { - searching: promise.then(shimHitsInFetchResponse).catch(error => { - const { - body: { statusCode, error: title, message }, - res: { url }, - } = error; - - // Format fetch error as a SearchError. - const searchError = new SearchError({ - status: statusCode, - title, - message: `Rollup search error: ${message}`, - path: url, - type: getSearchErrorType({ message }) || '', - }); - - return Promise.reject(searchError); - }), - abort: () => controller.abort(), - }; - }, - - isViable: (indexPattern: IIndexPattern) => { - if (!indexPattern) { - return false; - } - - return indexPattern.type === 'rollup'; - }, -}); diff --git a/x-pack/legacy/plugins/siem/.gitattributes b/x-pack/legacy/plugins/siem/.gitattributes index f40e829b65453..a4071d39e63c0 100644 --- a/x-pack/legacy/plugins/siem/.gitattributes +++ b/x-pack/legacy/plugins/siem/.gitattributes @@ -1,6 +1,5 @@ # Auto-collapse generated files in GitHub # https://help.github.com/en/articles/customizing-how-changed-files-appear-on-github x-pack/legacy/plugins/siem/public/graphql/types.ts linguist-generated=true -x-pack/legacy/plugins/siem/server/graphql/types.ts linguist-generated=true x-pack/legacy/plugins/siem/public/graphql/introspection.json linguist-generated=true diff --git a/x-pack/legacy/plugins/siem/cypress.json b/x-pack/legacy/plugins/siem/cypress.json deleted file mode 100644 index a0333a1068146..0000000000000 --- a/x-pack/legacy/plugins/siem/cypress.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "baseUrl": "http://localhost:5601", - "defaultCommandTimeout": 120000, - "screenshotsFolder": "../../../../target/kibana-siem/cypress/screenshots", - "trashAssetsBeforeRuns": false, - "video": false, - "videosFolder": "../../../../target/kibana-siem/cypress/videos" -} diff --git a/x-pack/legacy/plugins/siem/index.ts b/x-pack/legacy/plugins/siem/index.ts index 3773283555b32..6e03583dda69f 100644 --- a/x-pack/legacy/plugins/siem/index.ts +++ b/x-pack/legacy/plugins/siem/index.ts @@ -6,11 +6,10 @@ import { i18n } from '@kbn/i18n'; import { resolve } from 'path'; -import { Server } from 'hapi'; import { Root } from 'joi'; -import { plugin } from './server'; -import { savedObjectMappings } from './server/saved_objects'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +import { savedObjectMappings } from '../../../plugins/siem/server/saved_objects'; import { APP_ID, @@ -23,15 +22,13 @@ import { DEFAULT_INTERVAL_VALUE, DEFAULT_FROM, DEFAULT_TO, - DEFAULT_SIGNALS_INDEX, ENABLE_NEWS_FEED_SETTING, NEWS_FEED_URL_SETTING, NEWS_FEED_URL_SETTING_DEFAULT, - SIGNALS_INDEX_KEY, IP_REPUTATION_LINKS_SETTING, IP_REPUTATION_LINKS_SETTING_DEFAULT, -} from './common/constants'; -import { defaultIndexPattern } from './default_index_pattern'; + DEFAULT_INDEX_PATTERN, +} from '../../../plugins/siem/common/constants'; import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/utils'; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -102,7 +99,7 @@ export const siem = (kibana: any) => { name: i18n.translate('xpack.siem.uiSettings.defaultIndexLabel', { defaultMessage: 'Elasticsearch indices', }), - value: defaultIndexPattern, + value: DEFAULT_INDEX_PATTERN, description: i18n.translate('xpack.siem.uiSettings.defaultIndexDescription', { defaultMessage: '

Comma-delimited list of Elasticsearch indices from which the SIEM app collects events.

', @@ -162,31 +159,12 @@ export const siem = (kibana: any) => { }, mappings: savedObjectMappings, }, - init(server: Server) { - const { coreContext, env, setup, start } = server.newPlatform; - const initializerContext = { ...coreContext, env }; - const __legacy = { - config: server.config, - route: server.route.bind(server), - }; - - // @ts-ignore-next-line: NewPlatform shim is too loosely typed - const pluginInstance = plugin(initializerContext); - // @ts-ignore-next-line: NewPlatform shim is too loosely typed - pluginInstance.setup(setup.core, setup.plugins, __legacy); - // @ts-ignore-next-line: NewPlatform shim is too loosely typed - pluginInstance.start(start.core, start.plugins); - }, config(Joi: Root) { - // See x-pack/plugins/siem/server/config.ts if you're adding another - // value where the configuration has to be duplicated at the moment. - // When we move over to the new platform completely this will be - // removed and only server/config.ts should be used. return Joi.object() .keys({ enabled: Joi.boolean().default(true), - [SIGNALS_INDEX_KEY]: Joi.string().default(DEFAULT_SIGNALS_INDEX), }) + .unknown(true) .default(); }, }); diff --git a/x-pack/legacy/plugins/siem/package.json b/x-pack/legacy/plugins/siem/package.json index 472a473842f02..3a93beef963a0 100644 --- a/x-pack/legacy/plugins/siem/package.json +++ b/x-pack/legacy/plugins/siem/package.json @@ -1,16 +1,10 @@ { "author": "Elastic", - "name": "siem", + "name": "siem-legacy-ui", "version": "8.0.0", "private": true, "license": "Elastic-License", - "scripts": { - "extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js & node ../../../../scripts/eslint ./public/pages/detection_engine/mitre/mitre_tactics_techniques.ts --fix", - "build-graphql-types": "node scripts/generate_types_from_graphql.js", - "cypress:open": "../../../node_modules/.bin/cypress open", - "cypress:run": "../../../node_modules/.bin/cypress run --spec ./cypress/integration/**/*.spec.ts --reporter ../../../node_modules/cypress-multi-reporters --reporter-options configFile=./reporter_config.json; status=$?; ../../../node_modules/.bin/mochawesome-merge --reportDir ../../../../target/kibana-siem/cypress/results > ../../../../target/kibana-siem/cypress/results/output.json; ../../../../node_modules/.bin/marge ../../../../target/kibana-siem/cypress/results/output.json --reportDir ../../../../target/kibana-siem/cypress/results; mkdir -p ../../../../target/junit && cp ../../../../target/kibana-siem/cypress/results/*.xml ../../../../target/junit/ && exit $status;", - "cypress:run-as-ci": "node ../../../../scripts/functional_tests --config ../../../test/siem_cypress/config.ts" - }, + "scripts": {}, "devDependencies": { "@types/lodash": "^4.14.110", "@types/js-yaml": "^3.12.1", diff --git a/x-pack/legacy/plugins/siem/public/app/app.tsx b/x-pack/legacy/plugins/siem/public/app/app.tsx index 7413aeab549db..44c1c923cd6ee 100644 --- a/x-pack/legacy/plugins/siem/public/app/app.tsx +++ b/x-pack/legacy/plugins/siem/public/app/app.tsx @@ -20,7 +20,7 @@ import { pluck } from 'rxjs/operators'; import { KibanaContextProvider, useKibana, useUiSetting$ } from '../lib/kibana'; import { Storage } from '../../../../../../src/plugins/kibana_utils/public'; -import { DEFAULT_DARK_MODE } from '../../common/constants'; +import { DEFAULT_DARK_MODE } from '../../../../../plugins/siem/common/constants'; import { ErrorToastDispatcher } from '../components/error_toast_dispatcher'; import { compose } from '../lib/compose/kibana_compose'; import { AppFrontendLibs, AppApolloClient } from '../lib/lib'; diff --git a/x-pack/legacy/plugins/siem/public/components/alerts_viewer/index.tsx b/x-pack/legacy/plugins/siem/public/components/alerts_viewer/index.tsx index 587002c24d526..778adc708d901 100644 --- a/x-pack/legacy/plugins/siem/public/components/alerts_viewer/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/alerts_viewer/index.tsx @@ -6,11 +6,11 @@ import React, { useEffect, useCallback, useMemo } from 'react'; import numeral from '@elastic/numeral'; +import { DEFAULT_NUMBER_FORMAT } from '../../../../../../plugins/siem/common/constants'; import { AlertsComponentsQueryProps } from './types'; import { AlertsTable } from './alerts_table'; import * as i18n from './translations'; import { useUiSetting$ } from '../../lib/kibana'; -import { DEFAULT_NUMBER_FORMAT } from '../../../common/constants'; import { MatrixHistogramContainer } from '../matrix_histogram'; import { histogramConfigs } from './histogram_configs'; import { MatrixHisrogramConfigs } from '../matrix_histogram/types'; diff --git a/x-pack/legacy/plugins/siem/public/components/charts/barchart.test.tsx b/x-pack/legacy/plugins/siem/public/components/charts/barchart.test.tsx index 272c41833f368..635d48cca10fc 100644 --- a/x-pack/legacy/plugins/siem/public/components/charts/barchart.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/charts/barchart.test.tsx @@ -4,15 +4,29 @@ * you may not use this file except in compliance with the Elastic License. */ -import { shallow, ShallowWrapper } from 'enzyme'; +import { Chart, BarSeries, Axis, ScaleType } from '@elastic/charts'; +import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; +import { mount, ReactWrapper, shallow, ShallowWrapper } from 'enzyme'; import React from 'react'; +import { ThemeProvider } from 'styled-components'; + +import { escapeDataProviderId } from '../drag_and_drop/helpers'; +import { TestProviders } from '../../mock'; import { BarChartBaseComponent, BarChartComponent } from './barchart'; import { ChartSeriesData } from './common'; -import { Chart, BarSeries, Axis, ScaleType } from '@elastic/charts'; jest.mock('../../lib/kibana'); +jest.mock('uuid', () => { + return { + v1: jest.fn(() => 'uuid.v1()'), + v4: jest.fn(() => 'uuid.v4()'), + }; +}); + +const theme = () => ({ eui: euiDarkVars, darkMode: true }); + const customHeight = '100px'; const customWidth = '120px'; const chartDataSets = [ @@ -116,6 +130,19 @@ const mockConfig = { customHeight: 324, }; +// Suppress warnings about "react-beautiful-dnd" +/* eslint-disable no-console */ +const originalError = console.error; +const originalWarn = console.warn; +beforeAll(() => { + console.warn = jest.fn(); + console.error = jest.fn(); +}); +afterAll(() => { + console.error = originalError; + console.warn = originalWarn; +}); + describe('BarChartBaseComponent', () => { let shallowWrapper: ShallowWrapper; const mockBarChartData: ChartSeriesData[] = [ @@ -280,6 +307,91 @@ describe.each(chartDataSets)('BarChart with valid data [%o]', data => { expect(shallowWrapper.find('BarChartBase')).toHaveLength(1); expect(shallowWrapper.find('ChartPlaceHolder')).toHaveLength(0); }); + + it('it does NOT render a draggable legend because stackByField is not provided', () => { + expect(shallowWrapper.find('[data-test-subj="draggable-legend"]').exists()).toBe(false); + }); +}); + +describe.each(chartDataSets)('BarChart with stackByField', () => { + let wrapper: ReactWrapper; + + const data = [ + { + key: 'python.exe', + value: [ + { + x: 1586754900000, + y: 9675, + g: 'python.exe', + }, + ], + }, + { + key: 'kernel', + value: [ + { + x: 1586754900000, + y: 8708, + g: 'kernel', + }, + { + x: 1586757600000, + y: 9282, + g: 'kernel', + }, + ], + }, + { + key: 'sshd', + value: [ + { + x: 1586754900000, + y: 5907, + g: 'sshd', + }, + ], + }, + ]; + + const expectedColors = ['#1EA593', '#2B70F7', '#CE0060']; + + const stackByField = 'process.name'; + + beforeAll(() => { + wrapper = mount( + + + + + + ); + }); + + it('it renders a draggable legend', () => { + expect(wrapper.find('[data-test-subj="draggable-legend"]').exists()).toBe(true); + }); + + expectedColors.forEach((color, i) => { + test(`it renders the expected legend color ${color} for legend item ${i}`, () => { + expect(wrapper.find(`div [color="${color}"]`).exists()).toBe(true); + }); + }); + + data.forEach(datum => { + test(`it renders the expected draggable legend text for datum ${datum.key}`, () => { + const dataProviderId = `draggableId.content.draggable-legend-item-uuid_v4()-${escapeDataProviderId( + stackByField + )}-${escapeDataProviderId(datum.key)}`; + + expect( + wrapper + .find(`div [data-rbd-draggable-id="${dataProviderId}"]`) + .first() + .text() + ).toEqual(datum.key); + }); + }); }); describe.each(chartHolderDataSets)('BarChart with invalid data [%o]', data => { diff --git a/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx b/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx index 2ae0e05850a37..64d15cd6731cb 100644 --- a/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx +++ b/x-pack/legacy/plugins/siem/public/components/charts/barchart.tsx @@ -4,13 +4,19 @@ * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import React, { useMemo } from 'react'; import { Chart, BarSeries, Axis, Position, ScaleType, Settings } from '@elastic/charts'; import { getOr, get, isNumber } from 'lodash/fp'; import deepmerge from 'deepmerge'; +import uuid from 'uuid'; +import styled from 'styled-components'; -import { useThrottledResizeObserver } from '../utils'; +import { escapeDataProviderId } from '../drag_and_drop/helpers'; import { useTimeZone } from '../../lib/kibana'; +import { defaultLegendColors } from '../matrix_histogram/utils'; +import { useThrottledResizeObserver } from '../utils'; + import { ChartPlaceHolder } from './chart_place_holder'; import { chartDefaultSettings, @@ -22,6 +28,12 @@ import { WrappedByAutoSizer, useTheme, } from './common'; +import { DraggableLegend } from './draggable_legend'; +import { LegendItem } from './draggable_legend_item'; + +const LegendFlexItem = styled(EuiFlexItem)` + overview: hidden; +`; const checkIfAllTheDataInTheSeriesAreValid = (series: ChartSeriesData): series is ChartSeriesData => series != null && @@ -38,12 +50,14 @@ const checkIfAnyValidSeriesExist = ( // Bar chart rotation: https://ela.st/chart-rotations export const BarChartBaseComponent = ({ data, + forceHiddenLegend = false, ...chartConfigs }: { data: ChartSeriesData[]; width: string | null | undefined; height: string | null | undefined; configs?: ChartSeriesConfigs | undefined; + forceHiddenLegend?: boolean; }) => { const theme = useTheme(); const timeZone = useTimeZone(); @@ -59,10 +73,10 @@ export const BarChartBaseComponent = ({ return chartConfigs.width && chartConfigs.height ? ( - + {data.map(series => { const barSeriesKey = series.key; - return checkIfAllTheDataInTheSeriesAreValid ? ( + return checkIfAllTheDataInTheSeriesAreValid(series) ? ( = ({ barChart, configs }) => { +const NO_LEGEND_DATA: LegendItem[] = []; + +export const BarChartComponent: React.FC = ({ + barChart, + configs, + stackByField, +}) => { const { ref: measureRef, width, height } = useThrottledResizeObserver(); + const legendItems: LegendItem[] = useMemo( + () => + barChart != null && stackByField != null + ? barChart.map((d, i) => ({ + color: d.color ?? i < defaultLegendColors.length ? defaultLegendColors[i] : undefined, + dataProviderId: escapeDataProviderId( + `draggable-legend-item-${uuid.v4()}-${stackByField}-${d.key}` + ), + field: stackByField, + value: d.key, + })) + : NO_LEGEND_DATA, + [barChart, stackByField] + ); + const customHeight = get('customHeight', configs); const customWidth = get('customWidth', configs); const chartHeight = getChartHeight(customHeight, height); const chartWidth = getChartWidth(customWidth, width); return checkIfAnyValidSeriesExist(barChart) ? ( - - - + + + + + + + + + + ) : ( ); diff --git a/x-pack/legacy/plugins/siem/public/components/charts/common.tsx b/x-pack/legacy/plugins/siem/public/components/charts/common.tsx index d8429cba1b4fb..c7b40c50ffde8 100644 --- a/x-pack/legacy/plugins/siem/public/components/charts/common.tsx +++ b/x-pack/legacy/plugins/siem/public/components/charts/common.tsx @@ -19,8 +19,8 @@ import { import React, { useMemo } from 'react'; import styled from 'styled-components'; +import { DEFAULT_DARK_MODE } from '../../../../../../plugins/siem/common/constants'; import { useUiSetting } from '../../lib/kibana'; -import { DEFAULT_DARK_MODE } from '../../../common/constants'; export const defaultChartHeight = '100%'; export const defaultChartWidth = '100%'; diff --git a/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend.test.tsx b/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend.test.tsx new file mode 100644 index 0000000000000..0da0c2bdc35f2 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend.test.tsx @@ -0,0 +1,149 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; +import { mount, ReactWrapper } from 'enzyme'; +import React from 'react'; +import { ThemeProvider } from 'styled-components'; + +import { TestProviders } from '../../mock'; + +import { MIN_LEGEND_HEIGHT, DraggableLegend } from './draggable_legend'; +import { LegendItem } from './draggable_legend_item'; + +const theme = () => ({ eui: euiDarkVars, darkMode: true }); + +const allOthersDataProviderId = + 'draggable-legend-item-527adabe-8e1c-4a1f-965c-2f3d65dda9e1-event_dataset-All others'; + +const legendItems: LegendItem[] = [ + { + color: '#1EA593', + dataProviderId: 'draggable-legend-item-3207fda7-d008-402a-86a0-8ad632081bad-event_dataset-flow', + field: 'event.dataset', + value: 'flow', + }, + { + color: '#2B70F7', + dataProviderId: + 'draggable-legend-item-83f6c824-811d-4ec8-b373-eba2b0de6398-event_dataset-suricata_eve', + field: 'event.dataset', + value: 'suricata.eve', + }, + { + color: '#CE0060', + dataProviderId: + 'draggable-legend-item-ec57bb8f-82cd-4e07-bd38-1d11b3f0ee5f-event_dataset-traefik_access', + field: 'event.dataset', + value: 'traefik.access', + }, + { + color: '#38007E', + dataProviderId: + 'draggable-legend-item-25d5fcd6-87ba-46b5-893e-c655d7d504e3-event_dataset-esensor', + field: 'event.dataset', + value: 'esensor', + }, + { + color: '#F37020', + dataProviderId: allOthersDataProviderId, + field: 'event.dataset', + value: 'All others', + }, +]; + +describe('DraggableLegend', () => { + const height = 400; + + // Suppress warnings about "react-beautiful-dnd" + /* eslint-disable no-console */ + const originalError = console.error; + const originalWarn = console.warn; + beforeAll(() => { + console.warn = jest.fn(); + console.error = jest.fn(); + }); + afterAll(() => { + console.error = originalError; + console.warn = originalWarn; + }); + + describe('rendering', () => { + let wrapper: ReactWrapper; + + beforeEach(() => { + wrapper = mount( + + + + + + ); + }); + + it(`renders a container with the specified non-zero 'height'`, () => { + expect(wrapper.find('[data-test-subj="draggable-legend"]').first()).toHaveStyleRule( + 'height', + `${height}px` + ); + }); + + it('scrolls when necessary', () => { + expect(wrapper.find('[data-test-subj="draggable-legend"]').first()).toHaveStyleRule( + 'overflow', + 'auto' + ); + }); + + it('renders the legend items', () => { + legendItems.forEach(item => + expect( + wrapper + .find( + item.dataProviderId !== allOthersDataProviderId + ? `[data-test-subj="legend-item-${item.dataProviderId}"]` + : '[data-test-subj="all-others-legend-item"]' + ) + .first() + .text() + ).toEqual(item.value) + ); + }); + + it('renders a spacer for every legend item', () => { + expect(wrapper.find('[data-test-subj="draggable-legend-spacer"]').hostNodes().length).toEqual( + legendItems.length + ); + }); + }); + + it('does NOT render the legend when an empty collection of legendItems is provided', () => { + const wrapper = mount( + + + + + + ); + + expect(wrapper.find('[data-test-subj="draggable-legend"]').exists()).toBe(false); + }); + + it(`renders a legend with the minimum height when 'height' is zero`, () => { + const wrapper = mount( + + + + + + ); + + expect(wrapper.find('[data-test-subj="draggable-legend"]').first()).toHaveStyleRule( + 'height', + `${MIN_LEGEND_HEIGHT}px` + ); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend.tsx b/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend.tsx new file mode 100644 index 0000000000000..ef3fbb8780d15 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend.tsx @@ -0,0 +1,68 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiText } from '@elastic/eui'; +import { rgba } from 'polished'; +import React from 'react'; +import styled from 'styled-components'; + +import { DraggableLegendItem, LegendItem } from './draggable_legend_item'; + +export const MIN_LEGEND_HEIGHT = 175; + +const DraggableLegendContainer = styled.div<{ height: number }>` + height: ${({ height }) => `${height}px`}; + overflow: auto; + scrollbar-width: thin; + width: 165px; + + &::-webkit-scrollbar { + height: ${({ theme }) => theme.eui.euiScrollBar}; + width: ${({ theme }) => theme.eui.euiScrollBar}; + } + + &::-webkit-scrollbar-thumb { + background-clip: content-box; + background-color: ${({ theme }) => rgba(theme.eui.euiColorDarkShade, 0.5)}; + border: ${({ theme }) => theme.eui.euiScrollBarCorner} solid transparent; + } + + &::-webkit-scrollbar-corner, + &::-webkit-scrollbar-track { + background-color: transparent; + } +`; + +const DraggableLegendComponent: React.FC<{ + height: number; + legendItems: LegendItem[]; +}> = ({ height, legendItems }) => { + if (legendItems.length === 0) { + return null; + } + + return ( + + + + {legendItems.map(item => ( + + + + + ))} + + + + ); +}; + +DraggableLegendComponent.displayName = 'DraggableLegendComponent'; + +export const DraggableLegend = React.memo(DraggableLegendComponent); diff --git a/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend_item.test.tsx b/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend_item.test.tsx new file mode 100644 index 0000000000000..581952a8415f6 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend_item.test.tsx @@ -0,0 +1,143 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; +import { mount, ReactWrapper } from 'enzyme'; +import React from 'react'; +import { ThemeProvider } from 'styled-components'; + +import { TestProviders } from '../../mock'; + +import { DraggableLegendItem, LegendItem } from './draggable_legend_item'; + +const theme = () => ({ eui: euiDarkVars, darkMode: true }); + +describe('DraggableLegendItem', () => { + // Suppress warnings about "react-beautiful-dnd" + /* eslint-disable no-console */ + const originalError = console.error; + const originalWarn = console.warn; + beforeAll(() => { + console.warn = jest.fn(); + console.error = jest.fn(); + }); + afterAll(() => { + console.error = originalError; + console.warn = originalWarn; + }); + + describe('rendering a regular (non "All others") legend item', () => { + const legendItem: LegendItem = { + color: '#1EA593', + dataProviderId: + 'draggable-legend-item-3207fda7-d008-402a-86a0-8ad632081bad-event_dataset-flow', + field: 'event.dataset', + value: 'flow', + }; + + let wrapper: ReactWrapper; + + beforeEach(() => { + wrapper = mount( + + + + + + ); + }); + + it('renders a colored circle with the expected legend item color', () => { + expect( + wrapper + .find('[data-test-subj="legend-color"]') + .first() + .props().color + ).toEqual(legendItem.color); + }); + + it('renders draggable legend item text', () => { + expect( + wrapper + .find(`[data-test-subj="legend-item-${legendItem.dataProviderId}"]`) + .first() + .text() + ).toEqual(legendItem.value); + }); + + it('does NOT render a non-draggable "All others" legend item', () => { + expect(wrapper.find(`[data-test-subj="all-others-legend-item"]`).exists()).toBe(false); + }); + }); + + describe('rendering an "All others" legend item', () => { + const allOthersLegendItem: LegendItem = { + color: '#F37020', + dataProviderId: + 'draggable-legend-item-527adabe-8e1c-4a1f-965c-2f3d65dda9e1-event_dataset-All others', + field: 'event.dataset', + value: 'All others', + }; + + let wrapper: ReactWrapper; + + beforeEach(() => { + wrapper = mount( + + + + + + ); + }); + + it('renders a colored circle with the expected legend item color', () => { + expect( + wrapper + .find('[data-test-subj="legend-color"]') + .first() + .props().color + ).toEqual(allOthersLegendItem.color); + }); + + it('does NOT render a draggable legend item', () => { + expect( + wrapper + .find(`[data-test-subj="legend-item-${allOthersLegendItem.dataProviderId}"]`) + .exists() + ).toBe(false); + }); + + it('renders NON-draggable `All others` legend item text', () => { + expect( + wrapper + .find(`[data-test-subj="all-others-legend-item"]`) + .first() + .text() + ).toEqual(allOthersLegendItem.value); + }); + }); + + it('does NOT render a colored circle when the legend item has no color', () => { + const noColorLegendItem: LegendItem = { + // no `color` attribute for this `LegendItem`! + dataProviderId: + 'draggable-legend-item-3207fda7-d008-402a-86a0-8ad632081bad-event_dataset-flow', + field: 'event.dataset', + value: 'flow', + }; + + const wrapper = mount( + + + + + + ); + + expect(wrapper.find('[data-test-subj="legend-color"]').exists()).toBe(false); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend_item.tsx b/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend_item.tsx new file mode 100644 index 0000000000000..cdda1733932d5 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/charts/draggable_legend_item.tsx @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { EuiFlexGroup, EuiFlexItem, EuiHealth, EuiText } from '@elastic/eui'; +import React from 'react'; +import styled from 'styled-components'; + +import { DefaultDraggable } from '../draggables'; + +import * as i18n from './translation'; + +// The "All others" legend item is not draggable +const AllOthers = styled.span` + padding-left: 7px; +`; + +export interface LegendItem { + color?: string; + dataProviderId: string; + field: string; + value: string; +} + +const DraggableLegendItemComponent: React.FC<{ + legendItem: LegendItem; +}> = ({ legendItem }) => { + const { color, dataProviderId, field, value } = legendItem; + + return ( + + + {color != null && ( + + + + )} + + + {value !== i18n.ALL_OTHERS ? ( + + ) : ( + <> + {value} + + )} + + + + ); +}; + +DraggableLegendItemComponent.displayName = 'DraggableLegendItemComponent'; + +export const DraggableLegendItem = React.memo(DraggableLegendItemComponent); diff --git a/x-pack/legacy/plugins/siem/public/components/charts/translation.ts b/x-pack/legacy/plugins/siem/public/components/charts/translation.ts index 341cb7782f87c..891f59fc97bd1 100644 --- a/x-pack/legacy/plugins/siem/public/components/charts/translation.ts +++ b/x-pack/legacy/plugins/siem/public/components/charts/translation.ts @@ -13,3 +13,7 @@ export const ALL_VALUES_ZEROS_TITLE = i18n.translate('xpack.siem.chart.dataAllVa export const DATA_NOT_AVAILABLE_TITLE = i18n.translate('xpack.siem.chart.dataNotAvailableTitle', { defaultMessage: 'Chart Data Not Available', }); + +export const ALL_OTHERS = i18n.translate('xpack.siem.chart.allOthersGroupingLabel', { + defaultMessage: 'All others', +}); diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/drag_drop_context_wrapper.tsx b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/drag_drop_context_wrapper.tsx index 11db33fff6d72..248ae671550ef 100644 --- a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/drag_drop_context_wrapper.tsx +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/drag_drop_context_wrapper.tsx @@ -27,6 +27,9 @@ import { draggableIsField, } from './helpers'; +// @ts-ignore +window['__react-beautiful-dnd-disable-dev-warnings'] = true; + interface Props { browserFields: BrowserFields; children: React.ReactNode; diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.test.tsx b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.test.tsx index 11891afabbf3d..cd9e1dc95ff01 100644 --- a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.test.tsx @@ -7,12 +7,13 @@ import { shallow } from 'enzyme'; import React from 'react'; import { MockedProvider } from 'react-apollo/test-utils'; +import { DraggableStateSnapshot, DraggingStyle } from 'react-beautiful-dnd'; import { mockBrowserFields, mocksSource } from '../../containers/source/mock'; import { TestProviders } from '../../mock'; import { mockDataProviders } from '../timeline/data_providers/mock/mock_data_providers'; import { DragDropContextWrapper } from './drag_drop_context_wrapper'; -import { DraggableWrapper, ConditionalPortal } from './draggable_wrapper'; +import { ConditionalPortal, DraggableWrapper, getStyle } from './draggable_wrapper'; import { useMountAppended } from '../../utils/use_mount_appended'; describe('DraggableWrapper', () => { @@ -48,6 +49,36 @@ describe('DraggableWrapper', () => { expect(wrapper.text()).toEqual(message); }); + + test('it does NOT render hover actions when the mouse is NOT over the draggable wrapper', () => { + const wrapper = mount( + + + + message} /> + + + + ); + + expect(wrapper.find('[data-test-subj="copy-to-clipboard"]').exists()).toBe(false); + }); + + test('it renders hover actions when the mouse is over the draggable wrapper', () => { + const wrapper = mount( + + + + message} /> + + + + ); + + wrapper.simulate('mouseenter'); + wrapper.update(); + expect(wrapper.find('[data-test-subj="copy-to-clipboard"]').exists()).toBe(true); + }); }); describe('text truncation styling', () => { @@ -100,4 +131,36 @@ describe('ConditionalPortal', () => { expect(props.registerProvider.mock.calls.length).toEqual(1); }); + + describe('getStyle', () => { + const style: DraggingStyle = { + boxSizing: 'border-box', + height: 10, + left: 1, + pointerEvents: 'none', + position: 'fixed', + transition: 'none', + top: 123, + width: 50, + zIndex: 9999, + }; + + it('returns a style with no transitionDuration when the snapshot is not drop animating', () => { + const snapshot: DraggableStateSnapshot = { + isDragging: true, + isDropAnimating: false, // <-- NOT drop animating + }; + + expect(getStyle(style, snapshot)).not.toHaveProperty('transitionDuration'); + }); + + it('returns a style with a transitionDuration when the snapshot is drop animating', () => { + const snapshot: DraggableStateSnapshot = { + isDragging: true, + isDropAnimating: true, // <-- it is drop animating + }; + + expect(getStyle(style, snapshot)).toHaveProperty('transitionDuration', '0.00000001s'); + }); + }); }); diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx index 3a6a4de7984db..c7da5b5c58951 100644 --- a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx @@ -4,12 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useCallback, useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Draggable, DraggableProvided, DraggableStateSnapshot, + DraggingStyle, Droppable, + NotDraggingStyle, } from 'react-beautiful-dnd'; import { useDispatch } from 'react-redux'; import styled from 'styled-components'; @@ -18,6 +20,9 @@ import deepEqual from 'fast-deep-equal'; import { dragAndDropActions } from '../../store/drag_and_drop'; import { DataProvider } from '../timeline/data_providers/data_provider'; import { TruncatableText } from '../truncatable_text'; +import { WithHoverActions } from '../with_hover_actions'; + +import { DraggableWrapperHoverContent } from './draggable_wrapper_hover_content'; import { getDraggableId, getDroppableId } from './helpers'; import { ProviderContainer } from './provider_container'; @@ -67,23 +72,42 @@ type RenderFunctionProp = ( state: DraggableStateSnapshot ) => React.ReactNode; -interface OwnProps { +interface Props { dataProvider: DataProvider; inline?: boolean; render: RenderFunctionProp; truncate?: boolean; + onFilterAdded?: () => void; } -type Props = OwnProps; - /** * Wraps a draggable component to handle registration / unregistration of the * data provider associated with the item being dropped */ +export const getStyle = ( + style: DraggingStyle | NotDraggingStyle | undefined, + snapshot: DraggableStateSnapshot +) => { + if (!snapshot.isDropAnimating) { + return style; + } + + return { + ...style, + transitionDuration: '0.00000001s', // cannot be 0, but can be a very short duration + }; +}; + export const DraggableWrapper = React.memo( - ({ dataProvider, render, truncate }) => { + ({ dataProvider, onFilterAdded, render, truncate }) => { + const [showTopN, setShowTopN] = useState(false); + const toggleTopN = useCallback(() => { + setShowTopN(!showTopN); + }, [setShowTopN, showTopN]); + const [providerRegistered, setProviderRegistered] = useState(false); + const dispatch = useDispatch(); const registerProvider = useCallback(() => { @@ -105,65 +129,90 @@ export const DraggableWrapper = React.memo( [] ); - return ( - - - ( - -
- ( + + ), + [dataProvider, onFilterAdded, showTopN, toggleTopN] + ); + + const renderContent = useCallback( + () => ( + + + ( + +
- {render(dataProvider, provided, snapshot)} - -
-
- )} - > - {droppableProvided => ( -
- - {(provided, snapshot) => ( - - {truncate && !snapshot.isDragging ? ( - - {render(dataProvider, provided, snapshot)} - - ) : ( - - {render(dataProvider, provided, snapshot)} - - )} - - )} - - {droppableProvided.placeholder} -
- )} -
-
-
+ {render(dataProvider, provided, snapshot)} +
+
+
+ )} + > + {droppableProvided => ( +
+ + {(provided, snapshot) => ( + + {truncate && !snapshot.isDragging ? ( + + {render(dataProvider, provided, snapshot)} + + ) : ( + + {render(dataProvider, provided, snapshot)} + + )} + + )} + + {droppableProvided.placeholder} +
+ )} +
+
+
+ ), + [dataProvider, render, registerProvider, truncate] + ); + + return ( + ); }, (prevProps, nextProps) => diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper_hover_content.test.tsx b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper_hover_content.test.tsx new file mode 100644 index 0000000000000..f8b5eb7209ff4 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper_hover_content.test.tsx @@ -0,0 +1,559 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { mount, ReactWrapper } from 'enzyme'; +import React from 'react'; +import { MockedProvider } from 'react-apollo/test-utils'; + +import { mocksSource } from '../../containers/source/mock'; +import { wait } from '../../lib/helpers'; +import { useKibana } from '../../lib/kibana'; +import { TestProviders } from '../../mock'; +import { createKibanaCoreStartMock } from '../../mock/kibana_core'; +import { FilterManager } from '../../../../../../../src/plugins/data/public'; +import { TimelineContext } from '../timeline/timeline_context'; + +import { DraggableWrapperHoverContent } from './draggable_wrapper_hover_content'; + +jest.mock('../../lib/kibana'); + +jest.mock('uuid', () => { + return { + v1: jest.fn(() => 'uuid.v1()'), + v4: jest.fn(() => 'uuid.v4()'), + }; +}); + +const mockUiSettingsForFilterManager = createKibanaCoreStartMock().uiSettings; +const field = 'process.name'; +const value = 'nice'; + +describe('DraggableWrapperHoverContent', () => { + // Suppress warnings about "react-beautiful-dnd" + /* eslint-disable no-console */ + const originalError = console.error; + const originalWarn = console.warn; + beforeAll(() => { + console.warn = jest.fn(); + console.error = jest.fn(); + }); + afterAll(() => { + console.error = originalError; + console.warn = originalWarn; + }); + + /** + * The tests for "Filter for value" and "Filter out value" are similar enough + * to combine them into "table tests" using this array + */ + const forOrOut = ['for', 'out']; + + forOrOut.forEach(hoverAction => { + describe(`Filter ${hoverAction} value`, () => { + test(`it renders the 'Filter ${hoverAction} value' button when showTopN is false`, () => { + const wrapper = mount( + + + + ); + + expect( + wrapper + .find(`[data-test-subj="filter-${hoverAction}-value"]`) + .first() + .exists() + ).toBe(true); + }); + + test(`it does NOT render the 'Filter ${hoverAction} value' button when showTopN is true`, () => { + const wrapper = mount( + + + + ); + + expect( + wrapper + .find(`[data-test-subj="filter-${hoverAction}-value"]`) + .first() + .exists() + ).toBe(false); + }); + + describe('when run in the context of a timeline', () => { + let filterManager: FilterManager; + let wrapper: ReactWrapper; + let onFilterAdded: () => void; + + beforeEach(() => { + filterManager = new FilterManager(mockUiSettingsForFilterManager); + filterManager.addFilters = jest.fn(); + onFilterAdded = jest.fn(); + + wrapper = mount( + + + + + + ); + }); + + test('when clicked, it adds a filter to the timeline when running in the context of a timeline', () => { + wrapper + .find(`[data-test-subj="filter-${hoverAction}-value"]`) + .first() + .simulate('click'); + wrapper.update(); + + expect(filterManager.addFilters).toBeCalledWith({ + meta: { + alias: null, + disabled: false, + key: 'process.name', + negate: hoverAction === 'out' ? true : false, + params: { query: 'nice' }, + type: 'phrase', + value: 'nice', + }, + query: { match: { 'process.name': { query: 'nice', type: 'phrase' } } }, + }); + }); + + test('when clicked, invokes onFilterAdded when running in the context of a timeline', () => { + wrapper + .find(`[data-test-subj="filter-${hoverAction}-value"]`) + .first() + .simulate('click'); + wrapper.update(); + + expect(onFilterAdded).toBeCalled(); + }); + }); + + describe('when NOT run in the context of a timeline', () => { + let wrapper: ReactWrapper; + let onFilterAdded: () => void; + const kibana = useKibana(); + + beforeEach(() => { + kibana.services.data.query.filterManager.addFilters = jest.fn(); + onFilterAdded = jest.fn(); + + wrapper = mount( + + + + ); + }); + + test('when clicked, it adds a filter to the global filters when NOT running in the context of a timeline', () => { + wrapper + .find(`[data-test-subj="filter-${hoverAction}-value"]`) + .first() + .simulate('click'); + wrapper.update(); + + expect(kibana.services.data.query.filterManager.addFilters).toBeCalledWith({ + meta: { + alias: null, + disabled: false, + key: 'process.name', + negate: hoverAction === 'out' ? true : false, + params: { query: 'nice' }, + type: 'phrase', + value: 'nice', + }, + query: { match: { 'process.name': { query: 'nice', type: 'phrase' } } }, + }); + }); + + test('when clicked, invokes onFilterAdded when NOT running in the context of a timeline', () => { + wrapper + .find(`[data-test-subj="filter-${hoverAction}-value"]`) + .first() + .simulate('click'); + wrapper.update(); + + expect(onFilterAdded).toBeCalled(); + }); + }); + + describe('an empty string value when run in the context of a timeline', () => { + let filterManager: FilterManager; + let wrapper: ReactWrapper; + let onFilterAdded: () => void; + + beforeEach(() => { + filterManager = new FilterManager(mockUiSettingsForFilterManager); + filterManager.addFilters = jest.fn(); + onFilterAdded = jest.fn(); + + wrapper = mount( + + + + + + ); + }); + + const expectedFilterTypeDescription = + hoverAction === 'for' ? 'a "NOT exists"' : 'an "exists"'; + test(`when clicked, it adds ${expectedFilterTypeDescription} filter to the timeline when run in the context of a timeline`, () => { + const expected = + hoverAction === 'for' + ? { + exists: { field: 'process.name' }, + meta: { + alias: null, + disabled: false, + key: 'process.name', + negate: true, + type: 'exists', + value: 'exists', + }, + } + : { + exists: { field: 'process.name' }, + meta: { + alias: null, + disabled: false, + key: 'process.name', + negate: false, + type: 'exists', + value: 'exists', + }, + }; + + wrapper + .find(`[data-test-subj="filter-${hoverAction}-value"]`) + .first() + .simulate('click'); + wrapper.update(); + + expect(filterManager.addFilters).toBeCalledWith(expected); + }); + }); + + describe('an empty string value when NOT run in the context of a timeline', () => { + let wrapper: ReactWrapper; + let onFilterAdded: () => void; + const kibana = useKibana(); + + beforeEach(() => { + kibana.services.data.query.filterManager.addFilters = jest.fn(); + onFilterAdded = jest.fn(); + + wrapper = mount( + + + + ); + }); + + const expectedFilterTypeDescription = + hoverAction === 'for' ? 'a "NOT exists"' : 'an "exists"'; + test(`when clicked, it adds ${expectedFilterTypeDescription} filter to the global filters when NOT running in the context of a timeline`, () => { + const expected = + hoverAction === 'for' + ? { + exists: { field: 'process.name' }, + meta: { + alias: null, + disabled: false, + key: 'process.name', + negate: true, + type: 'exists', + value: 'exists', + }, + } + : { + exists: { field: 'process.name' }, + meta: { + alias: null, + disabled: false, + key: 'process.name', + negate: false, + type: 'exists', + value: 'exists', + }, + }; + + wrapper + .find(`[data-test-subj="filter-${hoverAction}-value"]`) + .first() + .simulate('click'); + wrapper.update(); + + expect(kibana.services.data.query.filterManager.addFilters).toBeCalledWith(expected); + }); + }); + }); + }); + + describe('Top N', () => { + test(`it renders the 'Show top field' button when showTopN is false and an aggregatable string field is provided`, async () => { + const aggregatableStringField = 'cloud.account.id'; + const wrapper = mount( + + + + + + ); + + await wait(); // https://github.com/apollographql/react-apollo/issues/1711 + wrapper.update(); + + expect( + wrapper + .find('[data-test-subj="show-top-field"]') + .first() + .exists() + ).toBe(true); + }); + + test(`it renders the 'Show top field' button when showTopN is false and a whitelisted signal field is provided`, async () => { + const whitelistedField = 'signal.rule.name'; + const wrapper = mount( + + + + + + ); + + await wait(); + wrapper.update(); + + expect( + wrapper + .find('[data-test-subj="show-top-field"]') + .first() + .exists() + ).toBe(true); + }); + + test(`it does NOT render the 'Show top field' button when showTopN is false and a field not known to BrowserFields is provided`, async () => { + const notKnownToBrowserFields = 'unknown.field'; + const wrapper = mount( + + + + + + ); + + await wait(); + wrapper.update(); + + expect( + wrapper + .find('[data-test-subj="show-top-field"]') + .first() + .exists() + ).toBe(false); + }); + + test(`invokes the toggleTopN function when the 'Show top field' button is clicked`, async () => { + const toggleTopN = jest.fn(); + const whitelistedField = 'signal.rule.name'; + const wrapper = mount( + + + + + + ); + + await wait(); + wrapper.update(); + + wrapper + .find('[data-test-subj="show-top-field"]') + .first() + .simulate('click'); + wrapper.update(); + + expect(toggleTopN).toBeCalled(); + }); + + test(`it does NOT render the Top N histogram when when showTopN is false`, async () => { + const whitelistedField = 'signal.rule.name'; + const wrapper = mount( + + + + + + ); + + await wait(); + wrapper.update(); + + expect( + wrapper + .find('[data-test-subj="eventsByDatasetOverviewPanel"]') + .first() + .exists() + ).toBe(false); + }); + + test(`it does NOT render the 'Show top field' button when showTopN is true`, async () => { + const whitelistedField = 'signal.rule.name'; + const wrapper = mount( + + + + + + ); + + await wait(); + wrapper.update(); + + expect( + wrapper + .find('[data-test-subj="show-top-field"]') + .first() + .exists() + ).toBe(false); + }); + + test(`it renders the Top N histogram when when showTopN is true`, async () => { + const whitelistedField = 'signal.rule.name'; + const wrapper = mount( + + + + + + ); + + await wait(); + wrapper.update(); + + expect( + wrapper + .find('[data-test-subj="eventsByDatasetOverview-uuid.v4()Panel"]') + .first() + .exists() + ).toBe(true); + }); + }); + + describe('Copy to Clipboard', () => { + test(`it renders the 'Copy to Clipboard' button when showTopN is false`, () => { + const wrapper = mount( + + + + ); + + expect( + wrapper + .find(`[data-test-subj="copy-to-clipboard"]`) + .first() + .exists() + ).toBe(true); + }); + + test(`it does NOT render the 'Copy to Clipboard' button when showTopN is true`, () => { + const wrapper = mount( + + + + ); + + expect( + wrapper + .find(`[data-test-subj="copy-to-clipboard"]`) + .first() + .exists() + ).toBe(false); + }); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper_hover_content.tsx b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper_hover_content.tsx new file mode 100644 index 0000000000000..40725bea498f1 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/draggable_wrapper_hover_content.tsx @@ -0,0 +1,145 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { EuiButtonIcon, EuiToolTip } from '@elastic/eui'; +import React, { useCallback, useMemo } from 'react'; + +import { getAllFieldsByName, WithSource } from '../../containers/source'; +import { WithCopyToClipboard } from '../../lib/clipboard/with_copy_to_clipboard'; +import { useKibana } from '../../lib/kibana'; +import { createFilter } from '../page/add_filter_to_global_search_bar'; +import { useTimelineContext } from '../timeline/timeline_context'; +import { StatefulTopN } from '../top_n'; + +import { allowTopN } from './helpers'; +import * as i18n from './translations'; + +interface Props { + field: string; + onFilterAdded?: () => void; + showTopN: boolean; + toggleTopN: () => void; + value?: string[] | string | null; +} + +const DraggableWrapperHoverContentComponent: React.FC = ({ + field, + onFilterAdded, + showTopN, + toggleTopN, + value, +}) => { + const kibana = useKibana(); + const { filterManager: timelineFilterManager } = useTimelineContext(); + const filterManager = useMemo(() => kibana.services.data.query.filterManager, [ + kibana.services.data.query.filterManager, + ]); + + const filterForValue = useCallback(() => { + const filter = + value?.length === 0 ? createFilter(field, undefined) : createFilter(field, value); + const activeFilterManager = timelineFilterManager ?? filterManager; + + if (activeFilterManager != null) { + activeFilterManager.addFilters(filter); + + if (onFilterAdded != null) { + onFilterAdded(); + } + } + }, [field, value, timelineFilterManager, filterManager, onFilterAdded]); + + const filterOutValue = useCallback(() => { + const filter = + value?.length === 0 ? createFilter(field, null, false) : createFilter(field, value, true); + const activeFilterManager = timelineFilterManager ?? filterManager; + + if (activeFilterManager != null) { + activeFilterManager.addFilters(filter); + + if (onFilterAdded != null) { + onFilterAdded(); + } + } + }, [field, value, timelineFilterManager, filterManager, onFilterAdded]); + + return ( + <> + {!showTopN && value != null && ( + + + + )} + + {!showTopN && value != null && ( + + + + )} + + + {({ browserFields }) => ( + <> + {allowTopN({ + browserField: getAllFieldsByName(browserFields)[field], + fieldName: field, + }) && ( + <> + {!showTopN && ( + + + + )} + + {showTopN && ( + + )} + + )} + + )} + + + {!showTopN && ( + + + + )} + + ); +}; + +DraggableWrapperHoverContentComponent.displayName = 'DraggableWrapperHoverContentComponent'; + +export const DraggableWrapperHoverContent = React.memo(DraggableWrapperHoverContentComponent); diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.test.ts b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.test.ts index af4b9b280f3cd..753fa5b54eade 100644 --- a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.test.ts +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.test.ts @@ -4,7 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ +import { omit } from 'lodash/fp'; + import { + allowTopN, destinationIsTimelineButton, destinationIsTimelineColumns, destinationIsTimelineProviders, @@ -717,4 +720,96 @@ describe('helpers', () => { expect(escaped).toEqual('hello.how.are.you?'); }); }); + + describe('#allowTopN', () => { + const aggregatableAllowedType = { + category: 'cloud', + description: + 'The cloud account or organization id used to identify different entities in a multi-tenant environment. Examples: AWS account id, Google Cloud ORG Id, or other unique identifier.', + example: '666777888999', + indexes: ['auditbeat', 'filebeat', 'packetbeat'], + name: 'cloud.account.id', + searchable: true, + type: 'string', + aggregatable: true, + format: '', + }; + + test('it returns true for an aggregatable field that is an allowed type', () => { + expect( + allowTopN({ + browserField: aggregatableAllowedType, + fieldName: aggregatableAllowedType.name, + }) + ).toBe(true); + }); + + test('it returns true for a whitelisted non-BrowserField', () => { + expect( + allowTopN({ + browserField: undefined, + fieldName: 'signal.rule.name', + }) + ).toBe(true); + }); + + test('it returns false for a NON-aggregatable field that is an allowed type', () => { + const nonAggregatableAllowedType = { + ...aggregatableAllowedType, + aggregatable: false, + }; + + expect( + allowTopN({ + browserField: nonAggregatableAllowedType, + fieldName: nonAggregatableAllowedType.name, + }) + ).toBe(false); + }); + + test('it returns false for a aggregatable field that is NOT an allowed type', () => { + const aggregatableNotAllowedType = { + ...aggregatableAllowedType, + type: 'not-an-allowed-type', + }; + + expect( + allowTopN({ + browserField: aggregatableNotAllowedType, + fieldName: aggregatableNotAllowedType.name, + }) + ).toBe(false); + }); + + test('it returns false if the BrowserField is missing the aggregatable property', () => { + const missingAggregatable = omit('aggregatable', aggregatableAllowedType); + + expect( + allowTopN({ + browserField: missingAggregatable, + fieldName: missingAggregatable.name, + }) + ).toBe(false); + }); + + test('it returns false if the BrowserField is missing the type property', () => { + const missingType = omit('type', aggregatableAllowedType); + + expect( + allowTopN({ + browserField: missingType, + fieldName: missingType.name, + }) + ).toBe(false); + }); + + test('it returns false for a non-whitelisted field when a BrowserField is not provided', () => { + expect( + allowTopN({ + browserField: undefined, + fieldName: 'non-whitelisted', + }) + ).toBe(false); + }); + }); }); diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.ts b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.ts index 82ddd2c9f29d7..cd3d7cc68d537 100644 --- a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/helpers.ts @@ -9,7 +9,7 @@ import { DropResult } from 'react-beautiful-dnd'; import { Dispatch } from 'redux'; import { ActionCreator } from 'typescript-fsa'; -import { BrowserFields, getAllFieldsByName } from '../../containers/source'; +import { BrowserField, BrowserFields, getAllFieldsByName } from '../../containers/source'; import { IdToDataProvider } from '../../store/drag_and_drop/model'; import { ColumnHeaderOptions } from '../../store/timeline/model'; import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/constants'; @@ -227,3 +227,98 @@ export const IS_DRAGGING_CLASS_NAME = 'is-dragging'; /** This class is added to the document body while timeline field dragging */ export const IS_TIMELINE_FIELD_DRAGGING_CLASS_NAME = 'is-timeline-field-dragging'; + +export const allowTopN = ({ + browserField, + fieldName, +}: { + browserField: Partial | undefined; + fieldName: string; +}): boolean => { + const isAggregatable = browserField?.aggregatable ?? false; + const fieldType = browserField?.type ?? ''; + const isAllowedType = [ + 'boolean', + 'geo-point', + 'geo-shape', + 'ip', + 'keyword', + 'number', + 'numeric', + 'string', + ].includes(fieldType); + + // TODO: remove this explicit whitelist when the ECS documentation includes signals + const isWhitelistedNonBrowserField = [ + 'signal.ancestors.depth', + 'signal.ancestors.id', + 'signal.ancestors.rule', + 'signal.ancestors.type', + 'signal.original_event.action', + 'signal.original_event.category', + 'signal.original_event.code', + 'signal.original_event.created', + 'signal.original_event.dataset', + 'signal.original_event.duration', + 'signal.original_event.end', + 'signal.original_event.hash', + 'signal.original_event.id', + 'signal.original_event.kind', + 'signal.original_event.module', + 'signal.original_event.original', + 'signal.original_event.outcome', + 'signal.original_event.provider', + 'signal.original_event.risk_score', + 'signal.original_event.risk_score_norm', + 'signal.original_event.sequence', + 'signal.original_event.severity', + 'signal.original_event.start', + 'signal.original_event.timezone', + 'signal.original_event.type', + 'signal.original_time', + 'signal.parent.depth', + 'signal.parent.id', + 'signal.parent.index', + 'signal.parent.rule', + 'signal.parent.type', + 'signal.rule.created_by', + 'signal.rule.description', + 'signal.rule.enabled', + 'signal.rule.false_positives', + 'signal.rule.filters', + 'signal.rule.from', + 'signal.rule.id', + 'signal.rule.immutable', + 'signal.rule.index', + 'signal.rule.interval', + 'signal.rule.language', + 'signal.rule.max_signals', + 'signal.rule.name', + 'signal.rule.note', + 'signal.rule.output_index', + 'signal.rule.query', + 'signal.rule.references', + 'signal.rule.risk_score', + 'signal.rule.rule_id', + 'signal.rule.saved_id', + 'signal.rule.severity', + 'signal.rule.size', + 'signal.rule.tags', + 'signal.rule.threat', + 'signal.rule.threat.tactic.id', + 'signal.rule.threat.tactic.name', + 'signal.rule.threat.tactic.reference', + 'signal.rule.threat.technique.id', + 'signal.rule.threat.technique.name', + 'signal.rule.threat.technique.reference', + 'signal.rule.timeline_id', + 'signal.rule.timeline_title', + 'signal.rule.to', + 'signal.rule.type', + 'signal.rule.updated_by', + 'signal.rule.version', + 'signal.status', + ].includes(fieldName); + + return isWhitelistedNonBrowserField || (isAggregatable && isAllowedType); +}; diff --git a/x-pack/legacy/plugins/siem/public/components/drag_and_drop/translations.ts b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/translations.ts new file mode 100644 index 0000000000000..61d036635a250 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/drag_and_drop/translations.ts @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; + +export const COPY_TO_CLIPBOARD = i18n.translate('xpack.siem.dragAndDrop.copyToClipboardTooltip', { + defaultMessage: 'Copy to Clipboard', +}); + +export const FIELD = i18n.translate('xpack.siem.dragAndDrop.fieldLabel', { + defaultMessage: 'Field', +}); + +export const FILTER_FOR_VALUE = i18n.translate('xpack.siem.dragAndDrop.filterForValueHoverAction', { + defaultMessage: 'Filter for value', +}); + +export const FILTER_OUT_VALUE = i18n.translate('xpack.siem.dragAndDrop.filterOutValueHoverAction', { + defaultMessage: 'Filter out value', +}); + +export const CLOSE = i18n.translate('xpack.siem.dragAndDrop.closeButtonLabel', { + defaultMessage: 'Close', +}); + +export const SHOW_TOP = (fieldName: string) => + i18n.translate('xpack.siem.overview.showTopTooltip', { + values: { fieldName }, + defaultMessage: `Show top {fieldName}`, + }); diff --git a/x-pack/legacy/plugins/siem/public/components/draggables/__snapshots__/index.test.tsx.snap b/x-pack/legacy/plugins/siem/public/components/draggables/__snapshots__/index.test.tsx.snap index 63ba13306ecd8..93608a181adff 100644 --- a/x-pack/legacy/plugins/siem/public/components/draggables/__snapshots__/index.test.tsx.snap +++ b/x-pack/legacy/plugins/siem/public/components/draggables/__snapshots__/index.test.tsx.snap @@ -10,6 +10,7 @@ exports[`draggables rendering it renders the default Badge 1`] = ` A child of this diff --git a/x-pack/legacy/plugins/siem/public/components/draggables/index.tsx b/x-pack/legacy/plugins/siem/public/components/draggables/index.tsx index 1fe6c936d2823..b3811d05eea04 100644 --- a/x-pack/legacy/plugins/siem/public/components/draggables/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/draggables/index.tsx @@ -8,7 +8,6 @@ import { EuiBadge, EuiToolTip, IconType } from '@elastic/eui'; import React from 'react'; import styled from 'styled-components'; -import { Omit } from '../../../common/utility_types'; import { DragEffects, DraggableWrapper } from '../drag_and_drop/draggable_wrapper'; import { escapeDataProviderId } from '../drag_and_drop/helpers'; import { getEmptyStringTag } from '../empty_value'; @@ -167,7 +166,7 @@ export const DraggableBadge = React.memo( tooltipContent={tooltipContent} queryValue={queryValue} > - + {children ? children : value !== '' ? value : getEmptyStringTag()} diff --git a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx index cbb4006bbf933..a7272593c2b27 100644 --- a/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx +++ b/x-pack/legacy/plugins/siem/public/components/embeddables/embedded_map.tsx @@ -14,7 +14,7 @@ import { EmbeddablePanel, ErrorEmbeddable, } from '../../../../../../../src/plugins/embeddable/public'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { getIndexPatternTitleIdMapping } from '../../hooks/api/helpers'; import { useIndexPatterns } from '../../hooks/use_index_patterns'; import { Loader } from '../loader'; diff --git a/x-pack/legacy/plugins/siem/public/components/event_details/columns.tsx b/x-pack/legacy/plugins/siem/public/components/event_details/columns.tsx index cd94a9fdcb5ac..131a3a63bae30 100644 --- a/x-pack/legacy/plugins/siem/public/components/event_details/columns.tsx +++ b/x-pack/legacy/plugins/siem/public/components/event_details/columns.tsx @@ -21,7 +21,6 @@ import styled from 'styled-components'; import { BrowserFields } from '../../containers/source'; import { ToStringArray } from '../../graphql/types'; -import { WithCopyToClipboard } from '../../lib/clipboard/with_copy_to_clipboard'; import { ColumnHeaderOptions } from '../../store/timeline/model'; import { DragEffects } from '../drag_and_drop/draggable_wrapper'; import { DroppableWrapper } from '../drag_and_drop/droppable_wrapper'; @@ -35,7 +34,6 @@ import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/constants'; import { MESSAGE_FIELD_NAME } from '../timeline/body/renderers/constants'; import { FormattedFieldValue } from '../timeline/body/renderers/formatted_field'; import { OnUpdateColumns } from '../timeline/events'; -import { WithHoverActions } from '../with_hover_actions'; import { getIconFromType, getExampleText, getColumnsWithTimestamp } from './helpers'; import * as i18n from './translations'; import { EventFieldsData } from './types'; @@ -172,29 +170,18 @@ export const getColumns = ({ component="span" key={`event-details-value-flex-item-${contextId}-${eventId}-${data.field}-${i}-${value}`} > - - - - - - } - render={() => - data.field === MESSAGE_FIELD_NAME ? ( - - ) : ( - - ) - } - /> + {data.field === MESSAGE_FIELD_NAME ? ( + + ) : ( + + )}
))} diff --git a/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.tsx b/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.tsx index ea2cb661763fa..d210c749dae9c 100644 --- a/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.tsx +++ b/x-pack/legacy/plugins/siem/public/components/events_viewer/events_viewer.tsx @@ -95,6 +95,7 @@ const EventsViewerComponent: React.FC = ({ }) => { const columnsHeader = isEmpty(columns) ? defaultHeaders : columns; const kibana = useKibana(); + const { filterManager } = useKibana().services.data.query; const combinedQueries = combineQueries({ config: esQuery.getEsQueryConfig(kibana.services.uiSettings), dataProviders, @@ -168,7 +169,11 @@ const EventsViewerComponent: React.FC = ({ {utilityBar?.(refetch, totalCountMinusDeleted)} - + { }); }); - test('it renders a hover actions panel for the category name', () => { - const wrapper = mount( - - - - ); - expect( - wrapper - .find('[data-test-subj="category-link"]') - .first() - .find('[data-test-subj="hover-actions-panel-container"]') - .first() - .exists() - ).toBe(true); - }); - test('it renders the selected category with bold text', () => { const selectedCategoryId = 'auditd'; diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/category_columns.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/category_columns.tsx index 0c7dd7e908ce3..7133e9b848c5c 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/category_columns.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/category_columns.tsx @@ -6,15 +6,7 @@ /* eslint-disable react/display-name */ -import { - EuiIcon, - EuiFlexGroup, - EuiFlexItem, - EuiLink, - EuiPanel, - EuiText, - EuiToolTip, -} from '@elastic/eui'; +import { EuiIcon, EuiFlexGroup, EuiFlexItem, EuiLink, EuiText, EuiToolTip } from '@elastic/eui'; import React, { useContext } from 'react'; import styled from 'styled-components'; @@ -35,22 +27,6 @@ const CategoryName = styled.span<{ bold: boolean }>` CategoryName.displayName = 'CategoryName'; -const HoverActionsContainer = styled(EuiPanel)` - cursor: default; - left: 5px; - padding: 8px; - position: absolute; - top: -8px; -`; - -HoverActionsContainer.displayName = 'HoverActionsContainer'; - -const HoverActionsFlexGroup = styled(EuiFlexGroup)` - cursor: pointer; -`; - -HoverActionsFlexGroup.displayName = 'HoverActionsFlexGroup'; - const LinkContainer = styled.div` width: 100%; .euiLink { @@ -71,7 +47,7 @@ interface ToolTipProps { } const ToolTip = React.memo(({ categoryId, browserFields, onUpdateColumns }) => { - const isLoading = useContext(TimelineContext); + const { isLoading } = useContext(TimelineContext); return ( {!isLoading ? ( @@ -127,25 +103,11 @@ export const getCategoryColumns = ({ - - - - - - + } render={() => ( { expect(wrapper.find('[data-test-subj="copy-to-clipboard"]').exists()).toBe(true); }); - test('it renders a view category action menu item a user hovers over the name', () => { - const wrapper = mount( - - - - ); - - wrapper.simulate('mouseenter'); - wrapper.update(); - expect(wrapper.find('[data-test-subj="view-category"]').exists()).toBe(true); - }); - - test('it invokes onUpdateColumns when the view category action menu item is clicked', () => { - const onUpdateColumns = jest.fn(); - - const wrapper = mount( - - - - ); - - wrapper.simulate('mouseenter'); - wrapper.update(); - wrapper - .find('[data-test-subj="view-category"]') - .first() - .simulate('click'); - - expect(onUpdateColumns).toBeCalledWith([ - { - aggregatable: true, - category: 'base', - columnHeaderType: 'not-filtered', - description: - 'Date/time when the event originated. For log events this is the date/time when the event was generated, and not when it was read. Required field for all events.', - example: '2016-05-23T08:05:34.853Z', - id: '@timestamp', - type: 'date', - width: 190, - }, - ]); - }); - test('it highlights the text specified by the `highlight` prop', () => { const highlight = 'stamp'; diff --git a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx index fe434a6ad63ce..fc9633b6f8748 100644 --- a/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx +++ b/x-pack/legacy/plugins/siem/public/components/fields_browser/field_name.tsx @@ -4,26 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -import { - EuiButtonIcon, - EuiHighlight, - EuiIcon, - EuiFlexGroup, - EuiFlexItem, - EuiPanel, - EuiText, - EuiToolTip, -} from '@elastic/eui'; -import React, { useContext } from 'react'; +import { EuiButtonIcon, EuiHighlight, EuiIcon, EuiText, EuiToolTip } from '@elastic/eui'; +import React, { useCallback, useContext, useState, useMemo } from 'react'; import styled from 'styled-components'; -import { WithCopyToClipboard } from '../../lib/clipboard/with_copy_to_clipboard'; import { ColumnHeaderOptions } from '../../store/timeline/model'; import { OnUpdateColumns } from '../timeline/events'; import { TimelineContext } from '../timeline/timeline_context'; import { WithHoverActions } from '../with_hover_actions'; import { LoadingSpinner } from './helpers'; import * as i18n from './translations'; +import { DraggableWrapperHoverContent } from '../drag_and_drop/draggable_wrapper_hover_content'; /** * The name of a (draggable) field @@ -82,22 +73,6 @@ export const FieldNameContainer = styled.span` FieldNameContainer.displayName = 'FieldNameContainer'; -const HoverActionsContainer = styled(EuiPanel)` - cursor: default; - left: 5px; - padding: 4px; - position: absolute; - top: -6px; -`; - -HoverActionsContainer.displayName = 'HoverActionsContainer'; - -const HoverActionsFlexGroup = styled(EuiFlexGroup)` - cursor: pointer; -`; - -HoverActionsFlexGroup.displayName = 'HoverActionsFlexGroup'; - const ViewCategoryIcon = styled(EuiIcon)` margin-left: 5px; `; @@ -112,7 +87,7 @@ interface ToolTipProps { const ViewCategory = React.memo( ({ categoryId, onUpdateColumns, categoryColumns }) => { - const isLoading = useContext(TimelineContext); + const { isLoading } = useContext(TimelineContext); return ( {!isLoading ? ( @@ -142,48 +117,33 @@ export const FieldName = React.memo<{ fieldId: string; highlight?: string; onUpdateColumns: OnUpdateColumns; -}>(({ categoryId, categoryColumns, fieldId, highlight = '', onUpdateColumns }) => ( - - - - - - - - - {categoryColumns.length > 0 && ( - - - - )} - - - } - render={() => ( - - +}>(({ fieldId, highlight = '' }) => { + const [showTopN, setShowTopN] = useState(false); + const toggleTopN = useCallback(() => { + setShowTopN(!showTopN); + }, [setShowTopN, showTopN]); + + const hoverContent = useMemo( + () => ( + + ), + [fieldId, showTopN, toggleTopN] + ); + + const render = useCallback( + () => ( + + {fieldId} - - - )} - /> -)); + + + ), + [fieldId, highlight] + ); + + return ; +}); FieldName.displayName = 'FieldName'; diff --git a/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.tsx b/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.tsx index 98a1acf471629..abde602c1bdac 100644 --- a/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/formatted_bytes/index.tsx @@ -7,7 +7,7 @@ import React from 'react'; import numeral from '@elastic/numeral'; -import { DEFAULT_BYTES_FORMAT } from '../../../common/constants'; +import { DEFAULT_BYTES_FORMAT } from '../../../../../../plugins/siem/common/constants'; import { useUiSetting$ } from '../../lib/kibana'; type Bytes = string | number; diff --git a/x-pack/legacy/plugins/siem/public/components/header_page/title.tsx b/x-pack/legacy/plugins/siem/public/components/header_page/title.tsx index a1f3cfd857148..59039ddd6a23b 100644 --- a/x-pack/legacy/plugins/siem/public/components/header_page/title.tsx +++ b/x-pack/legacy/plugins/siem/public/components/header_page/title.tsx @@ -51,7 +51,9 @@ const TitleComponent: React.FC = ({ draggableArguments, title, badgeOptio tooltipPosition="bottom" /> ) : ( - {badgeOptions.text} + + {badgeOptions.text} + )} )} diff --git a/x-pack/legacy/plugins/siem/public/components/header_section/__snapshots__/index.test.tsx.snap b/x-pack/legacy/plugins/siem/public/components/header_section/__snapshots__/index.test.tsx.snap index d4c3763f51460..53b41e2240de2 100644 --- a/x-pack/legacy/plugins/siem/public/components/header_section/__snapshots__/index.test.tsx.snap +++ b/x-pack/legacy/plugins/siem/public/components/header_section/__snapshots__/index.test.tsx.snap @@ -11,13 +11,18 @@ exports[`HeaderSection it renders 1`] = ` responsive={false} > - +

Test title

+
diff --git a/x-pack/legacy/plugins/siem/public/components/header_section/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/header_section/index.test.tsx index bc4692b6fe0c5..e61b39691203c 100644 --- a/x-pack/legacy/plugins/siem/public/components/header_section/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/header_section/index.test.tsx @@ -48,7 +48,7 @@ describe('HeaderSection', () => { ).toBe(true); }); - test('it DOES NOT render the subtitle when not provided', () => { + test('renders the subtitle when not provided (to prevent layout thrash)', () => { const wrapper = mount( @@ -60,7 +60,7 @@ describe('HeaderSection', () => { .find('[data-test-subj="header-section-subtitle"]') .first() .exists() - ).toBe(false); + ).toBe(true); }); test('it renders supplements when children provided', () => { diff --git a/x-pack/legacy/plugins/siem/public/components/header_section/index.tsx b/x-pack/legacy/plugins/siem/public/components/header_section/index.tsx index 3153e785a8a32..43245121dd393 100644 --- a/x-pack/legacy/plugins/siem/public/components/header_section/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/header_section/index.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiFlexGroup, EuiFlexItem, EuiIconTip, EuiTitle } from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiIconTip, EuiTitle, EuiTitleSize } from '@elastic/eui'; import React from 'react'; import styled, { css } from 'styled-components'; @@ -36,6 +36,7 @@ export interface HeaderSectionProps extends HeaderProps { split?: boolean; subtitle?: string | React.ReactNode; title: string | React.ReactNode; + titleSize?: EuiTitleSize; tooltip?: string; } @@ -46,6 +47,7 @@ const HeaderSectionComponent: React.FC = ({ split, subtitle, title, + titleSize = 'm', tooltip, }) => (
@@ -53,7 +55,7 @@ const HeaderSectionComponent: React.FC = ({ - +

{title} {tooltip && ( @@ -65,7 +67,7 @@ const HeaderSectionComponent: React.FC = ({

- {subtitle && } +
{id && ( diff --git a/x-pack/legacy/plugins/siem/public/components/links/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/links/index.test.tsx index d2d1d6569854d..214c0294f2cf4 100644 --- a/x-pack/legacy/plugins/siem/public/components/links/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/links/index.test.tsx @@ -24,6 +24,8 @@ import { ExternalLink, } from '.'; +jest.mock('../../pages/overview/events_by_dataset'); + jest.mock('../../lib/kibana', () => { return { useUiSetting$: jest.fn(), diff --git a/x-pack/legacy/plugins/siem/public/components/links/index.tsx b/x-pack/legacy/plugins/siem/public/components/links/index.tsx index 62a67af6e08b1..45225e31e9ac8 100644 --- a/x-pack/legacy/plugins/siem/public/components/links/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/links/index.tsx @@ -6,9 +6,10 @@ import { EuiLink, EuiToolTip, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React, { useMemo } from 'react'; - import { isNil } from 'lodash/fp'; import styled from 'styled-components'; + +import { IP_REPUTATION_LINKS_SETTING } from '../../../../../../plugins/siem/common/constants'; import { DefaultFieldRendererOverflow, DEFAULT_MORE_MAX_HEIGHT, @@ -22,7 +23,6 @@ import { } from '../link_to'; import { FlowTarget, FlowTargetSourceDest } from '../../graphql/types'; import { useUiSetting$ } from '../../lib/kibana'; -import { IP_REPUTATION_LINKS_SETTING } from '../../../common/constants'; import { isUrlInvalid } from '../../pages/detection_engine/rules/components/step_about_rule/helpers'; import { ExternalLinkIcon } from '../external_link_icon'; import { navTabs } from '../../pages/home/home_navigations'; diff --git a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/__snapshots__/index.test.tsx.snap b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/__snapshots__/index.test.tsx.snap index 0e518e48e2e88..5aa846d15b684 100644 --- a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/__snapshots__/index.test.tsx.snap +++ b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/__snapshots__/index.test.tsx.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Matrix Histogram Component not initial load it renders no MatrixLoader 1`] = `"
"`; +exports[`Matrix Histogram Component not initial load it renders no MatrixLoader 1`] = `"
"`; -exports[`Matrix Histogram Component on initial load it renders MatrixLoader 1`] = `"
"`; +exports[`Matrix Histogram Component on initial load it renders MatrixLoader 1`] = `"
"`; diff --git a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.test.tsx index db5b1f7f03ee3..3b8a43a0f395a 100644 --- a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.test.tsx @@ -87,6 +87,17 @@ describe('Matrix Histogram Component', () => { }); }); + describe('spacer', () => { + test('it renders a spacer by default', () => { + expect(wrapper.find('[data-test-subj="spacer"]').exists()).toBe(true); + }); + + test('it does NOT render a spacer when showSpacer is false', () => { + wrapper = mount(); + expect(wrapper.find('[data-test-subj="spacer"]').exists()).toBe(false); + }); + }); + describe('not initial load', () => { beforeAll(() => { (useQuery as jest.Mock).mockReturnValue({ diff --git a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.tsx b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.tsx index 12a474009dc5b..3d4eebd68319c 100644 --- a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/index.tsx @@ -37,6 +37,7 @@ import { import { SetQuery } from '../../pages/hosts/navigation/types'; import { QueryTemplateProps } from '../../containers/query_template'; import { setAbsoluteRangeDatePicker } from '../../store/inputs/actions'; +import { InputsModelId } from '../../store/inputs/constants'; import { HistogramType } from '../../graphql/types'; export interface OwnProps extends QueryTemplateProps { @@ -46,9 +47,12 @@ export interface OwnProps extends QueryTemplateProps { hideHistogramIfEmpty?: boolean; histogramType: HistogramType; id: string; + indexToAdd?: string[] | null; legendPosition?: Position; mapping?: MatrixHistogramMappingTypes; + showSpacer?: boolean; setQuery: SetQuery; + setAbsoluteRangeDatePickerTarget?: InputsModelId; showLegend?: boolean; stackByOptions: MatrixHistogramOption[]; subtitle?: string | GetSubTitle; @@ -62,6 +66,7 @@ const HeaderChildrenFlexItem = styled(EuiFlexItem)` margin-left: 24px; `; +// @ts-ignore - the EUI type definitions for Panel do no play nice with styled-components const HistogramPanel = styled(Panel)<{ height?: number }>` display: flex; flex-direction: column; @@ -79,16 +84,20 @@ export const MatrixHistogramComponent: React.FC { @@ -100,7 +109,11 @@ export const MatrixHistogramComponent: React.FC { - dispatchSetAbsoluteRangeDatePicker({ id: 'global', from: min, to: max }); + dispatchSetAbsoluteRangeDatePicker({ + id: setAbsoluteRangeDatePickerTarget, + from: min, + to: max, + }); }, yTickFormatter, showLegend, @@ -122,7 +135,7 @@ export const MatrixHistogramComponent: React.FC) => { setSelectedStackByOption( - stackByOptions?.find(co => co.value === event.target.value) ?? defaultStackByOption + stackByOptions.find(co => co.value === event.target.value) ?? defaultStackByOption ); }, [] @@ -134,6 +147,7 @@ export const MatrixHistogramComponent: React.FC (title != null && typeof title === 'function' ? title(selectedStackByOption) : title), [title, selectedStackByOption] ); - const subtitleWithCounts = useMemo( - () => (subtitle != null && typeof subtitle === 'function' ? subtitle(totalCount) : subtitle), - [subtitle, totalCount] - ); + const subtitleWithCounts = useMemo(() => { + if (isInitialLoading) { + return null; + } + + if (typeof subtitle === 'function') { + return totalCount >= 0 ? subtitle(totalCount) : null; + } + + return subtitle; + }, [isInitialLoading, subtitle, totalCount]); const hideHistogram = useMemo(() => (totalCount <= 0 && hideHistogramIfEmpty ? true : false), [ totalCount, hideHistogramIfEmpty, @@ -155,7 +176,9 @@ export const MatrixHistogramComponent: React.FC getCustomChartData(data, mapping), [data, mapping]); useEffect(() => { - setQuery({ id, inspect, loading, refetch }); + if (!loading && !isInitialLoading) { + setQuery({ id, inspect, loading, refetch }); + } if (isInitialLoading && !!barChartData && data) { setIsInitialLoading(false); @@ -189,59 +212,39 @@ export const MatrixHistogramComponent: React.FC )} + + + + {stackByOptions.length > 1 && ( + + )} + + {headerChildren} + + + {isInitialLoading ? ( - <> - = 0 ? subtitleWithCounts : null)} - > - - - {stackByOptions?.length > 1 && ( - - )} - - {headerChildren} - - - - + ) : ( - <> - = 0 ? subtitleWithCounts : null) - } - > - - - {stackByOptions?.length > 1 && ( - - )} - - {headerChildren} - - - - + )} - + {showSpacer && } ); }; diff --git a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/types.ts b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/types.ts index a435c7be6c890..98437845a3ab7 100644 --- a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/types.ts +++ b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/types.ts @@ -4,9 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ +import { EuiTitleSize } from '@elastic/eui'; import { ScaleType, Position, TickFormatter } from '@elastic/charts'; import { ActionCreator } from 'redux'; -import { ESQuery } from '../../../common/typed_json'; +import { ESQuery } from '../../../../../../plugins/siem/common/typed_json'; import { SetQuery } from '../../pages/hosts/navigation/types'; import { InputsModelId } from '../../store/inputs/constants'; import { HistogramType } from '../../graphql/types'; @@ -34,6 +35,7 @@ export interface MatrixHisrogramConfigs { stackByOptions: MatrixHistogramOption[]; subtitle?: string | GetSubTitle; title: string | GetTitle; + titleSize?: EuiTitleSize; } interface MatrixHistogramBasicProps { @@ -57,14 +59,22 @@ interface MatrixHistogramBasicProps { stackByOptions: MatrixHistogramOption[]; subtitle?: string | GetSubTitle; title?: string | GetTitle; + titleSize?: EuiTitleSize; } export interface MatrixHistogramQueryProps { endDate: number; errorMessage: string; filterQuery?: ESQuery | string | undefined; + setAbsoluteRangeDatePicker?: ActionCreator<{ + id: InputsModelId; + from: number; + to: number; + }>; + setAbsoluteRangeDatePickerTarget?: InputsModelId; stackByField: string; startDate: number; + indexToAdd?: string[] | null; isInspected: boolean; histogramType: HistogramType; } @@ -73,6 +83,7 @@ export interface MatrixHistogramProps extends MatrixHistogramBasicProps { scaleType?: ScaleType; yTickFormatter?: (value: number) => string; showLegend?: boolean; + showSpacer?: boolean; legendPosition?: Position; } diff --git a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/utils.ts b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/utils.ts index ddac615cef50a..d31eb1da15ea1 100644 --- a/x-pack/legacy/plugins/siem/public/components/matrix_histogram/utils.ts +++ b/x-pack/legacy/plugins/siem/public/components/matrix_histogram/utils.ts @@ -69,6 +69,19 @@ export const getBarchartConfigs = ({ customHeight: chartHeight ?? DEFAULT_CHART_HEIGHT, }); +export const defaultLegendColors = [ + '#1EA593', + '#2B70F7', + '#CE0060', + '#38007E', + '#FCA5D3', + '#F37020', + '#E49E29', + '#B0916F', + '#7B000B', + '#34130C', +]; + export const formatToChartDataItem = ([key, value]: [ string, MatrixOverTimeHistogramData[] diff --git a/x-pack/legacy/plugins/siem/public/components/ml/anomaly/use_anomalies_table_data.ts b/x-pack/legacy/plugins/siem/public/components/ml/anomaly/use_anomalies_table_data.ts index c4ca7dc203619..cebfc172ee6ff 100644 --- a/x-pack/legacy/plugins/siem/public/components/ml/anomaly/use_anomalies_table_data.ts +++ b/x-pack/legacy/plugins/siem/public/components/ml/anomaly/use_anomalies_table_data.ts @@ -5,6 +5,8 @@ */ import { useState, useEffect } from 'react'; + +import { DEFAULT_ANOMALY_SCORE } from '../../../../../../../plugins/siem/common/constants'; import { anomaliesTableData } from '../api/anomalies_table_data'; import { InfluencerInput, Anomalies, CriteriaFields } from '../types'; import { hasMlUserPermissions } from '../permissions/has_ml_user_permissions'; @@ -14,7 +16,6 @@ import { useStateToaster, errorToToaster } from '../../toasters'; import * as i18n from './translations'; import { useTimeZone, useUiSetting$ } from '../../../lib/kibana'; -import { DEFAULT_ANOMALY_SCORE } from '../../../../common/constants'; interface Args { influencers?: InfluencerInput[]; diff --git a/x-pack/legacy/plugins/siem/public/components/ml/score/create_description_list.tsx b/x-pack/legacy/plugins/siem/public/components/ml/score/create_description_list.tsx index e0f3ea162ee78..24f203a3682d5 100644 --- a/x-pack/legacy/plugins/siem/public/components/ml/score/create_description_list.tsx +++ b/x-pack/legacy/plugins/siem/public/components/ml/score/create_description_list.tsx @@ -7,11 +7,12 @@ import { EuiText, EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiLink } from '@elastic/eui'; import React from 'react'; import styled from 'styled-components'; + +import { DescriptionList } from '../../../../../../../plugins/siem/common/utility_types'; import { Anomaly, NarrowDateRange } from '../types'; import { getScoreString } from './score_health'; import { PreferenceFormattedDate } from '../../formatted_date'; import { createInfluencers } from './../influencers/create_influencers'; -import { DescriptionList } from '../../../../common/utility_types'; import * as i18n from './translations'; import { createExplorerLink } from '../links/create_explorer_link'; diff --git a/x-pack/legacy/plugins/siem/public/components/ml_popover/hooks/use_siem_jobs.tsx b/x-pack/legacy/plugins/siem/public/components/ml_popover/hooks/use_siem_jobs.tsx index 9a82859066f54..bc488ee00988b 100644 --- a/x-pack/legacy/plugins/siem/public/components/ml_popover/hooks/use_siem_jobs.tsx +++ b/x-pack/legacy/plugins/siem/public/components/ml_popover/hooks/use_siem_jobs.tsx @@ -6,12 +6,12 @@ import { useEffect, useState } from 'react'; +import { DEFAULT_INDEX_KEY } from '../../../../../../../plugins/siem/common/constants'; import { checkRecognizer, getJobsSummary, getModules } from '../api'; import { SiemJob } from '../types'; import { hasMlUserPermissions } from '../../ml/permissions/has_ml_user_permissions'; import { errorToToaster, useStateToaster } from '../../toasters'; import { useUiSetting$ } from '../../../lib/kibana'; -import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; import * as i18n from './translations'; import { createSiemJobs } from './use_siem_jobs_helpers'; diff --git a/x-pack/legacy/plugins/siem/public/components/ml_popover/jobs_table/job_switch.tsx b/x-pack/legacy/plugins/siem/public/components/ml_popover/jobs_table/job_switch.tsx index a0e0c70d2f204..a0343608dc67a 100644 --- a/x-pack/legacy/plugins/siem/public/components/ml_popover/jobs_table/job_switch.tsx +++ b/x-pack/legacy/plugins/siem/public/components/ml_popover/jobs_table/job_switch.tsx @@ -7,12 +7,12 @@ import styled from 'styled-components'; import React, { useState, useCallback } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner, EuiSwitch } from '@elastic/eui'; -import { SiemJob } from '../types'; import { isJobLoading, isJobFailed, isJobStarted, -} from '../../../../common/detection_engine/ml_helpers'; +} from '../../../../../../../plugins/siem/common/detection_engine/ml_helpers'; +import { SiemJob } from '../types'; const StaticSwitch = styled(EuiSwitch)` .euiSwitch__thumb, diff --git a/x-pack/legacy/plugins/siem/public/components/navigation/breadcrumbs/index.ts b/x-pack/legacy/plugins/siem/public/components/navigation/breadcrumbs/index.ts index 155f63145ca95..5407eba8b5b29 100644 --- a/x-pack/legacy/plugins/siem/public/components/navigation/breadcrumbs/index.ts +++ b/x-pack/legacy/plugins/siem/public/components/navigation/breadcrumbs/index.ts @@ -7,7 +7,7 @@ import { getOr, omit } from 'lodash/fp'; import { ChromeBreadcrumb } from '../../../../../../../../src/core/public'; -import { APP_NAME } from '../../../../common/constants'; +import { APP_NAME } from '../../../../../../../plugins/siem/common/constants'; import { StartServices } from '../../../plugin'; import { getBreadcrumbs as getHostDetailsBreadcrumbs } from '../../../pages/hosts/details/utils'; import { getBreadcrumbs as getIPDetailsBreadcrumbs } from '../../../pages/network/ip_details'; diff --git a/x-pack/legacy/plugins/siem/public/components/news_feed/helpers.test.ts b/x-pack/legacy/plugins/siem/public/components/news_feed/helpers.test.ts index e7cd03d098da8..686ec4e86e785 100644 --- a/x-pack/legacy/plugins/siem/public/components/news_feed/helpers.test.ts +++ b/x-pack/legacy/plugins/siem/public/components/news_feed/helpers.test.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { NEWS_FEED_URL_SETTING_DEFAULT } from '../../../../../../plugins/siem/common/constants'; import { KibanaServices } from '../../lib/kibana'; -import { NEWS_FEED_URL_SETTING_DEFAULT } from '../../../common/constants'; import { rawNewsApiResponse } from '../../mock/news'; import { rawNewsJSON } from '../../mock/raw_news'; diff --git a/x-pack/legacy/plugins/siem/public/components/notes/note_card/note_card_body.tsx b/x-pack/legacy/plugins/siem/public/components/notes/note_card/note_card_body.tsx index 11761c8fd39b0..4463f8d4ff602 100644 --- a/x-pack/legacy/plugins/siem/public/components/notes/note_card/note_card_body.tsx +++ b/x-pack/legacy/plugins/siem/public/components/notes/note_card/note_card_body.tsx @@ -5,7 +5,7 @@ */ import { EuiPanel, EuiToolTip } from '@elastic/eui'; -import React from 'react'; +import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; import { WithCopyToClipboard } from '../../../lib/clipboard/with_copy_to_clipboard'; @@ -19,33 +19,23 @@ const BodyContainer = styled(EuiPanel)` BodyContainer.displayName = 'BodyContainer'; -const HoverActionsContainer = styled(EuiPanel)` - align-items: center; - display: flex; - flex-direction: row; - height: 25px; - justify-content: center; - left: 5px; - position: absolute; - top: -5px; - width: 30px; -`; - -HoverActionsContainer.displayName = 'HoverActionsContainer'; - -export const NoteCardBody = React.memo<{ rawNote: string }>(({ rawNote }) => ( - - - - - - - } - render={() => } - /> - -)); +export const NoteCardBody = React.memo<{ rawNote: string }>(({ rawNote }) => { + const hoverContent = useMemo( + () => ( + + + + ), + [rawNote] + ); + + const render = useCallback(() => , [rawNote]); + + return ( + + + + ); +}); NoteCardBody.displayName = 'NoteCardBody'; diff --git a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/__snapshots__/index.test.tsx.snap b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/__snapshots__/index.test.tsx.snap index 42ef4e5404faa..ef02311c0629e 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/__snapshots__/index.test.tsx.snap +++ b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/__snapshots__/index.test.tsx.snap @@ -3,22 +3,36 @@ exports[`AddFilterToGlobalSearchBar Component Rendering 1`] = ` - - + + + + } render={[Function]} /> diff --git a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/helpers.test.tsx b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/helpers.test.tsx index 7e5e53f575be8..5c920d923d9a4 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/helpers.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/helpers.test.tsx @@ -24,6 +24,22 @@ describe('helpers', () => { }); }); + test('returns a negated filter when `negate` is true', () => { + const filter = createFilter('host.name', 'siem-xavier', true); + expect(filter).toEqual({ + meta: { + alias: null, + disabled: false, + key: 'host.name', + negate: true, // <-- filter is negated + params: { query: 'siem-xavier' }, + type: 'phrase', + value: 'siem-xavier', + }, + query: { match: { 'host.name': { query: 'siem-xavier', type: 'phrase' } } }, + }); + }); + test('return valid exists filter when valid key and null value are provided', () => { const filter = createFilter('host.name', null); expect(filter).toEqual({ diff --git a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/helpers.ts b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/helpers.ts index bafe033368c83..d88bc2bf3b7e6 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/helpers.ts @@ -6,13 +6,17 @@ import { Filter } from '../../../../../../../../src/plugins/data/public'; -export const createFilter = (key: string, value: string[] | string | null | undefined): Filter => { +export const createFilter = ( + key: string, + value: string[] | string | null | undefined, + negate: boolean = false +): Filter => { const queryValue = value != null ? (Array.isArray(value) ? value[0] : value) : null; return queryValue != null ? { meta: { alias: null, - negate: false, + negate, disabled: false, type: 'phrase', key, diff --git a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/index.tsx index 160cd020796db..127eb3bae0284 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/index.tsx @@ -4,9 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiIcon, EuiPanel, EuiToolTip } from '@elastic/eui'; +import { EuiButtonIcon, EuiToolTip } from '@elastic/eui'; import React, { useCallback } from 'react'; -import styled from 'styled-components'; import { Filter } from '../../../../../../../../src/plugins/data/public'; import { WithHoverActions } from '../../with_hover_actions'; @@ -26,21 +25,52 @@ export const AddFilterToGlobalSearchBar = React.memo( ({ children, filter, onFilterAdded }) => { const { filterManager } = useKibana().services.data.query; - const addToKql = useCallback(() => { + const filterForValue = useCallback(() => { filterManager.addFilters(filter); + if (onFilterAdded != null) { onFilterAdded(); } - }, [filter, filterManager, onFilterAdded]); + }, [filterManager, filter, onFilterAdded]); + + const filterOutValue = useCallback(() => { + filterManager.addFilters({ + ...filter, + meta: { + ...filter.meta, + negate: true, + }, + }); + + if (onFilterAdded != null) { + onFilterAdded(); + } + }, [filterManager, filter, onFilterAdded]); return ( +
- + + + + + - +
} render={() => children} /> @@ -49,16 +79,3 @@ export const AddFilterToGlobalSearchBar = React.memo( ); AddFilterToGlobalSearchBar.displayName = 'AddFilterToGlobalSearchBar'; - -export const HoverActionsContainer = styled(EuiPanel)` - align-items: center; - display: flex; - flex-direction: row; - height: 34px; - justify-content: center; - left: 5px; - position: absolute; - top: -10px; - width: 34px; - cursor: pointer; -`; diff --git a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/translations.ts b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/translations.ts index 81772527e59db..f192c5c26fa49 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/translations.ts +++ b/x-pack/legacy/plugins/siem/public/components/page/add_filter_to_global_search_bar/translations.ts @@ -12,3 +12,10 @@ export const FILTER_FOR_VALUE = i18n.translate( defaultMessage: 'Filter for value', } ); + +export const FILTER_OUT_VALUE = i18n.translate( + 'xpack.siem.add_filter_to_global_search_bar.filterOutValueHoverAction', + { + defaultMessage: 'Filter out value', + } +); diff --git a/x-pack/legacy/plugins/siem/public/components/page/hosts/host_overview/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/hosts/host_overview/index.tsx index 4d0e6a737d303..a0ca5f855237c 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/hosts/host_overview/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/hosts/host_overview/index.tsx @@ -10,8 +10,8 @@ import lightTheme from '@elastic/eui/dist/eui_theme_light.json'; import { getOr } from 'lodash/fp'; import React from 'react'; -import { DEFAULT_DARK_MODE } from '../../../../../common/constants'; -import { DescriptionList } from '../../../../../common/utility_types'; +import { DEFAULT_DARK_MODE } from '../../../../../../../../plugins/siem/common/constants'; +import { DescriptionList } from '../../../../../../../../plugins/siem/common/utility_types'; import { useUiSetting$ } from '../../../../lib/kibana'; import { getEmptyTagValue } from '../../../empty_value'; import { DefaultFieldRenderer, hostIdRenderer } from '../../../field_renderers/field_renderers'; diff --git a/x-pack/legacy/plugins/siem/public/components/page/hosts/hosts_table/columns.tsx b/x-pack/legacy/plugins/siem/public/components/page/hosts/hosts_table/columns.tsx index 8d490d2c152d9..6bd82f3192f9b 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/hosts/hosts_table/columns.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/hosts/hosts_table/columns.tsx @@ -46,9 +46,7 @@ export const getHostsColumns = (): HostsTableColumns => [ ) : ( - - - + ) } /> diff --git a/x-pack/legacy/plugins/siem/public/components/page/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/index.tsx index ef6a19f4b7448..3a36a2dce476b 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/index.tsx @@ -17,7 +17,7 @@ export const AppGlobalStyle = createGlobalStyle` position: static; } /* end of dirty hack to fix draggables with tooltip on FF */ - + div.app-wrapper { background-color: rgba(0,0,0,0); } @@ -28,12 +28,13 @@ export const AppGlobalStyle = createGlobalStyle` .euiPopover__panel.euiPopover__panel-isOpen { z-index: 9900 !important; + min-width: 24px; } .euiToolTip { z-index: 9950 !important; } - /* + /* overrides the default styling of euiComboBoxOptionsList because it's implemented as a popover, so it's not selectable as a child of the styled component */ @@ -45,6 +46,17 @@ export const AppGlobalStyle = createGlobalStyle` .euiPanel-loading-hide-border { border: none; } + + /* hide open popovers when a modal is being displayed to prevent them from covering the modal */ + body.euiBody-hasOverlayMask .euiPopover__panel-isOpen { + visibility: hidden !important; + } + + /* ensure elastic charts tooltips appear above open euiPopovers */ + .echTooltip { + z-index: 9950; + } + `; export const DescriptionListStyled = styled(EuiDescriptionList)` diff --git a/x-pack/legacy/plugins/siem/public/components/page/manage_query.tsx b/x-pack/legacy/plugins/siem/public/components/page/manage_query.tsx index 138c38c02065b..3b723c66f5af5 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/manage_query.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/manage_query.tsx @@ -42,6 +42,6 @@ export function manageQuery(WrappedComponent: React.ComponentClass | React return ; } } - ManageQuery.displayName = `ManageQuery (${WrappedComponent.displayName || 'Unknown'})`; + ManageQuery.displayName = `ManageQuery (${WrappedComponent?.displayName ?? 'Unknown'})`; return ManageQuery; } diff --git a/x-pack/legacy/plugins/siem/public/components/page/network/ip_overview/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/network/ip_overview/index.tsx index 56b59ca97156f..a652fef5508fc 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/network/ip_overview/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/network/ip_overview/index.tsx @@ -9,8 +9,8 @@ import darkTheme from '@elastic/eui/dist/eui_theme_dark.json'; import lightTheme from '@elastic/eui/dist/eui_theme_light.json'; import React from 'react'; -import { DEFAULT_DARK_MODE } from '../../../../../common/constants'; -import { DescriptionList } from '../../../../../common/utility_types'; +import { DEFAULT_DARK_MODE } from '../../../../../../../../plugins/siem/common/constants'; +import { DescriptionList } from '../../../../../../../../plugins/siem/common/utility_types'; import { useUiSetting$ } from '../../../../lib/kibana'; import { FlowTarget, IpOverviewData, Overview } from '../../../../graphql/types'; import { networkModel } from '../../../../store'; diff --git a/x-pack/legacy/plugins/siem/public/components/page/overview/overview_host/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/overview/overview_host/index.tsx index 52c142ceff480..b43efbbde51b3 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/overview/overview_host/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/overview/overview_host/index.tsx @@ -10,8 +10,8 @@ import numeral from '@elastic/numeral'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { useMemo } from 'react'; -import { DEFAULT_NUMBER_FORMAT } from '../../../../../common/constants'; -import { ESQuery } from '../../../../../common/typed_json'; +import { DEFAULT_NUMBER_FORMAT } from '../../../../../../../../plugins/siem/common/constants'; +import { ESQuery } from '../../../../../../../../plugins/siem/common/typed_json'; import { ID as OverviewHostQueryId, OverviewHostQuery, diff --git a/x-pack/legacy/plugins/siem/public/components/page/overview/overview_network/index.tsx b/x-pack/legacy/plugins/siem/public/components/page/overview/overview_network/index.tsx index d649a0dd9e923..af50fa88e5fe8 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/overview/overview_network/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/overview/overview_network/index.tsx @@ -10,8 +10,8 @@ import numeral from '@elastic/numeral'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { useMemo } from 'react'; -import { DEFAULT_NUMBER_FORMAT } from '../../../../../common/constants'; -import { ESQuery } from '../../../../../common/typed_json'; +import { DEFAULT_NUMBER_FORMAT } from '../../../../../../../../plugins/siem/common/constants'; +import { ESQuery } from '../../../../../../../../plugins/siem/common/typed_json'; import { HeaderSection } from '../../../header_section'; import { useUiSetting$ } from '../../../../lib/kibana'; import { manageQuery } from '../../../page/manage_query'; diff --git a/x-pack/legacy/plugins/siem/public/components/page/overview/stat_value.tsx b/x-pack/legacy/plugins/siem/public/components/page/overview/stat_value.tsx index 7615001eec9da..cada0a9aff939 100644 --- a/x-pack/legacy/plugins/siem/public/components/page/overview/stat_value.tsx +++ b/x-pack/legacy/plugins/siem/public/components/page/overview/stat_value.tsx @@ -9,7 +9,7 @@ import numeral from '@elastic/numeral'; import React, { useEffect, useState } from 'react'; import styled from 'styled-components'; -import { DEFAULT_NUMBER_FORMAT } from '../../../../common/constants'; +import { DEFAULT_NUMBER_FORMAT } from '../../../../../../../plugins/siem/common/constants'; import { useUiSetting$ } from '../../../lib/kibana'; const ProgressContainer = styled.div` diff --git a/x-pack/legacy/plugins/siem/public/components/paginated_table/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/paginated_table/index.test.tsx index 947bdee6a5cd2..2f743c3387209 100644 --- a/x-pack/legacy/plugins/siem/public/components/paginated_table/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/paginated_table/index.test.tsx @@ -7,13 +7,13 @@ import { mount, shallow } from 'enzyme'; import React from 'react'; +import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../plugins/siem/common/constants'; import { Direction } from '../../graphql/types'; import { BasicTableProps, PaginatedTable } from './index'; import { getHostsColumns, mockData, rowItems, sortedHosts } from './index.mock'; import { ThemeProvider } from 'styled-components'; import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; -import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../common/constants'; jest.mock('react', () => { const r = jest.requireActual('react'); diff --git a/x-pack/legacy/plugins/siem/public/components/paginated_table/index.tsx b/x-pack/legacy/plugins/siem/public/components/paginated_table/index.tsx index 5cd200cbb41b7..e481fe7245201 100644 --- a/x-pack/legacy/plugins/siem/public/components/paginated_table/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/paginated_table/index.tsx @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + import { EuiBasicTable, EuiBasicTableProps, @@ -21,6 +22,7 @@ import { noop } from 'lodash/fp'; import React, { FC, memo, useState, useEffect, ComponentType } from 'react'; import styled from 'styled-components'; +import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../../../../plugins/siem/common/constants'; import { AuthTableColumns } from '../page/hosts/authentications_table'; import { HostsTableColumns } from '../page/hosts/hosts_table'; import { NetworkDnsColumns } from '../page/network/network_dns_table/columns'; @@ -39,7 +41,6 @@ import { UsersColumns } from '../page/network/users_table/columns'; import { HeaderSection } from '../header_section'; import { Loader } from '../loader'; import { useStateToaster } from '../toasters'; -import { DEFAULT_MAX_TABLE_QUERY_SIZE } from '../../../common/constants'; import * as i18n from './translations'; import { Panel } from '../panel'; @@ -246,21 +247,16 @@ const PaginatedTableComponent: FC = ({ ) : ( <> - { - // @ts-ignore avoid some type mismatches - } = ({ export const PaginatedTable = memo(PaginatedTableComponent); type BasicTableType = ComponentType>; // eslint-disable-line @typescript-eslint/no-explicit-any -const BasicTable: typeof EuiBasicTable & { displayName: string } = styled( - EuiBasicTable as BasicTableType -)` +const BasicTable = styled(EuiBasicTable as BasicTableType)` tbody { th, td { diff --git a/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx index 870d0b40d8cd4..49afc8d5ef68b 100644 --- a/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/query_bar/index.test.tsx @@ -7,9 +7,9 @@ import { mount } from 'enzyme'; import React from 'react'; +import { DEFAULT_FROM, DEFAULT_TO } from '../../../../../../plugins/siem/common/constants'; import { TestProviders, mockIndexPattern } from '../../mock'; import { createKibanaCoreStartMock } from '../../mock/kibana_core'; -import { DEFAULT_FROM, DEFAULT_TO } from '../../../common/constants'; import { FilterManager, SearchBar } from '../../../../../../../src/plugins/data/public'; import { QueryBar, QueryBarComponentProps } from '.'; import { createKibanaContextProviderMock } from '../../mock/kibana_react'; diff --git a/x-pack/legacy/plugins/siem/public/components/source_destination/source_destination_ip.tsx b/x-pack/legacy/plugins/siem/public/components/source_destination/source_destination_ip.tsx index b8192cce11e5a..62f01dfc020f5 100644 --- a/x-pack/legacy/plugins/siem/public/components/source_destination/source_destination_ip.tsx +++ b/x-pack/legacy/plugins/siem/public/components/source_destination/source_destination_ip.tsx @@ -171,7 +171,7 @@ export const SourceDestinationIp = React.memo( return isIpFieldPopulated({ destinationIp, sourceIp, type }) || hasPorts({ destinationPort, sourcePort, type }) ? ( - + (({ header, onColumnRemoved, sort }) => { - const isLoading = useTimelineContext(); + const { isLoading } = useTimelineContext(); return ( <> {sort.columnId === header.id && isLoading ? ( diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/header_content.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/header_content.tsx index 84781e6a24300..0a69cef618570 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/header_content.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/column_headers/header/header_content.tsx @@ -32,7 +32,7 @@ const HeaderContentComponent: React.FC = ({ onClick, sort, }) => { - const isLoading = useTimelineContext(); + const { isLoading } = useTimelineContext(); return ( diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_row_renderer.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_row_renderer.test.tsx index 5f59915eac418..417a078a08150 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_row_renderer.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/auditd/generic_row_renderer.test.tsx @@ -19,6 +19,8 @@ import { createGenericFileRowRenderer, } from './generic_row_renderer'; +jest.mock('../../../../../pages/overview/events_by_dataset'); + describe('GenericRowRenderer', () => { const mount = useMountAppended(); diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/suricata/suricata_signature.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/suricata/suricata_signature.tsx index 9ccd1fb7a0519..24c52f3372d62 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/suricata/suricata_signature.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/suricata/suricata_signature.tsx @@ -44,7 +44,7 @@ export const Tokens = React.memo<{ tokens: string[] }>(({ tokens }) => ( <> {tokens.map(token => ( - + {token} @@ -81,7 +81,7 @@ export const DraggableSignatureId = React.memo<{ id: string; signatureId: number data-test-subj="signature-id-tooltip" content={SURICATA_SIGNATURE_ID_FIELD_NAME} > - + {signatureId} diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_details.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_details.tsx index e1524c8e5aecb..2ad3eb4681454 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_details.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_details.tsx @@ -119,7 +119,7 @@ export const SystemGenericLine = React.memo( - + diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_file_details.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_file_details.tsx index c47d9603cbea2..ef7c3b3ccf859 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_file_details.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_file_details.tsx @@ -193,7 +193,7 @@ export const SystemGenericFileLine = React.memo( - + diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_row_renderer.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_row_renderer.test.tsx index abe77a63f4a27..2f5fa76855f2b 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_row_renderer.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/system/generic_row_renderer.test.tsx @@ -48,6 +48,8 @@ import { } from './generic_row_renderer'; import * as i18n from './translations'; +jest.mock('../../../../../pages/overview/events_by_dataset'); + describe('GenericRowRenderer', () => { const mount = useMountAppended(); diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/zeek/zeek_signature.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/zeek/zeek_signature.tsx index f13a236e8ec36..39c21c4ffa33b 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/zeek/zeek_signature.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/body/renderers/zeek/zeek_signature.tsx @@ -92,7 +92,7 @@ export const DraggableZeekElement = React.memo<{ ) : ( - + {stringRenderer(value)} diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/data_providers/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/data_providers/index.tsx index 525cc8e301d11..f369b961807af 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/data_providers/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/data_providers/index.tsx @@ -109,7 +109,7 @@ export const DataProviders = React.memo( data-test-subj="dataProviders" > - {isLoading => ( + {({ isLoading }) => ( {dataProviders != null && dataProviders.length ? ( ( ({ deleteProvider, field, isEnabled, isExcluded, operator, providerId, togglePopover, val }) => { - const deleteFilter: React.MouseEventHandler = ( - event: React.MouseEvent - ) => { - // Make sure it doesn't also trigger the onclick for the whole badge - if (event.stopPropagation) { - event.stopPropagation(); - } - deleteProvider(); - }; - const classes = classNames('globalFilterItem', { - 'globalFilterItem-isDisabled': !isEnabled, - 'globalFilterItem-isExcluded': isExcluded, - }); - const formattedValue = isString(val) && val === '' ? getEmptyString() : val; - const prefix = isExcluded ? {i18n.NOT} : null; - const title = `${field}: "${formattedValue}"`; - - return ( - - {prefix} - {operator !== EXISTS_OPERATOR ? ( - <> - {`${field}: `} - {`"${formattedValue}"`} - - ) : ( - - {field} {i18n.EXISTS_LABEL} - - )} - + const deleteFilter: React.MouseEventHandler = useCallback( + (event: React.MouseEvent) => { + // Make sure it doesn't also trigger the onclick for the whole badge + if (event.stopPropagation) { + event.stopPropagation(); + } + deleteProvider(); + }, + [deleteProvider] + ); + + const classes = useMemo( + () => + classNames('globalFilterItem', { + 'globalFilterItem-isDisabled': !isEnabled, + 'globalFilterItem-isExcluded': isExcluded, + }), + [isEnabled, isExcluded] + ); + + const formattedValue = useMemo(() => (isString(val) && val === '' ? getEmptyString() : val), [ + val, + ]); + + const prefix = useMemo(() => (isExcluded ? {i18n.NOT} : null), [isExcluded]); + + const title = useMemo(() => `${field}: "${formattedValue}"`, [field, formattedValue]); + + const hoverContent = useMemo( + () => ( + + ), + [field, val] ); + + const badge = useCallback( + () => ( + + {prefix} + {operator !== EXISTS_OPERATOR ? ( + <> + {`${field}: `} + {`"${formattedValue}"`} + + ) : ( + + {field} {i18n.EXISTS_LABEL} + + )} + + ), + [ + providerId, + field, + val, + classes, + title, + deleteFilter, + togglePopover, + formattedValue, + closeButtonProps, + prefix, + operator, + ] + ); + + return ; } ); diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/data_providers/provider_item_badge.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/data_providers/provider_item_badge.tsx index 79f9c32a176f5..2cc19537d6a63 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/data_providers/provider_item_badge.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/data_providers/provider_item_badge.tsx @@ -71,7 +71,7 @@ export const ProviderItemBadge = React.memo( return ( - {isLoading => ( + {({ isLoading }) => ( { - const mockTimelineContext: boolean = true; + const isLoading: boolean = true; const mount = useMountAppended(); + const filterManager = new FilterManager(mockUiSettingsForFilterManager); describe('rendering', () => { test('renders correctly against snapshot', () => { @@ -96,7 +101,7 @@ describe('Providers', () => { const mockOnDataProviderRemoved = jest.fn(); const wrapper = mount( - + { const mockOnDataProviderRemoved = jest.fn(); const wrapper = mount( - + { const mockOnToggleDataProviderEnabled = jest.fn(); const wrapper = mount( - + { const wrapper = mount( - + { const wrapper = mount( - + { const wrapper = mount( - + { const wrapper = mount( - + { @@ -26,6 +30,7 @@ describe('Header', () => { { { = ({ id, indexPattern, dataProviders, + filterManager, onChangeDataProviderKqlQuery, onChangeDroppableAndProvider, onDataProviderEdited, @@ -77,6 +79,7 @@ const TimelineHeaderComponent: React.FC = ({ /> @@ -90,6 +93,7 @@ export const TimelineHeader = React.memo( prevProps.id === nextProps.id && deepEqual(prevProps.indexPattern, nextProps.indexPattern) && deepEqual(prevProps.dataProviders, nextProps.dataProviders) && + prevProps.filterManager === nextProps.filterManager && prevProps.onChangeDataProviderKqlQuery === nextProps.onChangeDataProviderKqlQuery && prevProps.onChangeDroppableAndProvider === nextProps.onChangeDroppableAndProvider && prevProps.onDataProviderEdited === nextProps.onDataProviderEdited && diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.test.tsx index b978ef3d478d8..a49f6cc930abd 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.test.tsx @@ -7,16 +7,20 @@ import { mount } from 'enzyme'; import React from 'react'; -import { DEFAULT_FROM, DEFAULT_TO } from '../../../../common/constants'; +import { DEFAULT_FROM, DEFAULT_TO } from '../../../../../../../plugins/siem/common/constants'; import { mockBrowserFields } from '../../../containers/source/mock'; import { convertKueryToElasticSearchQuery } from '../../../lib/keury'; import { mockIndexPattern, TestProviders } from '../../../mock'; +import { createKibanaCoreStartMock } from '../../../mock/kibana_core'; import { QueryBar } from '../../query_bar'; +import { FilterManager } from '../../../../../../../../src/plugins/data/public'; import { mockDataProviders } from '../data_providers/mock/mock_data_providers'; import { buildGlobalQuery } from '../helpers'; import { QueryBarTimeline, QueryBarTimelineComponentProps, getDataProviderFilter } from './index'; +const mockUiSettingsForFilterManager = createKibanaCoreStartMock().uiSettings; + jest.mock('../../../lib/kibana'); describe('Timeline QueryBar ', () => { @@ -58,6 +62,7 @@ describe('Timeline QueryBar ', () => { browserFields={mockBrowserFields} dataProviders={mockDataProviders} filters={[]} + filterManager={new FilterManager(mockUiSettingsForFilterManager)} filterQuery={{ expression: 'here: query', kind: 'kuery' }} filterQueryDraft={{ expression: 'here: query', kind: 'kuery' }} from={0} @@ -99,6 +104,7 @@ describe('Timeline QueryBar ', () => { browserFields={mockBrowserFields} dataProviders={mockDataProviders} filters={[]} + filterManager={new FilterManager(mockUiSettingsForFilterManager)} filterQuery={{ expression: 'here: query', kind: 'kuery' }} filterQueryDraft={{ expression: 'here: query', kind: 'kuery' }} from={0} @@ -145,6 +151,7 @@ describe('Timeline QueryBar ', () => { browserFields={mockBrowserFields} dataProviders={mockDataProviders} filters={[]} + filterManager={new FilterManager(mockUiSettingsForFilterManager)} filterQuery={{ expression: 'here: query', kind: 'kuery' }} filterQueryDraft={{ expression: 'here: query', kind: 'kuery' }} from={0} @@ -189,6 +196,7 @@ describe('Timeline QueryBar ', () => { browserFields={mockBrowserFields} dataProviders={mockDataProviders} filters={[]} + filterManager={new FilterManager(mockUiSettingsForFilterManager)} filterQuery={{ expression: 'here: query', kind: 'kuery' }} filterQueryDraft={{ expression: 'here: query', kind: 'kuery' }} from={0} @@ -235,6 +243,7 @@ describe('Timeline QueryBar ', () => { browserFields={mockBrowserFields} dataProviders={mockDataProviders} filters={[]} + filterManager={new FilterManager(mockUiSettingsForFilterManager)} filterQuery={{ expression: 'here: query', kind: 'kuery' }} filterQueryDraft={{ expression: 'here: query', kind: 'kuery' }} from={0} @@ -279,6 +288,7 @@ describe('Timeline QueryBar ', () => { browserFields={mockBrowserFields} dataProviders={mockDataProviders} filters={[]} + filterManager={new FilterManager(mockUiSettingsForFilterManager)} filterQuery={{ expression: 'here: query', kind: 'kuery' }} filterQueryDraft={{ expression: 'here: query', kind: 'kuery' }} from={0} diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.tsx index 7f662cdb2f1b4..f53f7bb56e2f4 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/query_bar/index.tsx @@ -21,7 +21,6 @@ import { import { BrowserFields } from '../../../containers/source'; import { convertKueryToElasticSearchQuery } from '../../../lib/keury'; -import { useKibana } from '../../../lib/kibana'; import { KueryFilterQuery, KueryFilterQueryKind } from '../../../store'; import { KqlMode } from '../../../store/timeline/model'; import { useSavedQueryServices } from '../../../utils/saved_query_services'; @@ -35,6 +34,7 @@ export interface QueryBarTimelineComponentProps { browserFields: BrowserFields; dataProviders: DataProvider[]; filters: Filter[]; + filterManager: FilterManager; filterQuery: KueryFilterQuery; filterQueryDraft: KueryFilterQuery; from: number; @@ -61,6 +61,7 @@ export const QueryBarTimeline = memo( browserFields, dataProviders, filters, + filterManager, filterQuery, filterQueryDraft, from, @@ -94,9 +95,6 @@ export const QueryBarTimeline = memo( const [dataProvidersDsl, setDataProvidersDsl] = useState( convertKueryToElasticSearchQuery(buildGlobalQuery(dataProviders, browserFields), indexPattern) ); - const kibana = useKibana(); - const [filterManager] = useState(new FilterManager(kibana.services.uiSettings)); - const savedQueryServices = useSavedQueryServices(); useEffect(() => { diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx index 87061bdbb5d02..a0a0ac4c2b85c 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/index.tsx @@ -10,7 +10,11 @@ import { connect, ConnectedProps } from 'react-redux'; import { Dispatch } from 'redux'; import deepEqual from 'fast-deep-equal'; -import { Filter, IIndexPattern } from '../../../../../../../../src/plugins/data/public'; +import { + Filter, + FilterManager, + IIndexPattern, +} from '../../../../../../../../src/plugins/data/public'; import { BrowserFields } from '../../../containers/source'; import { convertKueryToElasticSearchQuery } from '../../../lib/keury'; import { @@ -29,6 +33,7 @@ import { SearchOrFilter } from './search_or_filter'; interface OwnProps { browserFields: BrowserFields; + filterManager: FilterManager; indexPattern: IIndexPattern; timelineId: string; } @@ -42,6 +47,7 @@ const StatefulSearchOrFilterComponent = React.memo( dataProviders, eventType, filters, + filterManager, filterQuery, filterQueryDraft, from, @@ -122,6 +128,7 @@ const StatefulSearchOrFilterComponent = React.memo( dataProviders={dataProviders} eventType={eventType} filters={filters} + filterManager={filterManager} filterQuery={filterQuery} filterQueryDraft={filterQueryDraft} from={from} @@ -146,6 +153,7 @@ const StatefulSearchOrFilterComponent = React.memo( (prevProps, nextProps) => { return ( prevProps.eventType === nextProps.eventType && + prevProps.filterManager === nextProps.filterManager && prevProps.from === nextProps.from && prevProps.fromStr === nextProps.fromStr && prevProps.to === nextProps.to && diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/search_or_filter.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/search_or_filter.tsx index 7bdd92e745f21..02a575db259bb 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/search_or_filter.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/search_or_filter/search_or_filter.tsx @@ -8,7 +8,11 @@ import { EuiFlexGroup, EuiFlexItem, EuiSuperSelect, EuiToolTip } from '@elastic/ import React from 'react'; import styled, { createGlobalStyle } from 'styled-components'; -import { Filter, IIndexPattern } from '../../../../../../../../src/plugins/data/public'; +import { + Filter, + FilterManager, + IIndexPattern, +} from '../../../../../../../../src/plugins/data/public'; import { BrowserFields } from '../../../containers/source'; import { KueryFilterQuery, KueryFilterQueryKind } from '../../../store'; import { KqlMode, EventType } from '../../../store/timeline/model'; @@ -44,6 +48,7 @@ interface Props { browserFields: BrowserFields; dataProviders: DataProvider[]; eventType: EventType; + filterManager: FilterManager; filterQuery: KueryFilterQuery; filterQueryDraft: KueryFilterQuery; from: number; @@ -95,6 +100,7 @@ export const SearchOrFilter = React.memo( indexPattern, isRefreshPaused, filters, + filterManager, filterQuery, filterQueryDraft, from, @@ -135,6 +141,7 @@ export const SearchOrFilter = React.memo( browserFields={browserFields} dataProviders={dataProviders} filters={filters} + filterManager={filterManager} filterQuery={filterQuery} filterQueryDraft={filterQueryDraft} from={from} diff --git a/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx b/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx index 098dd82791610..222cc0530bddb 100644 --- a/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx +++ b/x-pack/legacy/plugins/siem/public/components/timeline/timeline.tsx @@ -6,7 +6,7 @@ import { EuiFlyoutHeader, EuiFlyoutBody, EuiFlyoutFooter } from '@elastic/eui'; import { getOr, isEmpty } from 'lodash/fp'; -import React, { useMemo } from 'react'; +import React, { useState, useMemo } from 'react'; import styled from 'styled-components'; import { FlyoutHeaderWithCloseButton } from '../flyout/header_with_close_button'; @@ -34,7 +34,12 @@ import { TimelineHeader } from './header'; import { combineQueries } from './helpers'; import { TimelineRefetch } from './refetch_timeline'; import { ManageTimelineContext } from './timeline_context'; -import { esQuery, Filter, IIndexPattern } from '../../../../../../../src/plugins/data/public'; +import { + esQuery, + Filter, + FilterManager, + IIndexPattern, +} from '../../../../../../../src/plugins/data/public'; const TimelineContainer = styled.div` height: 100%; @@ -143,6 +148,7 @@ export const TimelineComponent: React.FC = ({ usersViewing, }) => { const kibana = useKibana(); + const [filterManager] = useState(new FilterManager(kibana.services.uiSettings)); const combinedQueries = combineQueries({ config: esQuery.getEsQueryConfig(kibana.services.uiSettings), dataProviders, @@ -178,6 +184,7 @@ export const TimelineComponent: React.FC = ({ id={id} indexPattern={indexPattern} dataProviders={dataProviders} + filterManager={filterManager} onChangeDataProviderKqlQuery={onChangeDataProviderKqlQuery} onChangeDroppableAndProvider={onChangeDroppableAndProvider} onDataProviderEdited={onDataProviderEdited} @@ -211,7 +218,12 @@ export const TimelineComponent: React.FC = ({ getUpdatedAt, refetch, }) => ( - + (initTimelineContext); +interface TimelineContextState { + filterManager: FilterManager | undefined; + isLoading: boolean; +} + +const initTimelineContext: TimelineContextState = { filterManager: undefined, isLoading: false }; +export const TimelineContext = createContext(initTimelineContext); export const useTimelineContext = () => useContext(TimelineContext); export interface TimelineTypeContextProps { documentType?: string; footerText?: string; + id?: string; + indexToAdd?: string[] | null; loadingText?: string; queryFields?: string[]; selectAll?: boolean; @@ -24,6 +34,8 @@ export interface TimelineTypeContextProps { const initTimelineType: TimelineTypeContextProps = { documentType: undefined, footerText: undefined, + id: undefined, + indexToAdd: undefined, loadingText: undefined, queryFields: [], selectAll: false, @@ -36,6 +48,8 @@ export const useTimelineTypeContext = () => useContext(TimelineTypeContext); interface ManageTimelineContextProps { children: React.ReactNode; + filterManager: FilterManager; + indexToAdd?: string[] | null; loading: boolean; type?: TimelineTypeContextProps; } @@ -44,22 +58,27 @@ interface ManageTimelineContextProps { // to avoid so many Context, at least the separation of code is there now const ManageTimelineContextComponent: React.FC = ({ children, + filterManager, + indexToAdd, loading, - type = initTimelineType, + type = { ...initTimelineType, indexToAdd }, }) => { - const [myLoading, setLoading] = useState(initTimelineContext); - const [myType, setType] = useState(initTimelineType); + const [myContextState, setMyContextState] = useState({ + filterManager, + isLoading: false, + }); + const [myType, setType] = useState(type); useEffect(() => { - setLoading(loading); - }, [loading]); + setMyContextState({ filterManager, isLoading: loading }); + }, [setMyContextState, filterManager, loading]); useEffect(() => { - setType(type); - }, [type]); + setType({ ...type, indexToAdd }); + }, [type, indexToAdd]); return ( - + {children} ); diff --git a/x-pack/legacy/plugins/siem/public/components/top_n/helpers.test.tsx b/x-pack/legacy/plugins/siem/public/components/top_n/helpers.test.tsx new file mode 100644 index 0000000000000..da0f6f59b533f --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/top_n/helpers.test.tsx @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { allEvents, defaultOptions, getOptions, rawEvents, signalEvents } from './helpers'; + +describe('getOptions', () => { + test(`it returns the default options when 'activeTimelineEventType' is undefined`, () => { + expect(getOptions()).toEqual(defaultOptions); + }); + + test(`it returns 'allEvents' when 'activeTimelineEventType' is 'all'`, () => { + expect(getOptions('all')).toEqual(allEvents); + }); + + test(`it returns 'rawEvents' when 'activeTimelineEventType' is 'raw'`, () => { + expect(getOptions('raw')).toEqual(rawEvents); + }); + + test(`it returns 'signalEvents' when 'activeTimelineEventType' is 'signal'`, () => { + expect(getOptions('signal')).toEqual(signalEvents); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/components/top_n/helpers.ts b/x-pack/legacy/plugins/siem/public/components/top_n/helpers.ts new file mode 100644 index 0000000000000..8d9ae48d29b69 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/top_n/helpers.ts @@ -0,0 +1,66 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { EventType } from '../../store/timeline/model'; + +import * as i18n from './translations'; + +export interface TopNOption { + inputDisplay: string; + value: EventType; + 'data-test-subj': string; +} + +/** A (stable) array containing only the 'All events' option */ +export const allEvents: TopNOption[] = [ + { + value: 'all', + inputDisplay: i18n.ALL_EVENTS, + 'data-test-subj': 'option-all', + }, +]; + +/** A (stable) array containing only the 'Raw events' option */ +export const rawEvents: TopNOption[] = [ + { + value: 'raw', + inputDisplay: i18n.RAW_EVENTS, + 'data-test-subj': 'option-raw', + }, +]; + +/** A (stable) array containing only the 'Signal events' option */ +export const signalEvents: TopNOption[] = [ + { + value: 'signal', + inputDisplay: i18n.SIGNAL_EVENTS, + 'data-test-subj': 'option-signal', + }, +]; + +/** A (stable) array containing the default Top N options */ +export const defaultOptions = [...rawEvents, ...signalEvents]; + +/** + * Returns the options to be displayed in a Top N view select. When + * an `activeTimelineEventType` is provided, an array containing + * just one option (corresponding to `activeTimelineEventType`) + * will be returned, to ensure the data displayed in the Top N + * is always in sync with the `EventType` chosen by the user in + * the active timeline. + */ +export const getOptions = (activeTimelineEventType?: EventType): TopNOption[] => { + switch (activeTimelineEventType) { + case 'all': + return allEvents; + case 'raw': + return rawEvents; + case 'signal': + return signalEvents; + default: + return defaultOptions; + } +}; diff --git a/x-pack/legacy/plugins/siem/public/components/top_n/index.test.tsx b/x-pack/legacy/plugins/siem/public/components/top_n/index.test.tsx new file mode 100644 index 0000000000000..61772f1dc7a7a --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/top_n/index.test.tsx @@ -0,0 +1,379 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { mount, ReactWrapper } from 'enzyme'; +import React from 'react'; + +import { mockBrowserFields } from '../../containers/source/mock'; +import { apolloClientObservable, mockGlobalState, TestProviders } from '../../mock'; +import { createKibanaCoreStartMock } from '../../mock/kibana_core'; +import { FilterManager } from '../../../../../../../src/plugins/data/public'; +import { createStore, State } from '../../store'; +import { TimelineContext, TimelineTypeContext } from '../timeline/timeline_context'; + +import { Props } from './top_n'; +import { ACTIVE_TIMELINE_REDUX_ID, StatefulTopN } from '.'; + +jest.mock('../../lib/kibana'); + +const mockUiSettingsForFilterManager = createKibanaCoreStartMock().uiSettings; + +const field = 'process.name'; +const value = 'nice'; + +const state: State = { + ...mockGlobalState, + inputs: { + ...mockGlobalState.inputs, + global: { + ...mockGlobalState.inputs.global, + query: { + query: 'host.name : end*', + language: 'kuery', + }, + filters: [ + { + meta: { + alias: null, + negate: false, + disabled: false, + type: 'phrase', + key: 'host.os.name', + params: { + query: 'Linux', + }, + }, + query: { + match: { + 'host.os.name': { + query: 'Linux', + type: 'phrase', + }, + }, + }, + }, + ], + }, + timeline: { + ...mockGlobalState.inputs.timeline, + timerange: { + kind: 'relative', + fromStr: 'now-24h', + toStr: 'now', + from: 1586835969047, + to: 1586922369047, + }, + }, + }, + timeline: { + ...mockGlobalState.timeline, + timelineById: { + [ACTIVE_TIMELINE_REDUX_ID]: { + ...mockGlobalState.timeline.timelineById.test, + id: ACTIVE_TIMELINE_REDUX_ID, + dataProviders: [ + { + id: + 'draggable-badge-default-draggable-netflow-renderer-timeline-1-_qpBe3EBD7k-aQQL7v7--_qpBe3EBD7k-aQQL7v7--network_transport-tcp', + name: 'tcp', + enabled: true, + excluded: false, + kqlQuery: '', + queryMatch: { + field: 'network.transport', + value: 'tcp', + operator: ':', + }, + and: [], + }, + ], + eventType: 'all', + filters: [ + { + meta: { + alias: null, + disabled: false, + key: 'source.port', + negate: false, + params: { + query: '30045', + }, + type: 'phrase', + }, + query: { + match: { + 'source.port': { + query: '30045', + type: 'phrase', + }, + }, + }, + }, + ], + kqlMode: 'filter', + kqlQuery: { + filterQuery: { + kuery: { + kind: 'kuery', + expression: 'host.name : *', + }, + serializedQuery: + '{"bool":{"should":[{"exists":{"field":"host.name"}}],"minimum_should_match":1}}', + }, + filterQueryDraft: { + kind: 'kuery', + expression: 'host.name : *', + }, + }, + }, + }, + }, +}; +const store = createStore(state, apolloClientObservable); + +describe('StatefulTopN', () => { + // Suppress warnings about "react-beautiful-dnd" + /* eslint-disable no-console */ + const originalError = console.error; + const originalWarn = console.warn; + beforeAll(() => { + console.warn = jest.fn(); + console.error = jest.fn(); + }); + afterAll(() => { + console.error = originalError; + console.warn = originalWarn; + }); + + describe('rendering in a global NON-timeline context', () => { + let wrapper: ReactWrapper; + + beforeEach(() => { + wrapper = mount( + + + + ); + }); + + test('it has undefined combinedQueries when rendering in a global context', () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.combinedQueries).toBeUndefined(); + }); + + test(`defaults to the 'Raw events' view when rendering in a global context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.defaultView).toEqual('raw'); + }); + + test(`provides a 'deleteQuery' when rendering in a global context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.deleteQuery).toBeDefined(); + }); + + test(`provides filters from Redux state (inputs > global > filters) when rendering in a global context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.filters).toEqual([ + { + meta: { + alias: null, + negate: false, + disabled: false, + type: 'phrase', + key: 'host.os.name', + params: { query: 'Linux' }, + }, + query: { match: { 'host.os.name': { query: 'Linux', type: 'phrase' } } }, + }, + ]); + }); + + test(`provides 'from' via GlobalTime when rendering in a global context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.from).toEqual(0); + }); + + test('provides the global query from Redux state (inputs > global > query) when rendering in a global context', () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.query).toEqual({ query: 'host.name : end*', language: 'kuery' }); + }); + + test(`provides a 'global' 'setAbsoluteRangeDatePickerTarget' when rendering in a global context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.setAbsoluteRangeDatePickerTarget).toEqual('global'); + }); + + test(`provides 'to' via GlobalTime when rendering in a global context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.to).toEqual(1); + }); + }); + + describe('rendering in a timeline context', () => { + let filterManager: FilterManager; + let wrapper: ReactWrapper; + + beforeEach(() => { + filterManager = new FilterManager(mockUiSettingsForFilterManager); + + wrapper = mount( + + + + + + + + ); + }); + + test('it has a combinedQueries value from Redux state composed of the timeline [data providers + kql + filter-bar-filters] when rendering in a timeline context', () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.combinedQueries).toEqual( + '{"bool":{"must":[],"filter":[{"bool":{"filter":[{"bool":{"filter":[{"bool":{"should":[{"match_phrase":{"network.transport":"tcp"}}],"minimum_should_match":1}},{"bool":{"should":[{"exists":{"field":"host.name"}}],"minimum_should_match":1}}]}},{"bool":{"filter":[{"bool":{"should":[{"range":{"@timestamp":{"gte":1586835969047}}}],"minimum_should_match":1}},{"bool":{"should":[{"range":{"@timestamp":{"lte":1586922369047}}}],"minimum_should_match":1}}]}}]}},{"match_phrase":{"source.port":{"query":"30045"}}}],"should":[],"must_not":[]}}' + ); + }); + + test('it provides only one view option that matches the `eventType` from redux when rendering in the context of the active timeline', () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.defaultView).toEqual('all'); + }); + + test(`provides an undefined 'deleteQuery' when rendering in a timeline context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.deleteQuery).toBeUndefined(); + }); + + test(`provides empty filters when rendering in a timeline context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.filters).toEqual([]); + }); + + test(`provides 'from' via redux state (inputs > timeline > timerange) when rendering in a timeline context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.from).toEqual(1586835969047); + }); + + test('provides an empty query when rendering in a timeline context', () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.query).toEqual({ query: '', language: 'kuery' }); + }); + + test(`provides a 'timeline' 'setAbsoluteRangeDatePickerTarget' when rendering in a timeline context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.setAbsoluteRangeDatePickerTarget).toEqual('timeline'); + }); + + test(`provides 'to' via redux state (inputs > timeline > timerange) when rendering in a timeline context`, () => { + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.to).toEqual(1586922369047); + }); + }); + + test(`defaults to the 'Signals events' option when rendering in a NON-active timeline context (e.g. the Signals table on the Detections page) when 'documentType' from 'useTimelineTypeContext()' is 'signals'`, () => { + const filterManager = new FilterManager(mockUiSettingsForFilterManager); + const wrapper = mount( + + + + + + + + ); + + const props = wrapper + .find('[data-test-subj="top-n"]') + .first() + .props() as Props; + + expect(props.defaultView).toEqual('signal'); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/components/top_n/index.tsx b/x-pack/legacy/plugins/siem/public/components/top_n/index.tsx new file mode 100644 index 0000000000000..983b234a04eaa --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/top_n/index.tsx @@ -0,0 +1,166 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { connect, ConnectedProps } from 'react-redux'; + +import { GlobalTime } from '../../containers/global_time'; +import { BrowserFields, WithSource } from '../../containers/source'; +import { useKibana } from '../../lib/kibana'; +import { esQuery, Filter, Query } from '../../../../../../../src/plugins/data/public'; +import { inputsModel, inputsSelectors, State, timelineSelectors } from '../../store'; +import { setAbsoluteRangeDatePicker as dispatchSetAbsoluteRangeDatePicker } from '../../store/inputs/actions'; +import { timelineDefaults } from '../../store/timeline/defaults'; +import { TimelineModel } from '../../store/timeline/model'; +import { combineQueries } from '../timeline/helpers'; +import { useTimelineTypeContext } from '../timeline/timeline_context'; + +import { getOptions } from './helpers'; +import { TopN } from './top_n'; + +/** The currently active timeline always has this Redux ID */ +export const ACTIVE_TIMELINE_REDUX_ID = 'timeline-1'; + +const EMPTY_FILTERS: Filter[] = []; +const EMPTY_QUERY: Query = { query: '', language: 'kuery' }; + +const makeMapStateToProps = () => { + const getGlobalQuerySelector = inputsSelectors.globalQuerySelector(); + const getGlobalFiltersQuerySelector = inputsSelectors.globalFiltersQuerySelector(); + const getTimeline = timelineSelectors.getTimelineByIdSelector(); + const getInputsTimeline = inputsSelectors.getTimelineSelector(); + const getKqlQueryTimeline = timelineSelectors.getKqlFilterQuerySelector(); + + // The mapped Redux state provided to this component includes the global + // filters that appear at the top of most views in the app, and all the + // filters in the active timeline: + const mapStateToProps = (state: State) => { + const activeTimeline: TimelineModel = + getTimeline(state, ACTIVE_TIMELINE_REDUX_ID) ?? timelineDefaults; + const activeTimelineFilters = activeTimeline.filters ?? EMPTY_FILTERS; + const activeTimelineInput: inputsModel.InputsRange = getInputsTimeline(state); + + return { + activeTimelineEventType: activeTimeline.eventType, + activeTimelineFilters, + activeTimelineFrom: activeTimelineInput.timerange.from, + activeTimelineKqlQueryExpression: getKqlQueryTimeline(state, ACTIVE_TIMELINE_REDUX_ID), + activeTimelineTo: activeTimelineInput.timerange.to, + dataProviders: activeTimeline.dataProviders, + globalQuery: getGlobalQuerySelector(state), + globalFilters: getGlobalFiltersQuerySelector(state), + kqlMode: activeTimeline.kqlMode, + }; + }; + + return mapStateToProps; +}; + +const mapDispatchToProps = { setAbsoluteRangeDatePicker: dispatchSetAbsoluteRangeDatePicker }; + +const connector = connect(makeMapStateToProps, mapDispatchToProps); + +interface OwnProps { + browserFields: BrowserFields; + field: string; + toggleTopN: () => void; + onFilterAdded?: () => void; + value?: string[] | string | null; +} +type PropsFromRedux = ConnectedProps; +type Props = OwnProps & PropsFromRedux; + +const StatefulTopNComponent: React.FC = ({ + activeTimelineEventType, + activeTimelineFilters, + activeTimelineFrom, + activeTimelineKqlQueryExpression, + activeTimelineTo, + browserFields, + dataProviders, + field, + globalFilters = EMPTY_FILTERS, + globalQuery = EMPTY_QUERY, + kqlMode, + onFilterAdded, + setAbsoluteRangeDatePicker, + toggleTopN, + value, +}) => { + const kibana = useKibana(); + + // Regarding data from useTimelineTypeContext: + // * `documentType` (e.g. 'signals') may only be populated in some views, + // e.g. the `Signals` view on the `Detections` page. + // * `id` (`timelineId`) may only be populated when we are rendered in the + // context of the active timeline. + // * `indexToAdd`, which enables the signals index to be appended to + // the `indexPattern` returned by `WithSource`, may only be populated when + // this component is rendered in the context of the active timeline. This + // behavior enables the 'All events' view by appending the signals index + // to the index pattern. + const { documentType, id: timelineId, indexToAdd } = useTimelineTypeContext(); + + const options = getOptions( + timelineId === ACTIVE_TIMELINE_REDUX_ID ? activeTimelineEventType : undefined + ); + + return ( + + {({ from, deleteQuery, setQuery, to }) => ( + + {({ indexPattern }) => ( + + )} + + )} + + ); +}; + +StatefulTopNComponent.displayName = 'StatefulTopNComponent'; + +export const StatefulTopN = connector(React.memo(StatefulTopNComponent)); diff --git a/x-pack/legacy/plugins/siem/public/components/top_n/top_n.test.tsx b/x-pack/legacy/plugins/siem/public/components/top_n/top_n.test.tsx new file mode 100644 index 0000000000000..13b77ea0ccd4c --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/top_n/top_n.test.tsx @@ -0,0 +1,261 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { mount, ReactWrapper } from 'enzyme'; +import React from 'react'; + +import { TestProviders, mockIndexPattern } from '../../mock'; +import { setAbsoluteRangeDatePicker } from '../../store/inputs/actions'; + +import { allEvents, defaultOptions } from './helpers'; +import { TopN } from './top_n'; + +jest.mock('../../lib/kibana'); + +jest.mock('uuid', () => { + return { + v1: jest.fn(() => 'uuid.v1()'), + v4: jest.fn(() => 'uuid.v4()'), + }; +}); + +const field = 'process.name'; +const value = 'nice'; +const combinedQueries = { + bool: { + must: [], + filter: [ + { + bool: { + filter: [ + { + bool: { + filter: [ + { + bool: { + should: [{ match_phrase: { 'network.transport': 'tcp' } }], + minimum_should_match: 1, + }, + }, + { + bool: { should: [{ exists: { field: 'host.name' } }], minimum_should_match: 1 }, + }, + ], + }, + }, + { + bool: { + filter: [ + { + bool: { + should: [{ range: { '@timestamp': { gte: 1586824450493 } } }], + minimum_should_match: 1, + }, + }, + { + bool: { + should: [{ range: { '@timestamp': { lte: 1586910850493 } } }], + minimum_should_match: 1, + }, + }, + ], + }, + }, + ], + }, + }, + { match_phrase: { 'source.port': { query: '30045' } } }, + ], + should: [], + must_not: [], + }, +}; + +describe('TopN', () => { + // Suppress warnings about "react-beautiful-dnd" + /* eslint-disable no-console */ + const originalError = console.error; + const originalWarn = console.warn; + beforeAll(() => { + console.warn = jest.fn(); + console.error = jest.fn(); + }); + afterAll(() => { + console.error = originalError; + console.warn = originalWarn; + }); + + const query = { query: '', language: 'kuery' }; + + describe('common functionality', () => { + let toggleTopN: () => void; + let wrapper: ReactWrapper; + + beforeEach(() => { + toggleTopN = jest.fn(); + wrapper = mount( + + + + ); + }); + + test('it invokes the toggleTopN function when the close button is clicked', () => { + wrapper + .find('[data-test-subj="close"]') + .first() + .simulate('click'); + wrapper.update(); + + expect(toggleTopN).toHaveBeenCalled(); + }); + + test('it enables the view select by default', () => { + expect( + wrapper + .find('[data-test-subj="view-select"]') + .first() + .props().disabled + ).toBe(false); + }); + }); + + describe('events view', () => { + let toggleTopN: () => void; + let wrapper: ReactWrapper; + + beforeEach(() => { + toggleTopN = jest.fn(); + wrapper = mount( + + + + ); + }); + + test(`it renders EventsByDataset when defaultView is 'raw'`, () => { + expect( + wrapper.find('[data-test-subj="eventsByDatasetOverview-uuid.v4()Panel"]').exists() + ).toBe(true); + }); + + test(`it does NOT render SignalsByCategory when defaultView is 'raw'`, () => { + expect(wrapper.find('[data-test-subj="signals-histogram-panel"]').exists()).toBe(false); + }); + }); + + describe('signals view', () => { + let toggleTopN: () => void; + let wrapper: ReactWrapper; + + beforeEach(() => { + toggleTopN = jest.fn(); + wrapper = mount( + + + + ); + }); + + test(`it renders SignalsByCategory when defaultView is 'signal'`, () => { + expect(wrapper.find('[data-test-subj="signals-histogram-panel"]').exists()).toBe(true); + }); + + test(`it does NOT render EventsByDataset when defaultView is 'signal'`, () => { + expect( + wrapper.find('[data-test-subj="eventsByDatasetOverview-uuid.v4()Panel"]').exists() + ).toBe(false); + }); + }); + + describe('All events, a view shown only when rendered in the context of the active timeline', () => { + let wrapper: ReactWrapper; + + beforeEach(() => { + wrapper = mount( + + + + ); + }); + + test(`it disables the view select when 'options' contains only one entry`, () => { + expect( + wrapper + .find('[data-test-subj="view-select"]') + .first() + .props().disabled + ).toBe(true); + }); + + test(`it renders EventsByDataset when defaultView is 'all'`, () => { + expect( + wrapper.find('[data-test-subj="eventsByDatasetOverview-uuid.v4()Panel"]').exists() + ).toBe(true); + }); + + test(`it does NOT render SignalsByCategory when defaultView is 'all'`, () => { + expect(wrapper.find('[data-test-subj="signals-histogram-panel"]').exists()).toBe(false); + }); + }); +}); diff --git a/x-pack/legacy/plugins/siem/public/components/top_n/top_n.tsx b/x-pack/legacy/plugins/siem/public/components/top_n/top_n.tsx new file mode 100644 index 0000000000000..136252617e2a2 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/top_n/top_n.tsx @@ -0,0 +1,158 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { EuiButtonIcon, EuiSuperSelect } from '@elastic/eui'; +import React, { useCallback, useMemo, useState } from 'react'; +import styled from 'styled-components'; +import { ActionCreator } from 'typescript-fsa'; + +import { EventsByDataset } from '../../pages/overview/events_by_dataset'; +import { SignalsByCategory } from '../../pages/overview/signals_by_category'; +import { Filter, IIndexPattern, Query } from '../../../../../../../src/plugins/data/public'; +import { inputsModel } from '../../store'; +import { InputsModelId } from '../../store/inputs/constants'; +import { EventType } from '../../store/timeline/model'; + +import { TopNOption } from './helpers'; +import * as i18n from './translations'; + +const TopNContainer = styled.div` + width: 600px; +`; + +const CloseButton = styled(EuiButtonIcon)` + z-index: 999999; + position: absolute; + right: 4px; + top: 4px; +`; + +const ViewSelect = styled(EuiSuperSelect)` + z-index: 999999; + width: 155px; +`; + +const TopNContent = styled.div` + margin-top: 4px; + + .euiPanel { + border: none; + } +`; + +export interface Props { + combinedQueries?: string; + defaultView: EventType; + deleteQuery?: ({ id }: { id: string }) => void; + field: string; + filters: Filter[]; + from: number; + indexPattern: IIndexPattern; + indexToAdd?: string[] | null; + options: TopNOption[]; + query: Query; + setAbsoluteRangeDatePicker: ActionCreator<{ + id: InputsModelId; + from: number; + to: number; + }>; + setAbsoluteRangeDatePickerTarget: InputsModelId; + setQuery: (params: { + id: string; + inspect: inputsModel.InspectQuery | null; + loading: boolean; + refetch: inputsModel.Refetch; + }) => void; + to: number; + toggleTopN: () => void; + onFilterAdded?: () => void; + value?: string[] | string | null; +} + +const NO_FILTERS: Filter[] = []; +const DEFAULT_QUERY: Query = { query: '', language: 'kuery' }; + +const TopNComponent: React.FC = ({ + combinedQueries, + defaultView, + deleteQuery, + filters = NO_FILTERS, + field, + from, + indexPattern, + indexToAdd, + options, + query = DEFAULT_QUERY, + setAbsoluteRangeDatePicker, + setAbsoluteRangeDatePickerTarget, + setQuery, + to, + toggleTopN, +}) => { + const [view, setView] = useState(defaultView); + const onViewSelected = useCallback((value: string) => setView(value as EventType), [setView]); + + const headerChildren = useMemo( + () => ( + + ), + [onViewSelected, options, view] + ); + + return ( + + + + + {view === 'raw' || view === 'all' ? ( + + ) : ( + + )} + + + ); +}; + +TopNComponent.displayName = 'TopNComponent'; + +export const TopN = React.memo(TopNComponent); diff --git a/x-pack/legacy/plugins/siem/public/components/top_n/translations.ts b/x-pack/legacy/plugins/siem/public/components/top_n/translations.ts new file mode 100644 index 0000000000000..7db55fa94d42e --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/components/top_n/translations.ts @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; + +export const CLOSE = i18n.translate('xpack.siem.topN.closeButtonLabel', { + defaultMessage: 'Close', +}); + +export const ALL_EVENTS = i18n.translate('xpack.siem.topN.allEventsSelectLabel', { + defaultMessage: 'All events', +}); + +export const RAW_EVENTS = i18n.translate('xpack.siem.topN.rawEventsSelectLabel', { + defaultMessage: 'Raw events', +}); + +export const SIGNAL_EVENTS = i18n.translate('xpack.siem.topN.signalEventsSelectLabel', { + defaultMessage: 'Signal events', +}); diff --git a/x-pack/legacy/plugins/siem/public/components/with_hover_actions/index.tsx b/x-pack/legacy/plugins/siem/public/components/with_hover_actions/index.tsx index 07ea165fcbb5c..86a9acc486b6d 100644 --- a/x-pack/legacy/plugins/siem/public/components/with_hover_actions/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/with_hover_actions/index.tsx @@ -4,8 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useState, useCallback } from 'react'; -import styled from 'styled-components'; +import { EuiPopover } from '@elastic/eui'; +import React, { useCallback, useMemo, useState } from 'react'; +import { IS_DRAGGING_CLASS_NAME } from '../drag_and_drop/helpers'; interface Props { /** @@ -26,34 +27,6 @@ interface Props { */ render: (showHoverContent: boolean) => JSX.Element; } - -const HoverActionsPanelContainer = styled.div` - color: ${({ theme }) => theme.eui.textColors.default}; - height: 100%; - position: relative; -`; - -HoverActionsPanelContainer.displayName = 'HoverActionsPanelContainer'; - -const HoverActionsPanel = React.memo<{ children: JSX.Element; show: boolean }>( - ({ children, show }) => ( - - {show ? children : null} - - ) -); - -HoverActionsPanel.displayName = 'HoverActionsPanel'; - -const WithHoverActionsContainer = styled.div` - display: flex; - flex-direction: row; - height: 100%; - padding-right: 5px; -`; - -WithHoverActionsContainer.displayName = 'WithHoverActionsContainer'; - /** * Decorates it's children with actions that are visible on hover. * This component does not enforce an opinion on the styling and @@ -68,20 +41,41 @@ export const WithHoverActions = React.memo( ({ alwaysShow = false, hoverContent, render }) => { const [showHoverContent, setShowHoverContent] = useState(false); const onMouseEnter = useCallback(() => { - setShowHoverContent(true); + // NOTE: the following read from the DOM is expensive, but not as + // expensive as the default behavior, which adds a div to the body, + // which-in turn performs a more expensive change to the layout + if (!document.body.classList.contains(IS_DRAGGING_CLASS_NAME)) { + setShowHoverContent(true); + } }, []); const onMouseLeave = useCallback(() => { setShowHoverContent(false); }, []); + const content = useMemo(() => <>{render(showHoverContent)}, [render, showHoverContent]); + + const isOpen = hoverContent != null && (showHoverContent || alwaysShow); + + const popover = useMemo(() => { + return ( + + {isOpen ? hoverContent : null} + + ); + }, [content, onMouseLeave, isOpen, alwaysShow, hoverContent]); + return ( - - <>{render(showHoverContent)} - - {hoverContent != null ? hoverContent : <>} - - +
+ {popover} +
); } ); diff --git a/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/index.tsx b/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/index.tsx index 85e19248f2eb5..83c38f2a76175 100644 --- a/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/index.tsx @@ -5,11 +5,12 @@ */ import React, { useEffect } from 'react'; + +import { DEFAULT_ANOMALY_SCORE } from '../../../../../../../plugins/siem/common/constants'; import { AnomaliesQueryTabBodyProps } from './types'; import { getAnomaliesFilterQuery } from './utils'; import { useSiemJobs } from '../../../components/ml_popover/hooks/use_siem_jobs'; import { useUiSetting$ } from '../../../lib/kibana'; -import { DEFAULT_ANOMALY_SCORE } from '../../../../common/constants'; import { MatrixHistogramContainer } from '../../../components/matrix_histogram'; import { histogramConfigs } from './histogram_configs'; const ID = 'anomaliesOverTimeQuery'; diff --git a/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/types.ts b/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/types.ts index f6cae81e3c6c4..d17eadc68d04b 100644 --- a/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/types.ts +++ b/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ESTermQuery } from '../../../../common/typed_json'; +import { ESTermQuery } from '../../../../../../../plugins/siem/common/typed_json'; import { NarrowDateRange } from '../../../components/ml/types'; import { UpdateDateRange } from '../../../components/charts/common'; import { SetQuery } from '../../../pages/hosts/navigation/types'; diff --git a/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/utils.ts b/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/utils.ts index 9609619916ab1..f698e302d3423 100644 --- a/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/utils.ts +++ b/x-pack/legacy/plugins/siem/public/containers/anomalies/anomalies_query_tab_body/utils.ts @@ -5,8 +5,9 @@ */ import deepmerge from 'deepmerge'; + +import { ESTermQuery } from '../../../../../../../plugins/siem/common/typed_json'; import { createFilter } from '../../helpers'; -import { ESTermQuery } from '../../../../common/typed_json'; import { SiemJob } from '../../../components/ml_popover/types'; import { FlowTarget } from '../../../graphql/types'; diff --git a/x-pack/legacy/plugins/siem/public/containers/authentications/index.tsx b/x-pack/legacy/plugins/siem/public/containers/authentications/index.tsx index 6d4a88c45a768..13bb40dad04bd 100644 --- a/x-pack/legacy/plugins/siem/public/containers/authentications/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/authentications/index.tsx @@ -10,7 +10,7 @@ import { Query } from 'react-apollo'; import { connect } from 'react-redux'; import { compose } from 'redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { AuthenticationsEdges, GetAuthenticationsQuery, diff --git a/x-pack/legacy/plugins/siem/public/containers/case/api.test.tsx b/x-pack/legacy/plugins/siem/public/containers/case/api.test.tsx index 4f5655cc9f221..693a7175ebc3e 100644 --- a/x-pack/legacy/plugins/siem/public/containers/case/api.test.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/case/api.test.tsx @@ -5,6 +5,9 @@ */ import { KibanaServices } from '../../lib/kibana'; + +import { CASES_URL } from '../../../../../../plugins/case/common/constants'; + import { deleteCases, getActionLicense, @@ -22,6 +25,7 @@ import { pushCase, pushToService, } from './api'; + import { actionLicenses, allCases, @@ -44,7 +48,7 @@ import { caseUserActionsSnake, casesStatusSnake, } from './mock'; -import { CASES_URL } from './constants'; + import { DEFAULT_FILTER_OPTIONS, DEFAULT_QUERY_PARAMS } from './use_get_cases'; import * as i18n from './translations'; diff --git a/x-pack/legacy/plugins/siem/public/containers/case/api.ts b/x-pack/legacy/plugins/siem/public/containers/case/api.ts index 12b4c80a2dd89..b745361632419 100644 --- a/x-pack/legacy/plugins/siem/public/containers/case/api.ts +++ b/x-pack/legacy/plugins/siem/public/containers/case/api.ts @@ -20,6 +20,21 @@ import { ActionTypeExecutorResult, } from '../../../../../../plugins/case/common/api'; +import { + CASE_STATUS_URL, + CASES_URL, + CASE_TAGS_URL, + CASE_REPORTERS_URL, + ACTION_TYPES_URL, + ACTION_URL, +} from '../../../../../../plugins/case/common/constants'; + +import { + getCaseDetailsUrl, + getCaseUserActionUrl, + getCaseCommentsUrl, +} from '../../../../../../plugins/case/common/api/helpers'; + import { KibanaServices } from '../../lib/kibana'; import { @@ -33,8 +48,6 @@ import { CaseUserActions, } from './types'; -import { CASES_URL } from './constants'; - import { convertToCamelCase, convertAllCasesToCamel, @@ -54,7 +67,7 @@ export const getCase = async ( includeComments: boolean = true, signal: AbortSignal ): Promise => { - const response = await KibanaServices.get().http.fetch(`${CASES_URL}/${caseId}`, { + const response = await KibanaServices.get().http.fetch(getCaseDetailsUrl(caseId), { method: 'GET', query: { includeComments, @@ -65,18 +78,15 @@ export const getCase = async ( }; export const getCasesStatus = async (signal: AbortSignal): Promise => { - const response = await KibanaServices.get().http.fetch( - `${CASES_URL}/status`, - { - method: 'GET', - signal, - } - ); + const response = await KibanaServices.get().http.fetch(CASE_STATUS_URL, { + method: 'GET', + signal, + }); return convertToCamelCase(decodeCasesStatusResponse(response)); }; export const getTags = async (signal: AbortSignal): Promise => { - const response = await KibanaServices.get().http.fetch(`${CASES_URL}/tags`, { + const response = await KibanaServices.get().http.fetch(CASE_TAGS_URL, { method: 'GET', signal, }); @@ -84,7 +94,7 @@ export const getTags = async (signal: AbortSignal): Promise => { }; export const getReporters = async (signal: AbortSignal): Promise => { - const response = await KibanaServices.get().http.fetch(`${CASES_URL}/reporters`, { + const response = await KibanaServices.get().http.fetch(CASE_REPORTERS_URL, { method: 'GET', signal, }); @@ -96,7 +106,7 @@ export const getCaseUserActions = async ( signal: AbortSignal ): Promise => { const response = await KibanaServices.get().http.fetch( - `${CASES_URL}/${caseId}/user_actions`, + getCaseUserActionUrl(caseId), { method: 'GET', signal, @@ -193,14 +203,11 @@ export const patchComment = async ( version: string, signal: AbortSignal ): Promise => { - const response = await KibanaServices.get().http.fetch( - `${CASES_URL}/${caseId}/comments`, - { - method: 'PATCH', - body: JSON.stringify({ comment: commentUpdate, id: commentId, version }), - signal, - } - ); + const response = await KibanaServices.get().http.fetch(getCaseCommentsUrl(caseId), { + method: 'PATCH', + body: JSON.stringify({ comment: commentUpdate, id: commentId, version }), + signal, + }); return convertToCamelCase(decodeCaseResponse(response)); }; @@ -219,7 +226,7 @@ export const pushCase = async ( signal: AbortSignal ): Promise => { const response = await KibanaServices.get().http.fetch( - `${CASES_URL}/${caseId}/_push`, + `${getCaseDetailsUrl(caseId)}/_push`, { method: 'POST', body: JSON.stringify(push), @@ -235,7 +242,7 @@ export const pushToService = async ( signal: AbortSignal ): Promise => { const response = await KibanaServices.get().http.fetch( - `/api/action/${connectorId}/_execute`, + `${ACTION_URL}/${connectorId}/_execute`, { method: 'POST', body: JSON.stringify({ params: casePushParams }), @@ -251,7 +258,7 @@ export const pushToService = async ( }; export const getActionLicense = async (signal: AbortSignal): Promise => { - const response = await KibanaServices.get().http.fetch(`/api/action/types`, { + const response = await KibanaServices.get().http.fetch(ACTION_TYPES_URL, { method: 'GET', signal, }); diff --git a/x-pack/legacy/plugins/siem/public/containers/case/configure/api.ts b/x-pack/legacy/plugins/siem/public/containers/case/configure/api.ts index c24081c777a96..85e472811c93b 100644 --- a/x-pack/legacy/plugins/siem/public/containers/case/configure/api.ts +++ b/x-pack/legacy/plugins/siem/public/containers/case/configure/api.ts @@ -13,26 +13,27 @@ import { } from '../../../../../../../plugins/case/common/api'; import { KibanaServices } from '../../../lib/kibana'; -import { CASES_CONFIGURE_URL } from '../constants'; +import { + CASE_CONFIGURE_CONNECTORS_URL, + CASE_CONFIGURE_URL, +} from '../../../../../../../plugins/case/common/constants'; + import { ApiProps } from '../types'; import { convertToCamelCase, decodeCaseConfigureResponse } from '../utils'; import { CaseConfigure } from './types'; export const fetchConnectors = async ({ signal }: ApiProps): Promise => { - const response = await KibanaServices.get().http.fetch( - `${CASES_CONFIGURE_URL}/connectors/_find`, - { - method: 'GET', - signal, - } - ); + const response = await KibanaServices.get().http.fetch(`${CASE_CONFIGURE_CONNECTORS_URL}/_find`, { + method: 'GET', + signal, + }); return response; }; export const getCaseConfigure = async ({ signal }: ApiProps): Promise => { const response = await KibanaServices.get().http.fetch( - CASES_CONFIGURE_URL, + CASE_CONFIGURE_URL, { method: 'GET', signal, @@ -51,7 +52,7 @@ export const postCaseConfigure = async ( signal: AbortSignal ): Promise => { const response = await KibanaServices.get().http.fetch( - CASES_CONFIGURE_URL, + CASE_CONFIGURE_URL, { method: 'POST', body: JSON.stringify(caseConfiguration), @@ -68,7 +69,7 @@ export const patchCaseConfigure = async ( signal: AbortSignal ): Promise => { const response = await KibanaServices.get().http.fetch( - CASES_CONFIGURE_URL, + CASE_CONFIGURE_URL, { method: 'PATCH', body: JSON.stringify(caseConfiguration), diff --git a/x-pack/legacy/plugins/siem/public/containers/case/constants.ts b/x-pack/legacy/plugins/siem/public/containers/case/constants.ts index ab8dc98db4f64..d8bb499ed7922 100644 --- a/x-pack/legacy/plugins/siem/public/containers/case/constants.ts +++ b/x-pack/legacy/plugins/siem/public/containers/case/constants.ts @@ -4,7 +4,5 @@ * you may not use this file except in compliance with the Elastic License. */ -export const CASES_URL = `/api/cases`; -export const CASES_CONFIGURE_URL = `/api/cases/configure`; export const DEFAULT_TABLE_ACTIVE_PAGE = 1; export const DEFAULT_TABLE_LIMIT = 5; diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts index 5cc73e17662c6..69f4c93a82e2c 100644 --- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts +++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/api.ts @@ -4,6 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ +import { + DETECTION_ENGINE_RULES_URL, + DETECTION_ENGINE_PREPACKAGED_URL, + DETECTION_ENGINE_RULES_STATUS_URL, + DETECTION_ENGINE_PREPACKAGED_RULES_STATUS_URL, + DETECTION_ENGINE_TAGS_URL, +} from '../../../../../../../plugins/siem/common/constants'; import { AddRulesProps, DeleteRulesProps, @@ -23,13 +30,6 @@ import { BulkRuleResponse, } from './types'; import { KibanaServices } from '../../../lib/kibana'; -import { - DETECTION_ENGINE_RULES_URL, - DETECTION_ENGINE_PREPACKAGED_URL, - DETECTION_ENGINE_RULES_STATUS_URL, - DETECTION_ENGINE_PREPACKAGED_RULES_STATUS_URL, - DETECTION_ENGINE_TAGS_URL, -} from '../../../../common/constants'; import * as i18n from '../../../pages/detection_engine/rules/translations'; /** diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/fetch_index_patterns.test.tsx b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/fetch_index_patterns.test.tsx index cad78ac565903..83b8a3581a4be 100644 --- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/fetch_index_patterns.test.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/fetch_index_patterns.test.tsx @@ -6,7 +6,7 @@ import { renderHook, act } from '@testing-library/react-hooks'; -import { defaultIndexPattern } from '../../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../../../../../plugins/siem/common/constants'; import { useApolloClient } from '../../../utils/apollo_context'; import { mocksSource } from '../../source/mock'; @@ -25,7 +25,7 @@ describe('useFetchIndexPatterns', () => { query: () => Promise.resolve(mocksSource[0].result), })); const { result, waitForNextUpdate } = renderHook(() => - useFetchIndexPatterns(defaultIndexPattern) + useFetchIndexPatterns(DEFAULT_INDEX_PATTERN) ); await waitForNextUpdate(); await waitForNextUpdate(); @@ -429,7 +429,7 @@ describe('useFetchIndexPatterns', () => { query: () => Promise.reject(new Error('Something went wrong')), })); const { result, waitForNextUpdate } = renderHook(() => - useFetchIndexPatterns(defaultIndexPattern) + useFetchIndexPatterns(DEFAULT_INDEX_PATTERN) ); await waitForNextUpdate(); diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/types.ts b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/types.ts index f89d21ef1aeb1..2f2de2e151664 100644 --- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/types.ts +++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/types.ts @@ -6,7 +6,7 @@ import * as t from 'io-ts'; -import { RuleTypeSchema } from '../../../../common/detection_engine/types'; +import { RuleTypeSchema } from '../../../../../../../plugins/siem/common/detection_engine/types'; /** * Params is an "record", since it is a type of AlertActionParams which is action templates. diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rule_status.test.tsx b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rule_status.test.tsx index 0a30329baf68d..f74c2bad1019e 100644 --- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rule_status.test.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/rules/use_rule_status.test.tsx @@ -72,104 +72,108 @@ describe('useRuleStatus', () => { cleanup(); }); - test('init', async () => { - await act(async () => { - const { result, waitForNextUpdate } = renderHook(() => - useRuleStatus('myOwnRuleID') - ); - await waitForNextUpdate(); - expect(result.current).toEqual([true, null, null]); - }); - }); - - test('fetch rule status', async () => { - await act(async () => { - const { result, waitForNextUpdate } = renderHook(() => - useRuleStatus('myOwnRuleID') - ); - await waitForNextUpdate(); - await waitForNextUpdate(); - expect(result.current).toEqual([ - false, - { - current_status: { - alert_id: 'alertId', - last_failure_at: null, - last_failure_message: null, - last_success_at: 'mm/dd/yyyyTHH:MM:sssz', - last_success_message: 'it is a success', - status: 'succeeded', - status_date: 'mm/dd/yyyyTHH:MM:sssz', - gap: null, - bulk_create_time_durations: ['2235.01'], - search_after_time_durations: ['616.97'], - last_look_back_date: '2020-03-19T00:32:07.996Z', - }, - failures: [], - }, - result.current[2], - ]); - }); - }); - - test('re-fetch rule status', async () => { - const spyOngetRuleStatusById = jest.spyOn(api, 'getRuleStatusById'); - await act(async () => { - const { result, waitForNextUpdate } = renderHook(() => - useRuleStatus('myOwnRuleID') - ); - await waitForNextUpdate(); - await waitForNextUpdate(); - if (result.current[2]) { - result.current[2]('myOwnRuleID'); - } - await waitForNextUpdate(); - expect(spyOngetRuleStatusById).toHaveBeenCalledTimes(2); - }); - }); - - test('init rules statuses', async () => { - const payload = [testRule]; - await act(async () => { - const { result, waitForNextUpdate } = renderHook(() => - useRulesStatuses(payload) - ); - await waitForNextUpdate(); - expect(result.current).toEqual({ loading: false, rulesStatuses: [] }); + describe('useRuleStatus', () => { + test('init', async () => { + await act(async () => { + const { result, waitForNextUpdate } = renderHook(() => + useRuleStatus('myOwnRuleID') + ); + await waitForNextUpdate(); + expect(result.current).toEqual([true, null, null]); + }); }); - }); - test('fetch rules statuses', async () => { - const payload = [testRule]; - await act(async () => { - const { result, waitForNextUpdate } = renderHook(() => - useRulesStatuses(payload) - ); - await waitForNextUpdate(); - await waitForNextUpdate(); - expect(result.current).toEqual({ - loading: false, - rulesStatuses: [ + test('fetch rule status', async () => { + await act(async () => { + const { result, waitForNextUpdate } = renderHook(() => + useRuleStatus('myOwnRuleID') + ); + await waitForNextUpdate(); + await waitForNextUpdate(); + expect(result.current).toEqual([ + false, { current_status: { alert_id: 'alertId', - bulk_create_time_durations: ['2235.01'], - gap: null, last_failure_at: null, last_failure_message: null, - last_look_back_date: '2020-03-19T00:32:07.996Z', last_success_at: 'mm/dd/yyyyTHH:MM:sssz', last_success_message: 'it is a success', - search_after_time_durations: ['616.97'], status: 'succeeded', status_date: 'mm/dd/yyyyTHH:MM:sssz', + gap: null, + bulk_create_time_durations: ['2235.01'], + search_after_time_durations: ['616.97'], + last_look_back_date: '2020-03-19T00:32:07.996Z', }, failures: [], - id: '12345678987654321', - activate: true, - name: 'Test rule', }, - ], + result.current[2], + ]); + }); + }); + + test('re-fetch rule status', async () => { + const spyOngetRuleStatusById = jest.spyOn(api, 'getRuleStatusById'); + await act(async () => { + const { result, waitForNextUpdate } = renderHook(() => + useRuleStatus('myOwnRuleID') + ); + await waitForNextUpdate(); + await waitForNextUpdate(); + if (result.current[2]) { + result.current[2]('myOwnRuleID'); + } + await waitForNextUpdate(); + expect(spyOngetRuleStatusById).toHaveBeenCalledTimes(2); + }); + }); + }); + + describe('useRulesStatuses', () => { + test('init rules statuses', async () => { + const payload = [testRule]; + await act(async () => { + const { result, waitForNextUpdate } = renderHook(() => + useRulesStatuses(payload) + ); + await waitForNextUpdate(); + expect(result.current).toEqual({ loading: false, rulesStatuses: [] }); + }); + }); + + test('fetch rules statuses', async () => { + const payload = [testRule]; + await act(async () => { + const { result, waitForNextUpdate } = renderHook(() => + useRulesStatuses(payload) + ); + await waitForNextUpdate(); + await waitForNextUpdate(); + expect(result.current).toEqual({ + loading: false, + rulesStatuses: [ + { + current_status: { + alert_id: 'alertId', + bulk_create_time_durations: ['2235.01'], + gap: null, + last_failure_at: null, + last_failure_message: null, + last_look_back_date: '2020-03-19T00:32:07.996Z', + last_success_at: 'mm/dd/yyyyTHH:MM:sssz', + last_success_message: 'it is a success', + search_after_time_durations: ['616.97'], + status: 'succeeded', + status_date: 'mm/dd/yyyyTHH:MM:sssz', + }, + failures: [], + id: '12345678987654321', + activate: true, + name: 'Test rule', + }, + ], + }); }); }); }); diff --git a/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/api.ts b/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/api.ts index 25263c2d32735..ece2483adde3a 100644 --- a/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/api.ts +++ b/x-pack/legacy/plugins/siem/public/containers/detection_engine/signals/api.ts @@ -4,13 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { KibanaServices } from '../../../lib/kibana'; import { DETECTION_ENGINE_QUERY_SIGNALS_URL, DETECTION_ENGINE_SIGNALS_STATUS_URL, DETECTION_ENGINE_INDEX_URL, DETECTION_ENGINE_PRIVILEGES_URL, -} from '../../../../common/constants'; +} from '../../../../../../../plugins/siem/common/constants'; +import { KibanaServices } from '../../../lib/kibana'; import { BasicSignals, Privilege, diff --git a/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/index.ts b/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/index.ts index 9cae503d30940..8628ba502f081 100644 --- a/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/index.ts +++ b/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/index.ts @@ -7,7 +7,7 @@ import { get } from 'lodash/fp'; import React, { useEffect, useState } from 'react'; -import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../../plugins/siem/common/constants'; import { GetLastEventTimeQuery, LastEventIndexKey, LastTimeDetails } from '../../../graphql/types'; import { inputsModel } from '../../../store'; import { QueryTemplateProps } from '../../query_template'; diff --git a/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/mock.ts b/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/mock.ts index ca8786077851f..5ef8e67dedddb 100644 --- a/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/mock.ts +++ b/x-pack/legacy/plugins/siem/public/containers/events/last_event_time/mock.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { defaultIndexPattern } from '../../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../../../../../plugins/siem/common/constants'; import { GetLastEventTimeQuery, LastEventIndexKey } from '../../../graphql/types'; import { LastEventTimeGqlQuery } from './last_event_time.gql_query'; @@ -43,7 +43,7 @@ export const mockLastEventTimeQuery: MockLastEventTimeQuery[] = [ sourceId: 'default', indexKey: LastEventIndexKey.hosts, details: {}, - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, }, }, result: { diff --git a/x-pack/legacy/plugins/siem/public/containers/helpers.test.ts b/x-pack/legacy/plugins/siem/public/containers/helpers.test.ts index 5d378d79acc7a..67cfe259927ab 100644 --- a/x-pack/legacy/plugins/siem/public/containers/helpers.test.ts +++ b/x-pack/legacy/plugins/siem/public/containers/helpers.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ESQuery } from '../../common/typed_json'; +import { ESQuery } from '../../../../../plugins/siem/common/typed_json'; import { createFilter } from './helpers'; diff --git a/x-pack/legacy/plugins/siem/public/containers/helpers.ts b/x-pack/legacy/plugins/siem/public/containers/helpers.ts index 5f66e3f4b88d4..7ff9577bfb05e 100644 --- a/x-pack/legacy/plugins/siem/public/containers/helpers.ts +++ b/x-pack/legacy/plugins/siem/public/containers/helpers.ts @@ -7,7 +7,7 @@ import { FetchPolicy } from 'apollo-client'; import { isString } from 'lodash/fp'; -import { ESQuery } from '../../common/typed_json'; +import { ESQuery } from '../../../../../plugins/siem/common/typed_json'; export const createFilter = (filterQuery: ESQuery | string | undefined) => isString(filterQuery) ? filterQuery : JSON.stringify(filterQuery); diff --git a/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/index.ts b/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/index.ts index e36da5bfbe4ee..5806125f2397b 100644 --- a/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/index.ts +++ b/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/index.ts @@ -8,8 +8,8 @@ import ApolloClient from 'apollo-client'; import { get } from 'lodash/fp'; import React, { useEffect, useState } from 'react'; +import { DEFAULT_INDEX_KEY } from '../../../../../../../plugins/siem/common/constants'; import { useUiSetting$ } from '../../../lib/kibana'; -import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; import { GetHostFirstLastSeenQuery } from '../../../graphql/types'; import { inputsModel } from '../../../store'; import { QueryTemplateProps } from '../../query_template'; diff --git a/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/mock.ts b/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/mock.ts index 2c9d418763e8e..7376f38ae8d0f 100644 --- a/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/mock.ts +++ b/x-pack/legacy/plugins/siem/public/containers/hosts/first_last_seen/mock.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { defaultIndexPattern } from '../../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../../../../../plugins/siem/common/constants'; import { GetHostFirstLastSeenQuery } from '../../../graphql/types'; import { HostFirstLastSeenGqlQuery } from './first_last_seen.gql_query'; @@ -34,7 +34,7 @@ export const mockFirstLastSeenHostQuery: MockedProvidedQuery[] = [ variables: { sourceId: 'default', hostName: 'kibana-siem', - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, }, }, result: { diff --git a/x-pack/legacy/plugins/siem/public/containers/hosts/index.tsx b/x-pack/legacy/plugins/siem/public/containers/hosts/index.tsx index 733c2224d840a..edf3f6855f955 100644 --- a/x-pack/legacy/plugins/siem/public/containers/hosts/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/hosts/index.tsx @@ -11,7 +11,7 @@ import { Query } from 'react-apollo'; import { connect } from 'react-redux'; import { compose } from 'redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { Direction, GetHostsTableQuery, diff --git a/x-pack/legacy/plugins/siem/public/containers/hosts/overview/index.tsx b/x-pack/legacy/plugins/siem/public/containers/hosts/overview/index.tsx index 5057e872b5313..405c45348b54d 100644 --- a/x-pack/legacy/plugins/siem/public/containers/hosts/overview/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/hosts/overview/index.tsx @@ -10,7 +10,7 @@ import { Query } from 'react-apollo'; import { connect } from 'react-redux'; import { compose } from 'redux'; -import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../../plugins/siem/common/constants'; import { inputsModel, inputsSelectors, State } from '../../../store'; import { getDefaultFetchPolicy } from '../../helpers'; import { QueryTemplate, QueryTemplateProps } from '../../query_template'; diff --git a/x-pack/legacy/plugins/siem/public/containers/ip_overview/index.tsx b/x-pack/legacy/plugins/siem/public/containers/ip_overview/index.tsx index ade94c430c6ef..954bfede07139 100644 --- a/x-pack/legacy/plugins/siem/public/containers/ip_overview/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/ip_overview/index.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { Query } from 'react-apollo'; import { connect, ConnectedProps } from 'react-redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { GetIpOverviewQuery, IpOverviewData } from '../../graphql/types'; import { networkModel, inputsModel, inputsSelectors, State } from '../../store'; import { useUiSetting } from '../../lib/kibana'; diff --git a/x-pack/legacy/plugins/siem/public/containers/kpi_host_details/index.tsx b/x-pack/legacy/plugins/siem/public/containers/kpi_host_details/index.tsx index de9d54b1a185c..3933aefa60483 100644 --- a/x-pack/legacy/plugins/siem/public/containers/kpi_host_details/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/kpi_host_details/index.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { Query } from 'react-apollo'; import { connect, ConnectedProps } from 'react-redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { KpiHostDetailsData, GetKpiHostDetailsQuery } from '../../graphql/types'; import { inputsModel, inputsSelectors, State } from '../../store'; import { useUiSetting } from '../../lib/kibana'; diff --git a/x-pack/legacy/plugins/siem/public/containers/kpi_hosts/index.tsx b/x-pack/legacy/plugins/siem/public/containers/kpi_hosts/index.tsx index 5be2423e8a162..7035d63193118 100644 --- a/x-pack/legacy/plugins/siem/public/containers/kpi_hosts/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/kpi_hosts/index.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { Query } from 'react-apollo'; import { connect, ConnectedProps } from 'react-redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { GetKpiHostsQuery, KpiHostsData } from '../../graphql/types'; import { inputsModel, inputsSelectors, State } from '../../store'; import { useUiSetting } from '../../lib/kibana'; diff --git a/x-pack/legacy/plugins/siem/public/containers/kpi_network/index.tsx b/x-pack/legacy/plugins/siem/public/containers/kpi_network/index.tsx index 338cdc39b178c..002a819417df6 100644 --- a/x-pack/legacy/plugins/siem/public/containers/kpi_network/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/kpi_network/index.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { Query } from 'react-apollo'; import { connect, ConnectedProps } from 'react-redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { GetKpiNetworkQuery, KpiNetworkData } from '../../graphql/types'; import { inputsModel, inputsSelectors, State } from '../../store'; import { useUiSetting } from '../../lib/kibana'; diff --git a/x-pack/legacy/plugins/siem/public/containers/matrix_histogram/index.ts b/x-pack/legacy/plugins/siem/public/containers/matrix_histogram/index.ts index 0b369b4180fb8..55d7e7cdc6e54 100644 --- a/x-pack/legacy/plugins/siem/public/containers/matrix_histogram/index.ts +++ b/x-pack/legacy/plugins/siem/public/containers/matrix_histogram/index.ts @@ -3,9 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { useEffect, useState, useRef } from 'react'; + +import { isEmpty } from 'lodash/fp'; +import { useEffect, useMemo, useState, useRef } from 'react'; + +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { MatrixHistogramQueryProps } from '../../components/matrix_histogram/types'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; import { errorToToaster, useStateToaster } from '../../components/toasters'; import { useUiSetting$ } from '../../lib/kibana'; import { createFilter } from '../helpers'; @@ -19,11 +22,19 @@ export const useQuery = ({ errorMessage, filterQuery, histogramType, + indexToAdd, isInspected, stackByField, startDate, }: MatrixHistogramQueryProps) => { - const [defaultIndex] = useUiSetting$(DEFAULT_INDEX_KEY); + const [configIndex] = useUiSetting$(DEFAULT_INDEX_KEY); + const defaultIndex = useMemo(() => { + if (indexToAdd != null && !isEmpty(indexToAdd)) { + return [...configIndex, ...indexToAdd]; + } + return configIndex; + }, [configIndex, indexToAdd]); + const [, dispatchToaster] = useStateToaster(); const refetch = useRef(); const [loading, setLoading] = useState(false); @@ -96,6 +107,7 @@ export const useQuery = ({ errorMessage, filterQuery, histogramType, + indexToAdd, isInspected, stackByField, startDate, diff --git a/x-pack/legacy/plugins/siem/public/containers/network_dns/index.tsx b/x-pack/legacy/plugins/siem/public/containers/network_dns/index.tsx index 04c8783c30a0f..060b66fc3cbbe 100644 --- a/x-pack/legacy/plugins/siem/public/containers/network_dns/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/network_dns/index.tsx @@ -12,7 +12,7 @@ import { compose } from 'redux'; import { DocumentNode } from 'graphql'; import { ScaleType } from '@elastic/charts'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { GetNetworkDnsQuery, NetworkDnsEdges, diff --git a/x-pack/legacy/plugins/siem/public/containers/network_http/index.tsx b/x-pack/legacy/plugins/siem/public/containers/network_http/index.tsx index bf4e64f63d559..b13637fa88d07 100644 --- a/x-pack/legacy/plugins/siem/public/containers/network_http/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/network_http/index.tsx @@ -10,7 +10,7 @@ import { Query } from 'react-apollo'; import { connect } from 'react-redux'; import { compose } from 'redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { GetNetworkHttpQuery, NetworkHttpEdges, diff --git a/x-pack/legacy/plugins/siem/public/containers/network_top_countries/index.tsx b/x-pack/legacy/plugins/siem/public/containers/network_top_countries/index.tsx index bd1e1a002bbcd..17a14ce3a1120 100644 --- a/x-pack/legacy/plugins/siem/public/containers/network_top_countries/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/network_top_countries/index.tsx @@ -10,7 +10,7 @@ import { Query } from 'react-apollo'; import { connect } from 'react-redux'; import { compose } from 'redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { FlowTargetSourceDest, GetNetworkTopCountriesQuery, diff --git a/x-pack/legacy/plugins/siem/public/containers/network_top_n_flow/index.tsx b/x-pack/legacy/plugins/siem/public/containers/network_top_n_flow/index.tsx index f0f1f8257f29f..fdac282292a4b 100644 --- a/x-pack/legacy/plugins/siem/public/containers/network_top_n_flow/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/network_top_n_flow/index.tsx @@ -10,7 +10,7 @@ import { Query } from 'react-apollo'; import { connect } from 'react-redux'; import { compose } from 'redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { FlowTargetSourceDest, GetNetworkTopNFlowQuery, diff --git a/x-pack/legacy/plugins/siem/public/containers/overview/overview_host/index.tsx b/x-pack/legacy/plugins/siem/public/containers/overview/overview_host/index.tsx index 2dd9ccf24d802..e7b68bf557a21 100644 --- a/x-pack/legacy/plugins/siem/public/containers/overview/overview_host/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/overview/overview_host/index.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { Query } from 'react-apollo'; import { connect, ConnectedProps } from 'react-redux'; -import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../../plugins/siem/common/constants'; import { GetOverviewHostQuery, OverviewHostData } from '../../../graphql/types'; import { useUiSetting } from '../../../lib/kibana'; import { inputsModel, inputsSelectors } from '../../../store/inputs'; diff --git a/x-pack/legacy/plugins/siem/public/containers/overview/overview_network/index.tsx b/x-pack/legacy/plugins/siem/public/containers/overview/overview_network/index.tsx index d0acd41c224a5..c7f72ac6193f4 100644 --- a/x-pack/legacy/plugins/siem/public/containers/overview/overview_network/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/overview/overview_network/index.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { Query } from 'react-apollo'; import { connect, ConnectedProps } from 'react-redux'; -import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../../plugins/siem/common/constants'; import { GetOverviewNetworkQuery, OverviewNetworkData } from '../../../graphql/types'; import { useUiSetting } from '../../../lib/kibana'; import { State } from '../../../store'; diff --git a/x-pack/legacy/plugins/siem/public/containers/query_template.tsx b/x-pack/legacy/plugins/siem/public/containers/query_template.tsx index dfb452c24b86e..c33f5fd89a79b 100644 --- a/x-pack/legacy/plugins/siem/public/containers/query_template.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/query_template.tsx @@ -8,7 +8,7 @@ import { ApolloQueryResult } from 'apollo-client'; import React from 'react'; import { FetchMoreOptions, FetchMoreQueryOptions, OperationVariables } from 'react-apollo'; -import { ESQuery } from '../../common/typed_json'; +import { ESQuery } from '../../../../../plugins/siem/common/typed_json'; export interface QueryTemplateProps { id?: string; diff --git a/x-pack/legacy/plugins/siem/public/containers/query_template_paginated.tsx b/x-pack/legacy/plugins/siem/public/containers/query_template_paginated.tsx index db618f216d83e..45041a6447611 100644 --- a/x-pack/legacy/plugins/siem/public/containers/query_template_paginated.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/query_template_paginated.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { FetchMoreOptions, FetchMoreQueryOptions, OperationVariables } from 'react-apollo'; import deepEqual from 'fast-deep-equal'; -import { ESQuery } from '../../common/typed_json'; +import { ESQuery } from '../../../../../plugins/siem/common/typed_json'; import { inputsModel } from '../store/model'; import { generateTablePaginationOptions } from '../components/paginated_table/helpers'; diff --git a/x-pack/legacy/plugins/siem/public/containers/source/index.tsx b/x-pack/legacy/plugins/siem/public/containers/source/index.tsx index e454421ca955d..3467e2b5f18d8 100644 --- a/x-pack/legacy/plugins/siem/public/containers/source/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/source/index.tsx @@ -11,9 +11,9 @@ import React, { useEffect, useMemo, useState } from 'react'; import memoizeOne from 'memoize-one'; import { IIndexPattern } from 'src/plugins/data/public'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { useUiSetting$ } from '../../lib/kibana'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; import { IndexField, SourceQuery } from '../../graphql/types'; import { sourceQuery } from './index.gql_query'; diff --git a/x-pack/legacy/plugins/siem/public/containers/source/mock.ts b/x-pack/legacy/plugins/siem/public/containers/source/mock.ts index 738c1681f40af..805c69f7fcc12 100644 --- a/x-pack/legacy/plugins/siem/public/containers/source/mock.ts +++ b/x-pack/legacy/plugins/siem/public/containers/source/mock.ts @@ -4,9 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ +import { DEFAULT_INDEX_PATTERN } from '../../../../../../plugins/siem/common/constants'; + import { BrowserFields } from '.'; import { sourceQuery } from './index.gql_query'; -import { defaultIndexPattern } from '../../../default_index_pattern'; export const mocksSource = [ { @@ -14,7 +15,7 @@ export const mocksSource = [ query: sourceQuery, variables: { sourceId: 'default', - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, }, }, result: { @@ -333,7 +334,7 @@ export const mocksSource = [ 'event.end contains the date when the event ended or when the activity was last observed.', example: null, format: '', - indexes: defaultIndexPattern, + indexes: DEFAULT_INDEX_PATTERN, name: 'event.end', searchable: true, type: 'date', @@ -661,7 +662,7 @@ export const mockBrowserFields: BrowserFields = { 'event.end contains the date when the event ended or when the activity was last observed.', example: null, format: '', - indexes: defaultIndexPattern, + indexes: DEFAULT_INDEX_PATTERN, name: 'event.end', searchable: true, type: 'date', diff --git a/x-pack/legacy/plugins/siem/public/containers/timeline/all/api.ts b/x-pack/legacy/plugins/siem/public/containers/timeline/all/api.ts index 4c8e2384de585..32ac62d594e1c 100644 --- a/x-pack/legacy/plugins/siem/public/containers/timeline/all/api.ts +++ b/x-pack/legacy/plugins/siem/public/containers/timeline/all/api.ts @@ -4,9 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ +import { + TIMELINE_IMPORT_URL, + TIMELINE_EXPORT_URL, +} from '../../../../../../../plugins/siem/common/constants'; import { ImportDataProps, ImportDataResponse } from '../../detection_engine/rules'; import { KibanaServices } from '../../../lib/kibana'; -import { TIMELINE_IMPORT_URL, TIMELINE_EXPORT_URL } from '../../../../common/constants'; import { ExportSelectedData } from '../../../components/generic_downloader'; export const importTimelines = async ({ diff --git a/x-pack/legacy/plugins/siem/public/containers/timeline/details/index.tsx b/x-pack/legacy/plugins/siem/public/containers/timeline/details/index.tsx index cf1b8954307e7..0debed9c5f9aa 100644 --- a/x-pack/legacy/plugins/siem/public/containers/timeline/details/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/timeline/details/index.tsx @@ -9,7 +9,7 @@ import memoizeOne from 'memoize-one'; import React from 'react'; import { Query } from 'react-apollo'; -import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../../plugins/siem/common/constants'; import { DetailItem, GetTimelineDetailsQuery } from '../../../graphql/types'; import { useUiSetting } from '../../../lib/kibana'; diff --git a/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx b/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx index f726ec9779dc8..3c089ef6926dd 100644 --- a/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/timeline/index.tsx @@ -11,8 +11,8 @@ import { Query } from 'react-apollo'; import { compose, Dispatch } from 'redux'; import { connect, ConnectedProps } from 'react-redux'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { IIndexPattern } from '../../../../../../../src/plugins/data/common/index_patterns'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; import { GetTimelineQuery, PageInfo, diff --git a/x-pack/legacy/plugins/siem/public/containers/tls/index.tsx b/x-pack/legacy/plugins/siem/public/containers/tls/index.tsx index 3738355c8846e..20617b88bda94 100644 --- a/x-pack/legacy/plugins/siem/public/containers/tls/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/tls/index.tsx @@ -10,7 +10,7 @@ import { Query } from 'react-apollo'; import { connect } from 'react-redux'; import { compose } from 'redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { PageInfoPaginated, TlsEdges, diff --git a/x-pack/legacy/plugins/siem/public/containers/uncommon_processes/index.tsx b/x-pack/legacy/plugins/siem/public/containers/uncommon_processes/index.tsx index 0a2ce67d9be80..72e4e46bc6ae0 100644 --- a/x-pack/legacy/plugins/siem/public/containers/uncommon_processes/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/uncommon_processes/index.tsx @@ -10,7 +10,7 @@ import { Query } from 'react-apollo'; import { connect, ConnectedProps } from 'react-redux'; import { compose } from 'redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { GetUncommonProcessesQuery, PageInfoPaginated, diff --git a/x-pack/legacy/plugins/siem/public/containers/users/index.tsx b/x-pack/legacy/plugins/siem/public/containers/users/index.tsx index 5f71449c52460..658cb5785b54c 100644 --- a/x-pack/legacy/plugins/siem/public/containers/users/index.tsx +++ b/x-pack/legacy/plugins/siem/public/containers/users/index.tsx @@ -10,7 +10,7 @@ import { Query } from 'react-apollo'; import { connect, ConnectedProps } from 'react-redux'; import { compose } from 'redux'; -import { DEFAULT_INDEX_KEY } from '../../../common/constants'; +import { DEFAULT_INDEX_KEY } from '../../../../../../plugins/siem/common/constants'; import { GetUsersQuery, FlowTarget, PageInfoPaginated, UsersEdges } from '../../graphql/types'; import { inputsModel, networkModel, networkSelectors, State, inputsSelectors } from '../../store'; import { withKibana, WithKibanaProps } from '../../lib/kibana'; diff --git a/x-pack/legacy/plugins/siem/public/lib/kibana/hooks.ts b/x-pack/legacy/plugins/siem/public/lib/kibana/hooks.ts index 775a7d7c0acca..e1d0a445bf2fb 100644 --- a/x-pack/legacy/plugins/siem/public/lib/kibana/hooks.ts +++ b/x-pack/legacy/plugins/siem/public/lib/kibana/hooks.ts @@ -8,7 +8,10 @@ import moment from 'moment-timezone'; import { useCallback, useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; -import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_TZ } from '../../../common/constants'; +import { + DEFAULT_DATE_FORMAT, + DEFAULT_DATE_FORMAT_TZ, +} from '../../../../../../plugins/siem/common/constants'; import { useUiSetting, useKibana } from './kibana_react'; import { errorToToaster, useStateToaster } from '../../components/toasters'; import { AuthenticatedUser } from '../../../../../../plugins/security/common/model'; diff --git a/x-pack/legacy/plugins/siem/public/lib/theme/use_eui_theme.tsx b/x-pack/legacy/plugins/siem/public/lib/theme/use_eui_theme.tsx index 1696001203bc8..b72c34d3b59a7 100644 --- a/x-pack/legacy/plugins/siem/public/lib/theme/use_eui_theme.tsx +++ b/x-pack/legacy/plugins/siem/public/lib/theme/use_eui_theme.tsx @@ -7,7 +7,7 @@ import darkTheme from '@elastic/eui/dist/eui_theme_dark.json'; import lightTheme from '@elastic/eui/dist/eui_theme_light.json'; -import { DEFAULT_DARK_MODE } from '../../../common/constants'; +import { DEFAULT_DARK_MODE } from '../../../../../../plugins/siem/common/constants'; import { useUiSetting$ } from '../kibana'; export const useEuiTheme = () => { diff --git a/x-pack/legacy/plugins/siem/public/mock/global_state.ts b/x-pack/legacy/plugins/siem/public/mock/global_state.ts index 6678c3043a3da..266c3aadea8af 100644 --- a/x-pack/legacy/plugins/siem/public/mock/global_state.ts +++ b/x-pack/legacy/plugins/siem/public/mock/global_state.ts @@ -22,7 +22,7 @@ import { DEFAULT_TO, DEFAULT_INTERVAL_TYPE, DEFAULT_INTERVAL_VALUE, -} from '../../common/constants'; +} from '../../../../../plugins/siem/common/constants'; export const mockGlobalState: State = { app: { diff --git a/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts b/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts index 968ab6543f4fc..db7a931b3fb15 100644 --- a/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts +++ b/x-pack/legacy/plugins/siem/public/mock/kibana_react.ts @@ -23,8 +23,8 @@ import { DEFAULT_INTERVAL_PAUSE, DEFAULT_INTERVAL_VALUE, DEFAULT_BYTES_FORMAT, -} from '../../common/constants'; -import { defaultIndexPattern } from '../../default_index_pattern'; + DEFAULT_INDEX_PATTERN, +} from '../../../../../plugins/siem/common/constants'; import { createKibanaCoreStartMock, createKibanaPluginsStartMock } from './kibana_core'; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -39,7 +39,7 @@ export const mockUiSettings: Record = { pause: DEFAULT_INTERVAL_PAUSE, value: DEFAULT_INTERVAL_VALUE, }, - [DEFAULT_INDEX_KEY]: defaultIndexPattern, + [DEFAULT_INDEX_KEY]: DEFAULT_INDEX_PATTERN, [DEFAULT_BYTES_FORMAT]: '0,0.[0]b', [DEFAULT_DATE_FORMAT_TZ]: 'UTC', [DEFAULT_DATE_FORMAT]: 'MMM D, YYYY @ HH:mm:ss.SSS', diff --git a/x-pack/legacy/plugins/siem/public/pages/case/components/__mock__/form.ts b/x-pack/legacy/plugins/siem/public/pages/case/components/__mock__/form.ts index 9d2ac29bc47d7..cc01edcfaab11 100644 --- a/x-pack/legacy/plugins/siem/public/pages/case/components/__mock__/form.ts +++ b/x-pack/legacy/plugins/siem/public/pages/case/components/__mock__/form.ts @@ -3,6 +3,10 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import { useForm } from '../../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks'; +jest.mock( + '../../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks/use_form' +); export const mockFormHook = { isSubmitted: false, isSubmitting: false, @@ -35,3 +39,5 @@ export const getFormMock = (sampleData: any) => ({ }), getFormData: () => sampleData, }); + +export const useFormMock = useForm as jest.Mock; diff --git a/x-pack/legacy/plugins/siem/public/pages/case/components/create/index.test.tsx b/x-pack/legacy/plugins/siem/public/pages/case/components/create/index.test.tsx index d480744fc932a..0897be6310fa2 100644 --- a/x-pack/legacy/plugins/siem/public/pages/case/components/create/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/case/components/create/index.test.tsx @@ -14,6 +14,8 @@ import { Router, routeData, mockHistory, mockLocation } from '../__mock__/router import { useInsertTimeline } from '../../../../components/timeline/insert_timeline_popover/use_insert_timeline'; import { usePostCase } from '../../../../containers/case/use_post_case'; +import { useGetTags } from '../../../../containers/case/use_get_tags'; + jest.mock('../../../../components/timeline/insert_timeline_popover/use_insert_timeline'); jest.mock('../../../../containers/case/use_post_case'); import { useForm } from '../../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks'; @@ -22,6 +24,14 @@ import { SiemPageName } from '../../../home/types'; jest.mock( '../../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks/use_form' ); +jest.mock('../../../../containers/case/use_get_tags'); +jest.mock( + '../../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib/components/form_data_provider', + () => ({ + FormDataProvider: ({ children }: { children: ({ tags }: { tags: string[] }) => void }) => + children({ tags: ['rad', 'dude'] }), + }) +); export const useFormMock = useForm as jest.Mock; @@ -40,9 +50,11 @@ const defaultInsertTimeline = { handleCursorChange, handleOnTimelineChange, }; + +const sampleTags = ['coke', 'pepsi']; const sampleData = { description: 'what a great description', - tags: ['coke', 'pepsi'], + tags: sampleTags, title: 'what a cool title', }; const defaultPostCase = { @@ -52,14 +64,28 @@ const defaultPostCase = { postCase, }; describe('Create case', () => { + // Suppress warnings about "noSuggestions" prop + /* eslint-disable no-console */ + const originalError = console.error; + beforeAll(() => { + console.error = jest.fn(); + }); + afterAll(() => { + console.error = originalError; + }); + /* eslint-enable no-console */ + const fetchTags = jest.fn(); const formHookMock = getFormMock(sampleData); - beforeEach(() => { jest.resetAllMocks(); useInsertTimelineMock.mockImplementation(() => defaultInsertTimeline); usePostCaseMock.mockImplementation(() => defaultPostCase); useFormMock.mockImplementation(() => ({ form: formHookMock })); jest.spyOn(routeData, 'useLocation').mockReturnValue(mockLocation); + (useGetTags as jest.Mock).mockImplementation(() => ({ + tags: sampleTags, + fetchTags, + })); }); it('should post case on submit click', async () => { @@ -118,4 +144,19 @@ describe('Create case', () => { ); expect(wrapper.find(`[data-test-subj="create-case-loading-spinner"]`).exists()).toBeTruthy(); }); + it('Tag options render with new tags added', () => { + const wrapper = mount( + + + + + + ); + expect( + wrapper + .find(`[data-test-subj="caseTags"] [data-test-subj="input"]`) + .first() + .prop('options') + ).toEqual([{ label: 'coke' }, { label: 'pepsi' }, { label: 'rad' }, { label: 'dude' }]); + }); }); diff --git a/x-pack/legacy/plugins/siem/public/pages/case/components/create/index.tsx b/x-pack/legacy/plugins/siem/public/pages/case/components/create/index.tsx index 53b792bb9b5eb..0f819f961b396 100644 --- a/x-pack/legacy/plugins/siem/public/pages/case/components/create/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/case/components/create/index.tsx @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React, { useCallback, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { EuiButton, EuiButtonEmpty, @@ -15,8 +15,16 @@ import { import styled, { css } from 'styled-components'; import { Redirect } from 'react-router-dom'; +import { isEqual } from 'lodash/fp'; import { CasePostRequest } from '../../../../../../../../plugins/case/common/api'; -import { Field, Form, getUseField, useForm, UseField } from '../../../../shared_imports'; +import { + Field, + Form, + getUseField, + useForm, + UseField, + FormDataProvider, +} from '../../../../shared_imports'; import { usePostCase } from '../../../../containers/case/use_post_case'; import { schema } from './schema'; import { InsertTimelinePopover } from '../../../../components/timeline/insert_timeline_popover'; @@ -24,6 +32,7 @@ import { useInsertTimeline } from '../../../../components/timeline/insert_timeli import * as i18n from '../../translations'; import { SiemPageName } from '../../../home/types'; import { MarkdownEditorForm } from '../../../../components/markdown_editor/form'; +import { useGetTags } from '../../../../containers/case/use_get_tags'; export const CommonUseField = getUseField({ component: Field }); @@ -59,6 +68,21 @@ export const Create = React.memo(() => { options: { stripEmptyFields: false }, schema, }); + const { tags: tagOptions } = useGetTags(); + const [options, setOptions] = useState( + tagOptions.map(label => ({ + label, + })) + ); + useEffect( + () => + setOptions( + tagOptions.map(label => ({ + label, + })) + ), + [tagOptions] + ); const { handleCursorChange, handleOnTimelineChange } = useInsertTimeline( form, 'description' @@ -108,6 +132,8 @@ export const Create = React.memo(() => { fullWidth: true, placeholder: '', disabled: isLoading, + options, + noSuggestions: false, }, }} /> @@ -131,6 +157,25 @@ export const Create = React.memo(() => { }} /> + + {({ tags: anotherTags }) => { + const current: string[] = options.map(opt => opt.label); + const newOptions = anotherTags.reduce((acc: string[], item: string) => { + if (!acc.includes(item)) { + return [...acc, item]; + } + return acc; + }, current); + if (!isEqual(current, newOptions)) { + setOptions( + newOptions.map((label: string) => ({ + label, + })) + ); + } + return null; + }} + ({ + FormDataProvider: ({ children }: { children: ({ tags }: { tags: string[] }) => void }) => + children({ tags: ['rad', 'dude'] }), + }) +); const onSubmit = jest.fn(); const defaultProps = { disabled: false, @@ -26,11 +35,27 @@ const defaultProps = { }; describe('TagList ', () => { + // Suppress warnings about "noSuggestions" prop + /* eslint-disable no-console */ + const originalError = console.error; + beforeAll(() => { + console.error = jest.fn(); + }); + afterAll(() => { + console.error = originalError; + }); + /* eslint-enable no-console */ const sampleTags = ['coke', 'pepsi']; + const fetchTags = jest.fn(); const formHookMock = getFormMock({ tags: sampleTags }); beforeEach(() => { jest.resetAllMocks(); (useForm as jest.Mock).mockImplementation(() => ({ form: formHookMock })); + + (useGetTags as jest.Mock).mockImplementation(() => ({ + tags: sampleTags, + fetchTags, + })); }); it('Renders no tags, and then edit', () => { const wrapper = mount( @@ -80,6 +105,23 @@ describe('TagList ', () => { expect(onSubmit).toBeCalledWith(sampleTags); }); }); + it('Tag options render with new tags added', () => { + const wrapper = mount( + + + + ); + wrapper + .find(`[data-test-subj="tag-list-edit-button"]`) + .last() + .simulate('click'); + expect( + wrapper + .find(`[data-test-subj="caseTags"] [data-test-subj="input"]`) + .first() + .prop('options') + ).toEqual([{ label: 'coke' }, { label: 'pepsi' }, { label: 'rad' }, { label: 'dude' }]); + }); it('Cancels on cancel', async () => { const props = { ...defaultProps, diff --git a/x-pack/legacy/plugins/siem/public/pages/case/components/tag_list/index.tsx b/x-pack/legacy/plugins/siem/public/pages/case/components/tag_list/index.tsx index 9bac000b93235..c96ae09706426 100644 --- a/x-pack/legacy/plugins/siem/public/pages/case/components/tag_list/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/case/components/tag_list/index.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useCallback, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { EuiText, EuiHorizontalRule, @@ -17,10 +17,12 @@ import { EuiLoadingSpinner, } from '@elastic/eui'; import styled, { css } from 'styled-components'; +import { isEqual } from 'lodash/fp'; import * as i18n from './translations'; -import { Form, useForm } from '../../../../shared_imports'; +import { Form, FormDataProvider, useForm } from '../../../../shared_imports'; import { schema } from './schema'; import { CommonUseField } from '../create'; +import { useGetTags } from '../../../../containers/case/use_get_tags'; interface TagListProps { disabled?: boolean; @@ -54,6 +56,22 @@ export const TagList = React.memo( setIsEditTags(false); } }, [form, onSubmit]); + const { tags: tagOptions } = useGetTags(); + const [options, setOptions] = useState( + tagOptions.map(label => ({ + label, + })) + ); + + useEffect( + () => + setOptions( + tagOptions.map(label => ({ + label, + })) + ), + [tagOptions] + ); return ( @@ -75,7 +93,7 @@ export const TagList = React.memo( )} - + {tags.length === 0 && !isEditTags &&

{i18n.NO_TAGS}

} {tags.length > 0 && !isEditTags && @@ -98,9 +116,30 @@ export const TagList = React.memo( euiFieldProps: { fullWidth: true, placeholder: '', + options, + noSuggestions: false, }, }} /> + + {({ tags: anotherTags }) => { + const current: string[] = options.map(opt => opt.label); + const newOptions = anotherTags.reduce((acc: string[], item: string) => { + if (!acc.includes(item)) { + return [...acc, item]; + } + return acc; + }, current); + if (!isEqual(current, newOptions)) { + setOptions( + newOptions.map((label: string) => ({ + label, + })) + ); + } + return null; + }} +
diff --git a/x-pack/legacy/plugins/siem/public/pages/case/components/user_action_tree/index.test.tsx b/x-pack/legacy/plugins/siem/public/pages/case/components/user_action_tree/index.test.tsx index 1c71260422d4b..ff402e8ea1c8b 100644 --- a/x-pack/legacy/plugins/siem/public/pages/case/components/user_action_tree/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/case/components/user_action_tree/index.test.tsx @@ -8,17 +8,13 @@ import React from 'react'; import { mount } from 'enzyme'; import { Router, routeData, mockHistory, mockLocation } from '../__mock__/router'; -import { getFormMock } from '../__mock__/form'; +import { getFormMock, useFormMock } from '../__mock__/form'; import { useUpdateComment } from '../../../../containers/case/use_update_comment'; import { basicCase, getUserAction } from '../../../../containers/case/mock'; import { UserActionTree } from './'; import { TestProviders } from '../../../../mock'; -import { useFormMock } from '../create/index.test'; import { wait } from '../../../../lib/helpers'; import { act } from 'react-dom/test-utils'; -jest.mock( - '../../../../../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks/use_form' -); const fetchUserActions = jest.fn(); const onUpdateField = jest.fn(); diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/signals_utility_bar/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/signals_utility_bar/index.tsx index 2000a699ab18d..847fcc7860085 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/signals_utility_bar/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals/signals_utility_bar/index.tsx @@ -7,6 +7,8 @@ import { isEmpty } from 'lodash/fp'; import React, { useCallback } from 'react'; import numeral from '@elastic/numeral'; + +import { DEFAULT_NUMBER_FORMAT } from '../../../../../../../../../plugins/siem/common/constants'; import { UtilityBar, UtilityBarAction, @@ -16,7 +18,6 @@ import { } from '../../../../../components/utility_bar'; import * as i18n from './translations'; import { useUiSetting$ } from '../../../../../lib/kibana'; -import { DEFAULT_NUMBER_FORMAT } from '../../../../../../common/constants'; import { TimelineNonEcsData } from '../../../../../graphql/types'; import { UpdateSignalsStatus } from '../types'; import { FILTER_CLOSED, FILTER_OPEN } from '../signals_filter_group'; diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.tsx index 27ee552146092..90bdd39e4a6fa 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/helpers.tsx @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { showAllOthersBucket } from '../../../../../../../../plugins/siem/common/constants'; import { HistogramData, SignalsAggregation, SignalsBucket, SignalsGroupBucket } from './types'; import { SignalSearchResponse } from '../../../../containers/detection_engine/signals/types'; import * as i18n from './translations'; @@ -34,48 +35,56 @@ export const getSignalsHistogramQuery = ( additionalFilters: Array<{ bool: { filter: unknown[]; should: unknown[]; must_not: unknown[]; must: unknown[] }; }> -) => ({ - aggs: { - signalsByGrouping: { - terms: { - field: stackByField, +) => { + const missing = showAllOthersBucket.includes(stackByField) + ? { missing: stackByField.endsWith('.ip') ? '0.0.0.0' : i18n.ALL_OTHERS, - order: { - _count: 'desc', + } + : {}; + + return { + aggs: { + signalsByGrouping: { + terms: { + field: stackByField, + ...missing, + order: { + _count: 'desc', + }, + size: 10, }, - size: 10, - }, - aggs: { - signals: { - date_histogram: { - field: '@timestamp', - fixed_interval: `${Math.floor((to - from) / 32)}ms`, - min_doc_count: 0, - extended_bounds: { - min: from, - max: to, + aggs: { + signals: { + date_histogram: { + field: '@timestamp', + fixed_interval: `${Math.floor((to - from) / 32)}ms`, + min_doc_count: 0, + extended_bounds: { + min: from, + max: to, + }, }, }, }, }, }, - }, - query: { - bool: { - filter: [ - ...additionalFilters, - { - range: { - '@timestamp': { - gte: from, - lte: to, + query: { + bool: { + filter: [ + ...additionalFilters, + { + range: { + '@timestamp': { + gte: from, + lte: to, + }, }, }, - }, - ], + ], + }, }, - }, -}); + }; +}; /** * Returns `true` when the signals histogram initial loading spinner should be shown diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/index.tsx index e25442b31da4e..e70ba804ec018 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/index.tsx @@ -9,16 +9,20 @@ import numeral from '@elastic/numeral'; import React, { memo, useCallback, useMemo, useState, useEffect } from 'react'; import styled from 'styled-components'; import { isEmpty } from 'lodash/fp'; +import uuid from 'uuid'; +import { DEFAULT_NUMBER_FORMAT } from '../../../../../../../../plugins/siem/common/constants'; +import { LegendItem } from '../../../../components/charts/draggable_legend_item'; +import { escapeDataProviderId } from '../../../../components/drag_and_drop/helpers'; import { HeaderSection } from '../../../../components/header_section'; - import { Filter, esQuery, Query } from '../../../../../../../../../src/plugins/data/public'; -import { DEFAULT_NUMBER_FORMAT } from '../../../../../common/constants'; import { useQuerySignals } from '../../../../containers/detection_engine/signals/use_query'; import { getDetectionEngineUrl } from '../../../../components/link_to'; +import { defaultLegendColors } from '../../../../components/matrix_histogram/utils'; import { InspectButtonContainer } from '../../../../components/inspect'; import { useGetUrlSearch } from '../../../../components/navigation/use_get_url_search'; import { MatrixLoader } from '../../../../components/matrix_histogram/matrix_loader'; +import { MatrixHistogramOption } from '../../../../components/matrix_histogram/types'; import { useKibana, useUiSetting$ } from '../../../../lib/kibana'; import { navTabs } from '../../../home/home_navigations'; import { signalsHistogramOptions } from './config'; @@ -53,6 +57,9 @@ interface SignalsHistogramPanelProps { deleteQuery?: ({ id }: { id: string }) => void; filters?: Filter[]; from: number; + headerChildren?: React.ReactNode; + /** Override all defaults, and only display this field */ + onlyField?: string; query?: Query; legendPosition?: Position; panelHeight?: number; @@ -66,12 +73,21 @@ interface SignalsHistogramPanelProps { updateDateRange: (min: number, max: number) => void; } +const getHistogramOption = (fieldName: string): MatrixHistogramOption => ({ + text: fieldName, + value: fieldName, +}); + +const NO_LEGEND_DATA: LegendItem[] = []; + export const SignalsHistogramPanel = memo( ({ chartHeight, defaultStackByOption = signalsHistogramOptions[0], deleteQuery, filters, + headerChildren, + onlyField, query, from, legendPosition = 'right', @@ -85,11 +101,13 @@ export const SignalsHistogramPanel = memo( title = i18n.HISTOGRAM_HEADER, updateDateRange, }) => { + // create a unique, but stable (across re-renders) query id + const uniqueQueryId = useMemo(() => `${DETECTIONS_HISTOGRAM_ID}-${uuid.v4()}`, []); const [isInitialLoading, setIsInitialLoading] = useState(true); const [defaultNumberFormat] = useUiSetting$(DEFAULT_NUMBER_FORMAT); const [totalSignalsObj, setTotalSignalsObj] = useState(defaultTotalSignalsObj); const [selectedStackByOption, setSelectedStackByOption] = useState( - defaultStackByOption + onlyField == null ? defaultStackByOption : getHistogramOption(onlyField) ); const { loading: isLoadingSignals, @@ -123,6 +141,21 @@ export const SignalsHistogramPanel = memo( const formattedSignalsData = useMemo(() => formatSignalsData(signalsData), [signalsData]); + const legendItems: LegendItem[] = useMemo( + () => + signalsData?.aggregations?.signalsByGrouping?.buckets != null + ? signalsData.aggregations.signalsByGrouping.buckets.map((bucket, i) => ({ + color: i < defaultLegendColors.length ? defaultLegendColors[i] : undefined, + dataProviderId: escapeDataProviderId( + `draggable-legend-item-${uuid.v4()}-${selectedStackByOption.value}-${bucket.key}` + ), + field: selectedStackByOption.value, + value: bucket.key, + })) + : NO_LEGEND_DATA, + [signalsData, selectedStackByOption.value] + ); + useEffect(() => { let canceled = false; @@ -138,7 +171,7 @@ export const SignalsHistogramPanel = memo( useEffect(() => { return () => { if (deleteQuery) { - deleteQuery({ id: DETECTIONS_HISTOGRAM_ID }); + deleteQuery({ id: uniqueQueryId }); } }; }, []); @@ -146,7 +179,7 @@ export const SignalsHistogramPanel = memo( useEffect(() => { if (refetch != null && setQuery != null) { setQuery({ - id: DETECTIONS_HISTOGRAM_ID, + id: uniqueQueryId, inspect: { dsl: [request], response: [response], @@ -197,46 +230,49 @@ export const SignalsHistogramPanel = memo( } }, [showLinkToSignals, urlSearch]); + const titleText = useMemo(() => (onlyField == null ? title : i18n.TOP(onlyField)), [ + onlyField, + title, + ]); + return ( - + + + + + {stackByOptions && ( + + )} + {headerChildren != null && headerChildren} + + {linkButton} + + + {isInitialLoading ? ( - <> - - - + ) : ( - <> - - - - {stackByOptions && ( - - )} - - {linkButton} - - - - - + )} diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/signals_histogram.test.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/signals_histogram.test.tsx index 5eb9beaaaf76a..6a116efb8f2f8 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/signals_histogram.test.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/signals_histogram.test.tsx @@ -14,7 +14,14 @@ jest.mock('../../../../lib/kibana'); describe('SignalsHistogram', () => { it('renders correctly', () => { const wrapper = shallow( - + ); expect(wrapper.find('Chart')).toBeTruthy(); diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/signals_histogram.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/signals_histogram.tsx index 40e5b8abde072..4bb7e9f6e122f 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/signals_histogram.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/signals_histogram.tsx @@ -12,11 +12,14 @@ import { Settings, ChartSizeArray, } from '@elastic/charts'; +import { EuiFlexGroup, EuiFlexItem, EuiProgress } from '@elastic/eui'; import React, { useMemo } from 'react'; -import { EuiProgress } from '@elastic/eui'; import { useTheme } from '../../../../components/charts/common'; import { histogramDateTimeFormatter } from '../../../../components/utils'; +import { DraggableLegend } from '../../../../components/charts/draggable_legend'; +import { LegendItem } from '../../../../components/charts/draggable_legend_item'; + import { HistogramData } from './types'; const DEFAULT_CHART_HEIGHT = 174; @@ -24,18 +27,19 @@ const DEFAULT_CHART_HEIGHT = 174; interface HistogramSignalsProps { chartHeight?: number; from: number; + legendItems: LegendItem[]; legendPosition?: Position; loading: boolean; to: number; data: HistogramData[]; updateDateRange: (min: number, max: number) => void; } - export const SignalsHistogram = React.memo( ({ chartHeight = DEFAULT_CHART_HEIGHT, data, from, + legendItems, legendPosition = 'right', loading, to, @@ -62,29 +66,38 @@ export const SignalsHistogram = React.memo( /> )} - - + + + + - + - + - - + + + + + {legendItems.length > 0 && ( + + )} + + ); } diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/translations.ts b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/translations.ts index 8c88fa4a5dae6..e7b76a48c7592 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/translations.ts +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/components/signals_histogram_panel/translations.ts @@ -83,6 +83,12 @@ export const STACK_BY_USERS = i18n.translate( } ); +export const TOP = (fieldName: string) => + i18n.translate('xpack.siem.detectionEngine.signals.histogram.topNLabel', { + values: { fieldName }, + defaultMessage: `Top {fieldName}`, + }); + export const HISTOGRAM_HEADER = i18n.translate( 'xpack.siem.detectionEngine.signals.histogram.headerTitle', { diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/columns.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/columns.tsx index 80e644f800334..97c89f91c12bd 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/columns.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/columns.tsx @@ -19,6 +19,7 @@ import { FormattedRelative } from '@kbn/i18n/react'; import * as H from 'history'; import React, { Dispatch } from 'react'; +import { isMlRule } from '../../../../../../../../plugins/siem/common/detection_engine/ml_helpers'; import { Rule, RuleStatus } from '../../../../containers/detection_engine/rules'; import { getEmptyTagValue } from '../../../../components/empty_value'; import { FormattedDate } from '../../../../components/formatted_date'; @@ -38,7 +39,6 @@ import { import { Action } from './reducer'; import { LocalizedDateTooltip } from '../../../../components/localized_date_tooltip'; import * as detectionI18n from '../../translations'; -import { isMlRule } from '../../../../../common/detection_engine/ml_helpers'; export const getActions = ( dispatch: React.Dispatch, @@ -243,7 +243,7 @@ export const getMonitoringColumns = (): RulesStatusesColumns[] => { {value != null && value.length > 0 ? Math.max(...value?.map(item => Number.parseFloat(item))) - : null} + : getEmptyTagValue()} ), truncateText: true, @@ -256,7 +256,7 @@ export const getMonitoringColumns = (): RulesStatusesColumns[] => { {value != null && value.length > 0 ? Math.max(...value?.map(item => Number.parseFloat(item))) - : null} + : getEmptyTagValue()} ), truncateText: true, @@ -267,7 +267,7 @@ export const getMonitoringColumns = (): RulesStatusesColumns[] => { name: i18n.COLUMN_GAP, render: (value: RuleStatus['current_status']['gap']) => ( - {value} + {value ?? getEmptyTagValue()} ), truncateText: true, diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.test.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.test.tsx index f4955c2a93b8d..59b3b02ff3587 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.test.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.test.tsx @@ -5,10 +5,138 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow, mount } from 'enzyme'; +import { act } from 'react-dom/test-utils'; +import { createKibanaContextProviderMock } from '../../../../mock/kibana_react'; +import { TestProviders } from '../../../../mock'; +import { wait } from '../../../../lib/helpers'; import { AllRules } from './index'; +jest.mock('./reducer', () => { + return { + allRulesReducer: jest.fn().mockReturnValue(() => ({ + exportRuleIds: [], + filterOptions: { + filter: 'some filter', + sortField: 'some sort field', + sortOrder: 'desc', + }, + loadingRuleIds: [], + loadingRulesAction: null, + pagination: { + page: 1, + perPage: 20, + total: 1, + }, + rules: [ + { + actions: [], + created_at: '2020-02-14T19:49:28.178Z', + created_by: 'elastic', + description: 'jibber jabber', + enabled: false, + false_positives: [], + filters: [], + from: 'now-660s', + id: 'rule-id-1', + immutable: true, + index: ['endgame-*'], + interval: '10m', + language: 'kuery', + max_signals: 100, + name: 'Credential Dumping - Detected - Elastic Endpoint', + output_index: '.siem-signals-default', + query: 'host.name:*', + references: [], + risk_score: 73, + rule_id: '571afc56-5ed9-465d-a2a9-045f099f6e7e', + severity: 'high', + tags: ['Elastic', 'Endpoint'], + threat: [], + throttle: null, + to: 'now', + type: 'query', + updated_at: '2020-02-14T19:49:28.320Z', + updated_by: 'elastic', + version: 1, + }, + ], + selectedRuleIds: [], + })), + }; +}); + +jest.mock('../../../../containers/detection_engine/rules', () => { + return { + useRules: jest.fn().mockReturnValue([ + false, + { + page: 1, + perPage: 20, + total: 1, + data: [ + { + actions: [], + created_at: '2020-02-14T19:49:28.178Z', + created_by: 'elastic', + description: 'jibber jabber', + enabled: false, + false_positives: [], + filters: [], + from: 'now-660s', + id: 'rule-id-1', + immutable: true, + index: ['endgame-*'], + interval: '10m', + language: 'kuery', + max_signals: 100, + name: 'Credential Dumping - Detected - Elastic Endpoint', + output_index: '.siem-signals-default', + query: 'host.name:*', + references: [], + risk_score: 73, + rule_id: '571afc56-5ed9-465d-a2a9-045f099f6e7e', + severity: 'high', + tags: ['Elastic', 'Endpoint'], + threat: [], + throttle: null, + to: 'now', + type: 'query', + updated_at: '2020-02-14T19:49:28.320Z', + updated_by: 'elastic', + version: 1, + }, + ], + }, + ]), + useRulesStatuses: jest.fn().mockReturnValue({ + loading: false, + rulesStatuses: [ + { + current_status: { + alert_id: 'alertId', + bulk_create_time_durations: ['2235.01'], + gap: null, + last_failure_at: null, + last_failure_message: null, + last_look_back_date: new Date().toISOString(), + last_success_at: new Date().toISOString(), + last_success_message: 'it is a success', + search_after_time_durations: ['616.97'], + status: 'succeeded', + status_date: new Date().toISOString(), + }, + failures: [], + id: '12345678987654321', + activate: true, + name: 'Test rule', + }, + ], + }), + }; +}); + jest.mock('react-router-dom', () => { const originalModule = jest.requireActual('react-router-dom'); @@ -37,4 +165,66 @@ describe('AllRules', () => { expect(wrapper.find('[title="All rules"]')).toHaveLength(1); }); + + it('renders rules tab', async () => { + const KibanaContext = createKibanaContextProviderMock(); + const wrapper = mount( + + + + + + ); + + await act(async () => { + await wait(); + + expect(wrapper.exists('[data-test-subj="monitoring-table"]')).toBeFalsy(); + expect(wrapper.exists('[data-test-subj="rules-table"]')).toBeTruthy(); + }); + }); + + it('renders monitoring tab when monitoring tab clicked', async () => { + const KibanaContext = createKibanaContextProviderMock(); + + const wrapper = mount( + + + + + + ); + const monitoringTab = wrapper.find('[data-test-subj="allRulesTableTab-monitoring"] button'); + monitoringTab.simulate('click'); + + await act(async () => { + wrapper.update(); + await wait(); + + expect(wrapper.exists('[data-test-subj="monitoring-table"]')).toBeTruthy(); + expect(wrapper.exists('[data-test-subj="rules-table"]')).toBeFalsy(); + }); + }); }); diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx index e96ed856208bd..18ca4d42bd018 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/all/index.tsx @@ -4,7 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiBasicTable, EuiContextMenuPanel, EuiLoadingContent, EuiSpacer } from '@elastic/eui'; +import { + EuiBasicTable, + EuiContextMenuPanel, + EuiLoadingContent, + EuiSpacer, + EuiTab, + EuiTabs, +} from '@elastic/eui'; import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'; import { useHistory } from 'react-router-dom'; import uuid from 'uuid'; @@ -75,6 +82,24 @@ interface AllRulesProps { setRefreshRulesData: (refreshRule: (refreshPrePackagedRule?: boolean) => void) => void; } +export enum AllRulesTabs { + rules = 'rules', + monitoring = 'monitoring', +} + +const allRulesTabs = [ + { + id: AllRulesTabs.rules, + name: i18n.RULES_TAB, + disabled: false, + }, + { + id: AllRulesTabs.monitoring, + name: i18n.MONITORING_TAB, + disabled: false, + }, +]; + /** * Table Component for displaying all Rules for a given cluster. Provides the ability to filter * by name, sort by enabled, and perform the following actions: @@ -114,6 +139,7 @@ export const AllRules = React.memo( const history = useHistory(); const [, dispatchToaster] = useStateToaster(); const mlCapabilities = useMlCapabilities(); + const [allRulesTab, setAllRulesTab] = useState(AllRulesTabs.rules); // TODO: Refactor license check + hasMlAdminPermissions to common check const hasMlPermissions = @@ -271,6 +297,25 @@ export const AllRules = React.memo( return false; }, [loadingRuleIds, loadingRulesAction]); + const tabs = useMemo( + () => ( + + {allRulesTabs.map(tab => ( + setAllRulesTab(tab.id)} + isSelected={tab.id === allRulesTab} + disabled={tab.disabled} + key={tab.id} + > + {tab.name} + + ))} + + ), + [allRulesTabs, allRulesTab, setAllRulesTab] + ); + return ( <> ( exportSelectedData={exportRules} /> + {tabs} + <> @@ -321,7 +368,7 @@ export const AllRules = React.memo( )} {showRulesTable({ rulesCustomInstalled, rulesInstalled }) && !initLoading && ( <> - + @@ -352,6 +399,7 @@ export const AllRules = React.memo( { it('renders correctly', () => { @@ -16,6 +17,7 @@ describe('AllRulesTables', () => { return ( { expect(wrapper.dive().find('[data-test-subj="rules-table"]')).toHaveLength(1); }); + + it('renders rules tab when "selectedTab" is "rules"', () => { + const Component = () => { + const ref = useRef(); + + return ( + + ); + }; + const wrapper = shallow(); + + expect(wrapper.dive().find('[data-test-subj="rules-table"]')).toHaveLength(1); + expect(wrapper.dive().find('[data-test-subj="monitoring-table"]')).toHaveLength(0); + }); + + it('renders monitoring tab when "selectedTab" is "monitoring"', () => { + const Component = () => { + const ref = useRef(); + + return ( + + ); + }; + const wrapper = shallow(); + + expect(wrapper.dive().find('[data-test-subj="rules-table"]')).toHaveLength(0); + expect(wrapper.dive().find('[data-test-subj="monitoring-table"]')).toHaveLength(1); + }); }); diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/all_rules_tables/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/all_rules_tables/index.tsx index 31aaa426e4f3b..8ea5606d0082c 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/all_rules_tables/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/all_rules_tables/index.tsx @@ -7,13 +7,11 @@ import { EuiBasicTable, EuiBasicTableColumn, - EuiTab, - EuiTabs, EuiEmptyPrompt, Direction, EuiTableSelectionType, } from '@elastic/eui'; -import React, { useMemo, memo, useState } from 'react'; +import React, { useMemo, memo } from 'react'; import styled from 'styled-components'; import { EuiBasicTableOnChange } from '../../types'; @@ -23,6 +21,7 @@ import { RuleStatusRowItemType, } from '../../../../../pages/detection_engine/rules/all/columns'; import { Rule, Rules } from '../../../../../containers/detection_engine/rules'; +import { AllRulesTabs } from '../../all'; // EuiBasicTable give me a hardtime with adding the ref attributes so I went the easy way // after few hours of fight with typescript !!!! I lost :( @@ -57,27 +56,10 @@ interface AllRulesTablesProps { }; tableOnChangeCallback: ({ page, sort }: EuiBasicTableOnChange) => void; tableRef?: React.MutableRefObject; + selectedTab: AllRulesTabs; } -enum AllRulesTabs { - rules = 'rules', - monitoring = 'monitoring', -} - -const allRulesTabs = [ - { - id: AllRulesTabs.rules, - name: i18n.RULES_TAB, - disabled: false, - }, - { - id: AllRulesTabs.monitoring, - name: i18n.MONITORING_TAB, - disabled: false, - }, -]; - -const AllRulesTablesComponent: React.FC = ({ +export const AllRulesTablesComponent: React.FC = ({ euiBasicTableSelectionProps, hasNoPermissions, monitoringColumns, @@ -88,34 +70,17 @@ const AllRulesTablesComponent: React.FC = ({ sorting, tableOnChangeCallback, tableRef, + selectedTab, }) => { - const [allRulesTab, setAllRulesTab] = useState(AllRulesTabs.rules); const emptyPrompt = useMemo(() => { return ( {i18n.NO_RULES}} titleSize="xs" body={i18n.NO_RULES_BODY} /> ); }, []); - const tabs = useMemo( - () => ( - - {allRulesTabs.map(tab => ( - setAllRulesTab(tab.id)} - isSelected={tab.id === allRulesTab} - disabled={tab.disabled} - key={tab.id} - > - {tab.name} - - ))} - - ), - [allRulesTabs, allRulesTab, setAllRulesTab] - ); + return ( <> - {tabs} - {allRulesTab === AllRulesTabs.rules && ( + {selectedTab === AllRulesTabs.rules && ( = ({ selection={hasNoPermissions ? undefined : euiBasicTableSelectionProps} /> )} - {allRulesTab === AllRulesTabs.monitoring && ( + {selectedTab === AllRulesTabs.monitoring && ( { ); }); - test('it does NOT render the subtitle', () => { - expect(wrapper.find('[data-test-subj="header-panel-subtitle"]').exists()).toBe(false); + test('it renders the subtitle (to prevent layout thrashing)', () => { + expect(wrapper.find('[data-test-subj="header-panel-subtitle"]').exists()).toBe(true); }); test('it renders the expected filter fields', () => { diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/alerts_by_category/index.tsx b/x-pack/legacy/plugins/siem/public/pages/overview/alerts_by_category/index.tsx index 744102fbac4b3..8e09572cb2796 100644 --- a/x-pack/legacy/plugins/siem/public/pages/overview/alerts_by_category/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/overview/alerts_by_category/index.tsx @@ -7,9 +7,9 @@ import { EuiButton } from '@elastic/eui'; import numeral from '@elastic/numeral'; import React, { useEffect, useMemo } from 'react'; - import { Position } from '@elastic/charts'; -import { DEFAULT_NUMBER_FORMAT } from '../../../../common/constants'; + +import { DEFAULT_NUMBER_FORMAT } from '../../../../../../../plugins/siem/common/constants'; import { SHOWING, UNIT } from '../../../components/alerts_viewer/translations'; import { getDetectionEngineAlertUrl } from '../../../components/link_to/redirect_to_detection_engine'; import { MatrixHistogramContainer } from '../../../components/matrix_histogram'; diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/events_by_dataset/__mocks__/index.tsx b/x-pack/legacy/plugins/siem/public/pages/overview/events_by_dataset/__mocks__/index.tsx new file mode 100644 index 0000000000000..dad1e0034b4e2 --- /dev/null +++ b/x-pack/legacy/plugins/siem/public/pages/overview/events_by_dataset/__mocks__/index.tsx @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const EventsByDataset = () => 'mock EventsByDataset'; diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/events_by_dataset/index.tsx b/x-pack/legacy/plugins/siem/public/pages/overview/events_by_dataset/index.tsx index cc1f9b1cc5681..14cc29adb505a 100644 --- a/x-pack/legacy/plugins/siem/public/pages/overview/events_by_dataset/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/overview/events_by_dataset/index.tsx @@ -4,18 +4,26 @@ * you may not use this file except in compliance with the Elastic License. */ +import { Position } from '@elastic/charts'; import { EuiButton } from '@elastic/eui'; import numeral from '@elastic/numeral'; import React, { useEffect, useMemo } from 'react'; +import uuid from 'uuid'; -import { Position } from '@elastic/charts'; +import { DEFAULT_NUMBER_FORMAT } from '../../../../../../../plugins/siem/common/constants'; import { SHOWING, UNIT } from '../../../components/events_viewer/translations'; -import { convertToBuildEsQuery } from '../../../lib/keury'; import { getTabsOnHostsUrl } from '../../../components/link_to/redirect_to_hosts'; -import { histogramConfigs } from '../../../pages/hosts/navigation/events_query_tab_body'; import { MatrixHistogramContainer } from '../../../components/matrix_histogram'; +import { + MatrixHisrogramConfigs, + MatrixHistogramOption, +} from '../../../components/matrix_histogram/types'; +import { useGetUrlSearch } from '../../../components/navigation/use_get_url_search'; +import { navTabs } from '../../home/home_navigations'; import { eventsStackByOptions } from '../../hosts/navigation'; +import { convertToBuildEsQuery } from '../../../lib/keury'; import { useKibana, useUiSetting$ } from '../../../lib/kibana'; +import { histogramConfigs } from '../../../pages/hosts/navigation/events_query_tab_body'; import { Filter, esQuery, @@ -24,12 +32,9 @@ import { } from '../../../../../../../../src/plugins/data/public'; import { inputsModel } from '../../../store'; import { HostsTableType, HostsType } from '../../../store/hosts/model'; -import { DEFAULT_NUMBER_FORMAT } from '../../../../common/constants'; +import { InputsModelId } from '../../../store/inputs/constants'; import * as i18n from '../translations'; -import { MatrixHisrogramConfigs } from '../../../components/matrix_histogram/types'; -import { useGetUrlSearch } from '../../../components/navigation/use_get_url_search'; -import { navTabs } from '../../home/home_navigations'; const NO_FILTERS: Filter[] = []; const DEFAULT_QUERY: Query = { query: '', language: 'kuery' }; @@ -38,36 +43,56 @@ const DEFAULT_STACK_BY = 'event.dataset'; const ID = 'eventsByDatasetOverview'; interface Props { + combinedQueries?: string; deleteQuery?: ({ id }: { id: string }) => void; filters?: Filter[]; from: number; + headerChildren?: React.ReactNode; indexPattern: IIndexPattern; + indexToAdd?: string[] | null; + onlyField?: string; query?: Query; + setAbsoluteRangeDatePickerTarget?: InputsModelId; setQuery: (params: { id: string; inspect: inputsModel.InspectQuery | null; loading: boolean; refetch: inputsModel.Refetch; }) => void; + showSpacer?: boolean; to: number; } +const getHistogramOption = (fieldName: string): MatrixHistogramOption => ({ + text: fieldName, + value: fieldName, +}); + const EventsByDatasetComponent: React.FC = ({ + combinedQueries, deleteQuery, filters = NO_FILTERS, from, + headerChildren, indexPattern, + indexToAdd, + onlyField, query = DEFAULT_QUERY, + setAbsoluteRangeDatePickerTarget, setQuery, + showSpacer = true, to, }) => { + // create a unique, but stable (across re-renders) query id + const uniqueQueryId = useMemo(() => `${ID}-${uuid.v4()}`, []); + useEffect(() => { return () => { if (deleteQuery) { - deleteQuery({ id: ID }); + deleteQuery({ id: uniqueQueryId }); } }; - }, [deleteQuery]); + }, [deleteQuery, uniqueQueryId]); const kibana = useKibana(); const [defaultNumberFormat] = useUiSetting$(DEFAULT_NUMBER_FORMAT); @@ -84,38 +109,62 @@ const EventsByDatasetComponent: React.FC = ({ const filterQuery = useMemo( () => - convertToBuildEsQuery({ - config: esQuery.getEsQueryConfig(kibana.services.uiSettings), - indexPattern, - queries: [query], - filters, - }), - [kibana, indexPattern, query, filters] + combinedQueries == null + ? convertToBuildEsQuery({ + config: esQuery.getEsQueryConfig(kibana.services.uiSettings), + indexPattern, + queries: [query], + filters, + }) + : combinedQueries, + [combinedQueries, kibana, indexPattern, query, filters] ); const eventsByDatasetHistogramConfigs: MatrixHisrogramConfigs = useMemo( () => ({ ...histogramConfigs, + stackByOptions: + onlyField != null ? [getHistogramOption(onlyField)] : histogramConfigs.stackByOptions, defaultStackByOption: - eventsStackByOptions.find(o => o.text === DEFAULT_STACK_BY) ?? eventsStackByOptions[0], + onlyField != null + ? getHistogramOption(onlyField) + : eventsStackByOptions.find(o => o.text === DEFAULT_STACK_BY) ?? eventsStackByOptions[0], legendPosition: Position.Right, subtitle: (totalCount: number) => `${SHOWING}: ${numeral(totalCount).format(defaultNumberFormat)} ${UNIT(totalCount)}`, + titleSize: onlyField == null ? 'm' : 's', }), - [] + [onlyField, defaultNumberFormat] ); + const headerContent = useMemo(() => { + if (onlyField == null || headerChildren != null) { + return ( + <> + {headerChildren} + {onlyField == null && eventsCountViewEventsButton} + + ); + } else { + return null; + } + }, [onlyField, headerChildren, eventsCountViewEventsButton]); + return ( ); }; diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/overview.tsx b/x-pack/legacy/plugins/siem/public/pages/overview/overview.tsx index 2db49e60193fc..82f4444728902 100644 --- a/x-pack/legacy/plugins/siem/public/pages/overview/overview.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/overview/overview.tsx @@ -63,7 +63,7 @@ const OverviewComponent: React.FC = ({ from={from} indexPattern={indexPattern} query={query} - setAbsoluteRangeDatePicker={setAbsoluteRangeDatePicker!} + setAbsoluteRangeDatePicker={setAbsoluteRangeDatePicker} setQuery={setQuery} to={to} /> diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/sidebar/sidebar.tsx b/x-pack/legacy/plugins/siem/public/pages/overview/sidebar/sidebar.tsx index 52e36b472a0ec..4d4d96803cd65 100644 --- a/x-pack/legacy/plugins/siem/public/pages/overview/sidebar/sidebar.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/overview/sidebar/sidebar.tsx @@ -8,9 +8,12 @@ import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; import React, { useMemo } from 'react'; import styled from 'styled-components'; +import { + ENABLE_NEWS_FEED_SETTING, + NEWS_FEED_URL_SETTING, +} from '../../../../../../../plugins/siem/common/constants'; import { Filters as RecentCasesFilters } from '../../../components/recent_cases/filters'; import { Filters as RecentTimelinesFilters } from '../../../components/recent_timelines/filters'; -import { ENABLE_NEWS_FEED_SETTING, NEWS_FEED_URL_SETTING } from '../../../../common/constants'; import { StatefulRecentCases } from '../../../components/recent_cases'; import { StatefulRecentTimelines } from '../../../components/recent_timelines'; import { StatefulNewsFeed } from '../../../components/news_feed'; diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/signals_by_category/index.tsx b/x-pack/legacy/plugins/siem/public/pages/overview/signals_by_category/index.tsx index 5f78c4c10eb37..feba80539a11b 100644 --- a/x-pack/legacy/plugins/siem/public/pages/overview/signals_by_category/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/overview/signals_by_category/index.tsx @@ -12,6 +12,7 @@ import { useSignalIndex } from '../../../containers/detection_engine/signals/use import { SetAbsoluteRangeDatePicker } from '../../network/types'; import { Filter, IIndexPattern, Query } from '../../../../../../../../src/plugins/data/public'; import { inputsModel } from '../../../store'; +import { InputsModelId } from '../../../store/inputs/constants'; import * as i18n from '../translations'; const DEFAULT_QUERY: Query = { query: '', language: 'kuery' }; @@ -22,9 +23,13 @@ interface Props { deleteQuery?: ({ id }: { id: string }) => void; filters?: Filter[]; from: number; + headerChildren?: React.ReactNode; indexPattern: IIndexPattern; + /** Override all defaults, and only display this field */ + onlyField?: string; query?: Query; setAbsoluteRangeDatePicker: SetAbsoluteRangeDatePicker; + setAbsoluteRangeDatePickerTarget?: InputsModelId; setQuery: (params: { id: string; inspect: inputsModel.InspectQuery | null; @@ -38,15 +43,18 @@ const SignalsByCategoryComponent: React.FC = ({ deleteQuery, filters = NO_FILTERS, from, + headerChildren, + onlyField, query = DEFAULT_QUERY, setAbsoluteRangeDatePicker, + setAbsoluteRangeDatePickerTarget = 'global', setQuery, to, }) => { const { signalIndexName } = useSignalIndex(); const updateDateRangeCallback = useCallback( (min: number, max: number) => { - setAbsoluteRangeDatePicker!({ id: 'global', from: min, to: max }); + setAbsoluteRangeDatePicker({ id: setAbsoluteRangeDatePickerTarget, from: min, to: max }); }, [setAbsoluteRangeDatePicker] ); @@ -60,12 +68,14 @@ const SignalsByCategoryComponent: React.FC = ({ defaultStackByOption={defaultStackByOption} filters={filters} from={from} + headerChildren={headerChildren} + onlyField={onlyField} query={query} signalIndexName={signalIndexName} setQuery={setQuery} showTotalSignalsCount={true} - showLinkToSignals={true} - stackByOptions={signalsHistogramOptions} + showLinkToSignals={onlyField == null ? true : false} + stackByOptions={onlyField == null ? signalsHistogramOptions : undefined} legendPosition={'right'} to={to} title={i18n.SIGNAL_COUNT} diff --git a/x-pack/legacy/plugins/siem/public/pages/overview/translations.ts b/x-pack/legacy/plugins/siem/public/pages/overview/translations.ts index 601a629d86e57..b7bee15e4c5bf 100644 --- a/x-pack/legacy/plugins/siem/public/pages/overview/translations.ts +++ b/x-pack/legacy/plugins/siem/public/pages/overview/translations.ts @@ -38,6 +38,12 @@ export const SIGNAL_COUNT = i18n.translate('xpack.siem.overview.signalCountTitle defaultMessage: 'Signal count', }); +export const TOP = (fieldName: string) => + i18n.translate('xpack.siem.overview.topNLabel', { + values: { fieldName }, + defaultMessage: `Top {fieldName}`, + }); + export const VIEW_ALERTS = i18n.translate('xpack.siem.overview.viewAlertsButtonLabel', { defaultMessage: 'View alerts', }); diff --git a/x-pack/legacy/plugins/siem/public/pages/timelines/timelines_page.test.tsx b/x-pack/legacy/plugins/siem/public/pages/timelines/timelines_page.test.tsx index 62399891c9606..ae95a1316a600 100644 --- a/x-pack/legacy/plugins/siem/public/pages/timelines/timelines_page.test.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/timelines/timelines_page.test.tsx @@ -10,6 +10,8 @@ import { shallow, ShallowWrapper } from 'enzyme'; import React from 'react'; import ApolloClient from 'apollo-client'; +jest.mock('../../pages/overview/events_by_dataset'); + jest.mock('../../lib/kibana', () => { return { useKibana: jest.fn(), diff --git a/x-pack/legacy/plugins/siem/public/register_feature.ts b/x-pack/legacy/plugins/siem/public/register_feature.ts index ca7a22408b6ff..b5e8f78ebc560 100644 --- a/x-pack/legacy/plugins/siem/public/register_feature.ts +++ b/x-pack/legacy/plugins/siem/public/register_feature.ts @@ -6,7 +6,7 @@ import { npSetup } from 'ui/new_platform'; import { FeatureCatalogueCategory } from '../../../../../src/plugins/home/public'; -import { APP_ID } from '../common/constants'; +import { APP_ID } from '../../../../plugins/siem/common/constants'; // TODO(rylnd): move this into Plugin.setup once we're on NP npSetup.plugins.home.featureCatalogue.register({ diff --git a/x-pack/legacy/plugins/siem/public/shared_imports.ts b/x-pack/legacy/plugins/siem/public/shared_imports.ts index c83433ef129c9..0c0ac637a4229 100644 --- a/x-pack/legacy/plugins/siem/public/shared_imports.ts +++ b/x-pack/legacy/plugins/siem/public/shared_imports.ts @@ -8,6 +8,7 @@ export { getUseField, getFieldValidityAndErrorMessage, FieldHook, + FieldValidateResponse, FIELD_TYPES, Form, FormData, @@ -17,6 +18,7 @@ export { UseField, useForm, ValidationFunc, + VALIDATION_TYPES, } from '../../../../../src/plugins/es_ui_shared/static/forms/hook_form_lib'; export { Field, diff --git a/x-pack/legacy/plugins/siem/public/store/inputs/model.ts b/x-pack/legacy/plugins/siem/public/store/inputs/model.ts index 04facf3b98c3b..e851caf523eb4 100644 --- a/x-pack/legacy/plugins/siem/public/store/inputs/model.ts +++ b/x-pack/legacy/plugins/siem/public/store/inputs/model.ts @@ -5,7 +5,6 @@ */ import { Dispatch } from 'redux'; -import { Omit } from '../../../common/utility_types'; import { InputsModelId } from './constants'; import { CONSTANTS } from '../../components/url_state/constants'; import { Query, Filter, SavedQuery } from '../../../../../../../src/plugins/data/public'; diff --git a/x-pack/legacy/plugins/siem/public/utils/default_date_settings.test.ts b/x-pack/legacy/plugins/siem/public/utils/default_date_settings.test.ts index 9dc179ba7a6e2..bb66067512d1f 100644 --- a/x-pack/legacy/plugins/siem/public/utils/default_date_settings.test.ts +++ b/x-pack/legacy/plugins/siem/public/utils/default_date_settings.test.ts @@ -21,7 +21,7 @@ import { DEFAULT_INTERVAL_PAUSE, DEFAULT_INTERVAL_VALUE, DEFAULT_INTERVAL_TYPE, -} from '../../common/constants'; +} from '../../../../../plugins/siem/common/constants'; import { KibanaServices } from '../lib/kibana'; import { Policy } from '../store/inputs/model'; @@ -30,7 +30,7 @@ import { Policy } from '../store/inputs/model'; // we have to repeat ourselves once const DEFAULT_FROM_DATE = '1983-05-31T13:03:54.234Z'; const DEFAULT_TO_DATE = '1990-05-31T13:03:54.234Z'; -jest.mock('../../common/constants', () => ({ +jest.mock('../../../../../plugins/siem/common/constants', () => ({ DEFAULT_FROM: '1983-05-31T13:03:54.234Z', DEFAULT_TO: '1990-05-31T13:03:54.234Z', DEFAULT_INTERVAL_PAUSE: true, diff --git a/x-pack/legacy/plugins/siem/public/utils/default_date_settings.ts b/x-pack/legacy/plugins/siem/public/utils/default_date_settings.ts index c4869a4851ae5..89f7d34d85131 100644 --- a/x-pack/legacy/plugins/siem/public/utils/default_date_settings.ts +++ b/x-pack/legacy/plugins/siem/public/utils/default_date_settings.ts @@ -15,7 +15,7 @@ import { DEFAULT_TO, DEFAULT_INTERVAL_TYPE, DEFAULT_INTERVAL_VALUE, -} from '../../common/constants'; +} from '../../../../../plugins/siem/common/constants'; import { KibanaServices } from '../lib/kibana'; import { Policy } from '../store/inputs/model'; diff --git a/x-pack/legacy/plugins/siem/reporter_config.json b/x-pack/legacy/plugins/siem/reporter_config.json deleted file mode 100644 index dda68d501f975..0000000000000 --- a/x-pack/legacy/plugins/siem/reporter_config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "reporterEnabled": "mochawesome, mocha-junit-reporter", - "reporterOptions": { - "html": false, - "json": true, - "mochaFile": "../../../../target/kibana-siem/cypress/results/TEST-siem-cypress-[hash].xml", - "overwrite": false, - "reportDir": "../../../../target/kibana-siem/cypress/results" - } -} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_list.json b/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_list.json deleted file mode 100644 index 997d03369a699..0000000000000 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_list.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "Query with a list", - "description": "Query with a list", - "rule_id": "query-with-list", - "risk_score": 1, - "severity": "high", - "type": "query", - "query": "user.name: root or user.name: admin", - "lists": [ - { - "field": "source.ip", - "values_operator": "included", - "values_type": "exists" - }, - { - "field": "host.name", - "values_operator": "excluded", - "values_type": "match", - "values": [ - { - "name": "rock01" - } - ], - "and": [ - { - "field": "host.id", - "values_operator": "included", - "values_type": "match_all", - "values": [ - { - "name": "123" - }, - { - "name": "678" - } - ] - } - ] - } - ] -} diff --git a/x-pack/legacy/plugins/siem/server/plugin.ts b/x-pack/legacy/plugins/siem/server/plugin.ts deleted file mode 100644 index 13b58fa1d57eb..0000000000000 --- a/x-pack/legacy/plugins/siem/server/plugin.ts +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { i18n } from '@kbn/i18n'; - -import { - PluginStartContract as AlertingStart, - PluginSetupContract as AlertingSetup, -} from '../../../../plugins/alerting/server'; -import { - CoreSetup, - CoreStart, - PluginInitializerContext, - Logger, -} from '../../../../../src/core/server'; -import { SecurityPluginSetup as SecuritySetup } from '../../../../plugins/security/server'; -import { PluginSetupContract as FeaturesSetup } from '../../../../plugins/features/server'; -import { MlPluginSetup as MlSetup } from '../../../../plugins/ml/server'; -import { EncryptedSavedObjectsPluginSetup as EncryptedSavedObjectsSetup } from '../../../../plugins/encrypted_saved_objects/server'; -import { SpacesPluginSetup as SpacesSetup } from '../../../../plugins/spaces/server'; -import { PluginStartContract as ActionsStart } from '../../../../plugins/actions/server'; -import { LicensingPluginSetup } from '../../../../plugins/licensing/server'; -import { LegacyServices } from './types'; -import { initServer } from './init_server'; -import { compose } from './lib/compose/kibana'; -import { initRoutes } from './routes'; -import { isAlertExecutor } from './lib/detection_engine/signals/types'; -import { signalRulesAlertType } from './lib/detection_engine/signals/signal_rule_alert_type'; -import { rulesNotificationAlertType } from './lib/detection_engine/notifications/rules_notification_alert_type'; -import { isNotificationAlertExecutor } from './lib/detection_engine/notifications/types'; -import { - noteSavedObjectType, - pinnedEventSavedObjectType, - timelineSavedObjectType, - ruleStatusSavedObjectType, - ruleActionsSavedObjectType, -} from './saved_objects'; -import { SiemClientFactory } from './client'; -import { hasListsFeature, listsEnvFeatureFlagName } from './lib/detection_engine/feature_flags'; - -export { CoreSetup, CoreStart }; - -export interface SetupPlugins { - alerting: AlertingSetup; - encryptedSavedObjects: EncryptedSavedObjectsSetup; - features: FeaturesSetup; - licensing: LicensingPluginSetup; - security?: SecuritySetup; - spaces?: SpacesSetup; - ml?: MlSetup; -} - -export interface StartPlugins { - actions: ActionsStart; - alerting: AlertingStart; -} - -export class Plugin { - readonly name = 'siem'; - private readonly logger: Logger; - private context: PluginInitializerContext; - private siemClientFactory: SiemClientFactory; - - constructor(context: PluginInitializerContext) { - this.context = context; - this.logger = context.logger.get('plugins', this.name); - this.siemClientFactory = new SiemClientFactory(); - - this.logger.debug('Shim plugin initialized'); - } - - public setup(core: CoreSetup, plugins: SetupPlugins, __legacy: LegacyServices) { - this.logger.debug('Shim plugin setup'); - if (hasListsFeature()) { - // TODO: Remove this once we have the lists feature supported - this.logger.error( - `You have activated the lists feature flag which is NOT currently supported for SIEM! You should turn this feature flag off immediately by un-setting the environment variable: ${listsEnvFeatureFlagName} and restarting Kibana` - ); - } - - const router = core.http.createRouter(); - core.http.registerRouteHandlerContext(this.name, (context, request, response) => ({ - getSiemClient: () => this.siemClientFactory.create(request), - })); - - this.siemClientFactory.setup({ - getSpaceId: plugins.spaces?.spacesService?.getSpaceId, - config: __legacy.config, - }); - - initRoutes( - router, - __legacy.config, - plugins.encryptedSavedObjects?.usingEphemeralEncryptionKey ?? false, - plugins.security - ); - - plugins.features.registerFeature({ - id: this.name, - name: i18n.translate('xpack.siem.featureRegistry.linkSiemTitle', { - defaultMessage: 'SIEM', - }), - order: 1100, - icon: 'securityAnalyticsApp', - navLinkId: 'siem', - app: ['siem', 'kibana'], - catalogue: ['siem'], - privileges: { - all: { - app: ['siem', 'kibana'], - catalogue: ['siem'], - api: ['siem', 'actions-read', 'actions-all', 'alerting-read', 'alerting-all'], - savedObject: { - all: [ - 'alert', - 'action', - 'action_task_params', - noteSavedObjectType, - pinnedEventSavedObjectType, - timelineSavedObjectType, - ruleStatusSavedObjectType, - ruleActionsSavedObjectType, - 'cases', - 'cases-comments', - 'cases-configure', - 'cases-user-actions', - ], - read: ['config'], - }, - ui: [ - 'show', - 'crud', - 'alerting:show', - 'actions:show', - 'alerting:save', - 'actions:save', - 'alerting:delete', - 'actions:delete', - ], - }, - read: { - app: ['siem', 'kibana'], - catalogue: ['siem'], - api: ['siem', 'actions-read', 'actions-all', 'alerting-read', 'alerting-all'], - savedObject: { - all: ['alert', 'action', 'action_task_params'], - read: [ - 'config', - noteSavedObjectType, - pinnedEventSavedObjectType, - timelineSavedObjectType, - ruleStatusSavedObjectType, - ruleActionsSavedObjectType, - 'cases', - 'cases-comments', - 'cases-configure', - 'cases-user-actions', - ], - }, - ui: [ - 'show', - 'alerting:show', - 'actions:show', - 'alerting:save', - 'actions:save', - 'alerting:delete', - 'actions:delete', - ], - }, - }, - }); - - if (plugins.alerting != null) { - const signalRuleType = signalRulesAlertType({ - logger: this.logger, - version: this.context.env.packageInfo.version, - ml: plugins.ml, - }); - const ruleNotificationType = rulesNotificationAlertType({ - logger: this.logger, - }); - - if (isAlertExecutor(signalRuleType)) { - plugins.alerting.registerType(signalRuleType); - } - - if (isNotificationAlertExecutor(ruleNotificationType)) { - plugins.alerting.registerType(ruleNotificationType); - } - } - - const libs = compose(core, plugins, this.context.env.mode.prod); - initServer(libs); - } - - public start(core: CoreStart, plugins: StartPlugins) {} -} diff --git a/x-pack/legacy/plugins/siem/server/utils/build_validation/route_validation.test.ts b/x-pack/legacy/plugins/siem/server/utils/build_validation/route_validation.test.ts deleted file mode 100644 index 888cd5dfe5390..0000000000000 --- a/x-pack/legacy/plugins/siem/server/utils/build_validation/route_validation.test.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { buildRouteValidation } from './route_validation'; -import * as rt from 'io-ts'; -import { RouteValidationResultFactory } from '../../../../../../../src/core/server/http'; - -describe('buildRouteValidation', () => { - const schema = rt.type({ - ids: rt.array(rt.string), - }); - const validationResult: RouteValidationResultFactory = { - ok: jest.fn().mockImplementation(validatedInput => validatedInput), - badRequest: jest.fn().mockImplementation(e => e), - }; - - beforeEach(() => { - jest.clearAllMocks(); - }); - - test('return validation error', () => { - const input = { id: 'someId' }; - const result = buildRouteValidation(schema)(input, validationResult); - - expect(result).toEqual( - 'Invalid value undefined supplied to : { ids: Array }/ids: Array' - ); - }); - - test('return validated input', () => { - const input = { ids: ['someId'] }; - const result = buildRouteValidation(schema)(input, validationResult); - - expect(result).toEqual(input); - }); -}); diff --git a/x-pack/legacy/plugins/siem/tsconfig.json b/x-pack/legacy/plugins/siem/tsconfig.json deleted file mode 100644 index b027bb4567b97..0000000000000 --- a/x-pack/legacy/plugins/siem/tsconfig.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "../../../tsconfig.json" -} \ No newline at end of file diff --git a/x-pack/legacy/plugins/tilemap/index.js b/x-pack/legacy/plugins/tilemap/index.js deleted file mode 100644 index d4105519ee0a7..0000000000000 --- a/x-pack/legacy/plugins/tilemap/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { mirrorPluginStatus } from '../../server/lib/mirror_plugin_status'; -import { inspectSettings } from './server/lib/inspect_settings'; -import { resolve } from 'path'; - -export const tilemap = kibana => { - return new kibana.Plugin({ - id: 'tilemap', - configPrefix: 'xpack.tilemap', - require: ['xpack_main', 'vis_type_vislib'], - publicDir: resolve(__dirname, 'public'), - uiExports: { - hacks: ['plugins/tilemap/vis_type_enhancers/update_tilemap_settings'], - }, - init: function(server) { - const thisPlugin = this; - const xpackMainPlugin = server.plugins.xpack_main; - mirrorPluginStatus(xpackMainPlugin, thisPlugin); - xpackMainPlugin.status.once('green', () => { - xpackMainPlugin.info - .feature(thisPlugin.id) - .registerLicenseCheckResultsGenerator(inspectSettings); - }); - }, - }); -}; diff --git a/x-pack/legacy/plugins/tilemap/public/vis_type_enhancers/update_tilemap_settings.js b/x-pack/legacy/plugins/tilemap/public/vis_type_enhancers/update_tilemap_settings.js deleted file mode 100644 index 294bc31e3893e..0000000000000 --- a/x-pack/legacy/plugins/tilemap/public/vis_type_enhancers/update_tilemap_settings.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; -import { npSetup } from 'ui/new_platform'; - -const tileMapPluginInfo = xpackInfo.get('features.tilemap'); - -if (tileMapPluginInfo && (tileMapPluginInfo.license.active || tileMapPluginInfo.license.valid)) { - const { serviceSettings } = npSetup.plugins.mapsLegacy; - serviceSettings.addQueryParams({ license: tileMapPluginInfo.license.uid }); - serviceSettings.disableZoomMessage(); -} diff --git a/x-pack/legacy/plugins/tilemap/server/lib/__tests__/inspect_settings.js b/x-pack/legacy/plugins/tilemap/server/lib/__tests__/inspect_settings.js deleted file mode 100644 index ce7987ee396b8..0000000000000 --- a/x-pack/legacy/plugins/tilemap/server/lib/__tests__/inspect_settings.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { inspectSettings } from '../../../server/lib/inspect_settings'; - -describe('inspectSettings', function() { - it('should propagate x-pack info', function() { - const mockSettings = { - isAvailable: () => true, - license: { - getUid: () => 'foobar', - isActive: () => true, - isOneOf: () => true, - }, - }; - - const licenseInfo = inspectSettings(mockSettings); - expect(licenseInfo.license.uid).to.equal('foobar'); - expect(licenseInfo.license.active).to.equal(true); - expect(licenseInfo.license.valid).to.equal(true); - }); - - it('should break when unavailable info', function() { - const mockSettings = { - isAvailable: () => false, - }; - - const licenseInfo = inspectSettings(mockSettings); - expect(licenseInfo).to.have.property('message'); - expect(typeof licenseInfo.message === 'string').to.be.ok(); - }); -}); diff --git a/x-pack/legacy/plugins/tilemap/server/lib/inspect_settings.js b/x-pack/legacy/plugins/tilemap/server/lib/inspect_settings.js deleted file mode 100644 index cd6fb8bd8c110..0000000000000 --- a/x-pack/legacy/plugins/tilemap/server/lib/inspect_settings.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export function inspectSettings(xpackInfo) { - if (!xpackInfo || !xpackInfo.isAvailable()) { - return { - message: - 'You cannot use the Tilemap Plugin because license information is not available at this time.', - }; - } - - /** - *Propagate these settings to the client - */ - return { - license: { - uid: xpackInfo.license.getUid(), - active: xpackInfo.license.isActive(), - valid: xpackInfo.license.isOneOf([ - 'trial', - 'standard', - 'basic', - 'gold', - 'platinum', - 'enterprise', - ]), - }, - }; -} diff --git a/x-pack/legacy/plugins/uptime/README.md b/x-pack/legacy/plugins/uptime/README.md index 2ed0e2fc77cbc..92162341ff426 100644 --- a/x-pack/legacy/plugins/uptime/README.md +++ b/x-pack/legacy/plugins/uptime/README.md @@ -3,7 +3,7 @@ ## Purpose The purpose of this plugin is to provide users of Heartbeat more visibility of what's happening -in their infrastructure. It's primarily built using React and Apollo's GraphQL tools. +in their infrastructure. ## Layout @@ -11,13 +11,15 @@ There are three sections to the app, `common`, `public`, and `server`. ### common -Contains GraphQL types, constants and a few other files. +Contains runtime types types, constants and a few other files. + +Notably, we use `io-ts`/`fp-ts` functions and types to help provide +additional runtime safety for our API requests/responses. ### public -Components come in two main types, queries and functional. Queries are extended from Apollo's queries -type which abstracts a lot of the GraphQL connectivity away. Functional are dumb components that -don't store any state. +We use Redux and associated tools for managing our app state. Components come in the usual `connect`ed and +presentational varieties. The `lib` directory controls bootstrapping code and adapter types. @@ -27,12 +29,13 @@ The principal structure of the app is stored in `uptime_app.tsx`. ### server -There is a `graphql` directory which contains the resolvers, schema files, and constants. - The `lib` directory contains `adapters`, which are connections to external resources like Kibana Server, Elasticsearch, etc. In addition, it contains domains, which are libraries that provide functionality via adapters. +The `requests` directory contains functions responsible for querying Elasticsearch and parsing its +responses. + There's also a `rest_api` folder that defines the structure of the RESTful API endpoints. ## Testing diff --git a/x-pack/legacy/plugins/uptime/common/constants/chart_format_limits.ts b/x-pack/legacy/plugins/uptime/common/constants/chart_format_limits.ts index f291450ab2a7a..3bd204a003c9d 100644 --- a/x-pack/legacy/plugins/uptime/common/constants/chart_format_limits.ts +++ b/x-pack/legacy/plugins/uptime/common/constants/chart_format_limits.ts @@ -11,7 +11,7 @@ const WEEK = DAY * 7; const MONTH = WEEK * 4; /** - * These contsants are used by the charting code to determine + * These constants are used by the charting code to determine * what label should be applied to chart axes so as to help users * understand the timeseries data they're being shown. */ diff --git a/x-pack/legacy/plugins/uptime/common/constants/context_defaults.ts b/x-pack/legacy/plugins/uptime/common/constants/context_defaults.ts index 540e60a28b066..0c493326add72 100644 --- a/x-pack/legacy/plugins/uptime/common/constants/context_defaults.ts +++ b/x-pack/legacy/plugins/uptime/common/constants/context_defaults.ts @@ -4,14 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SortOrder, CursorDirection } from '../graphql/types'; +import { CursorDirection, SortOrder } from '../runtime_types'; /** * The Uptime UI utilizes a settings context, the defaults for which are stored here. */ export const CONTEXT_DEFAULTS = { /** - * The application cannot assume a basepath. + * The application cannot assume a basePath. */ BASE_PATH: '', diff --git a/x-pack/legacy/plugins/uptime/common/constants/rest_api.ts b/x-pack/legacy/plugins/uptime/common/constants/rest_api.ts index dffa131870db1..169d175f02d3b 100644 --- a/x-pack/legacy/plugins/uptime/common/constants/rest_api.ts +++ b/x-pack/legacy/plugins/uptime/common/constants/rest_api.ts @@ -5,8 +5,10 @@ */ export enum API_URLS { + CERTS = '/api/uptime/certs', INDEX_PATTERN = `/api/uptime/index_pattern`, INDEX_STATUS = '/api/uptime/index_status', + MONITOR_LIST = `/api/uptime/monitor/list`, MONITOR_LOCATIONS = `/api/uptime/monitor/locations`, MONITOR_DURATION = `/api/uptime/monitor/duration`, MONITOR_DETAILS = `/api/uptime/monitor/details`, diff --git a/x-pack/legacy/plugins/uptime/common/graphql/types.ts b/x-pack/legacy/plugins/uptime/common/graphql/types.ts index 506966ec6b5c9..e69de29bb2d1d 100644 --- a/x-pack/legacy/plugins/uptime/common/graphql/types.ts +++ b/x-pack/legacy/plugins/uptime/common/graphql/types.ts @@ -1,232 +0,0 @@ -/* tslint:disable */ - -// ==================================================== -// START: Typescript template -// ==================================================== - -// ==================================================== -// Scalars -// ==================================================== - -export type UnsignedInteger = any; - -// ==================================================== -// Types -// ==================================================== - -export interface Query { - /** Fetches the current state of Uptime monitors for the given parameters. */ - getMonitorStates?: MonitorSummaryResult | null; -} - -/** The monitor's status for a ping */ -export interface Duration { - us?: UnsignedInteger | null; -} - -export interface Rtt { - connect?: Duration | null; - - handshake?: Duration | null; - - validate?: Duration | null; -} - -export interface Summary { - up?: number | null; - - down?: number | null; - - geo?: CheckGeo | null; -} - -export interface CheckGeo { - name?: string | null; - - location?: Location | null; -} - -export interface Location { - lat?: number | null; - - lon?: number | null; -} - -export interface DocCount { - count: UnsignedInteger; -} - -/** The primary object returned for monitor states. */ -export interface MonitorSummaryResult { - /** Used to go to the next page of results */ - prevPagePagination?: string | null; - /** Used to go to the previous page of results */ - nextPagePagination?: string | null; - /** The objects representing the state of a series of heartbeat monitors. */ - summaries?: MonitorSummary[] | null; - /** The number of summaries. */ - totalSummaryCount: number; -} -/** Represents the current state and associated data for an Uptime monitor. */ -export interface MonitorSummary { - /** The ID assigned by the config or generated by the user. */ - monitor_id: string; - /** The state of the monitor and its associated details. */ - state: State; - - histogram?: SummaryHistogram | null; -} -/** Unifies the subsequent data for an uptime monitor. */ -export interface State { - /** The agent processing the monitor. */ - agent?: Agent | null; - /** There is a check object for each instance of the monitoring agent. */ - checks?: Check[] | null; - - geo?: StateGeo | null; - - observer?: StateObserver | null; - - monitor?: MonitorState | null; - - summary: Summary; - - timestamp: UnsignedInteger; - /** Transport encryption information. */ - tls?: (StateTls | null)[] | null; - - url?: StateUrl | null; -} - -export interface Agent { - id: string; -} - -export interface Check { - agent?: Agent | null; - - container?: StateContainer | null; - - kubernetes?: StateKubernetes | null; - - monitor: CheckMonitor; - - observer?: CheckObserver | null; - - timestamp: string; -} - -export interface StateContainer { - id?: string | null; -} - -export interface StateKubernetes { - pod?: StatePod | null; -} - -export interface StatePod { - uid?: string | null; -} - -export interface CheckMonitor { - ip?: string | null; - - name?: string | null; - - status: string; -} - -export interface CheckObserver { - geo?: CheckGeo | null; -} - -export interface StateGeo { - name?: (string | null)[] | null; - - location?: Location | null; -} - -export interface StateObserver { - geo?: StateGeo | null; -} - -export interface MonitorState { - status?: string | null; - - name?: string | null; - - id?: string | null; - - type?: string | null; -} -/** Contains monitor transmission encryption information. */ -export interface StateTls { - /** The date and time after which the certificate is invalid. */ - certificate_not_valid_after?: string | null; - - certificate_not_valid_before?: string | null; - - certificates?: string | null; - - rtt?: Rtt | null; -} - -export interface StateUrl { - domain?: string | null; - - full?: string | null; - - path?: string | null; - - port?: number | null; - - scheme?: string | null; -} -/** Monitor status data over time. */ -export interface SummaryHistogram { - /** The number of documents used to assemble the histogram. */ - count: number; - /** The individual histogram data points. */ - points: SummaryHistogramPoint[]; -} -/** Represents a monitor's statuses for a period of time. */ -export interface SummaryHistogramPoint { - /** The time at which these data were collected. */ - timestamp: UnsignedInteger; - /** The number of _up_ documents. */ - up: number; - /** The number of _down_ documents. */ - down: number; -} - -export interface GetMonitorStatesQueryArgs { - dateRangeStart: string; - - dateRangeEnd: string; - - pagination?: string | null; - - filters?: string | null; - - statusFilter?: string | null; - - pageSize: number; -} - -// ==================================================== -// Enums -// ==================================================== - -export enum CursorDirection { - AFTER = 'AFTER', - BEFORE = 'BEFORE', -} - -export enum SortOrder { - ASC = 'ASC', - DESC = 'DESC', -} - -// ==================================================== -// END: Typescript template -// ==================================================== diff --git a/x-pack/legacy/plugins/uptime/common/runtime_types/certs.ts b/x-pack/legacy/plugins/uptime/common/runtime_types/certs.ts new file mode 100644 index 0000000000000..e8be67abf3a44 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/common/runtime_types/certs.ts @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import * as t from 'io-ts'; + +export const GetCertsParamsType = t.intersection([ + t.type({ + from: t.string, + to: t.string, + index: t.number, + size: t.number, + }), + t.partial({ + search: t.string, + }), +]); + +export type GetCertsParams = t.TypeOf; + +export const CertType = t.intersection([ + t.type({ + monitors: t.array( + t.partial({ + name: t.string, + id: t.string, + }) + ), + sha256: t.string, + }), + t.partial({ + certificate_not_valid_after: t.string, + certificate_not_valid_before: t.string, + common_name: t.string, + issuer: t.string, + sha1: t.string, + }), +]); + +export type Cert = t.TypeOf; diff --git a/x-pack/legacy/plugins/uptime/common/runtime_types/common.ts b/x-pack/legacy/plugins/uptime/common/runtime_types/common.ts index 9018f4acaa320..e07c46fa01cfe 100644 --- a/x-pack/legacy/plugins/uptime/common/runtime_types/common.ts +++ b/x-pack/legacy/plugins/uptime/common/runtime_types/common.ts @@ -33,7 +33,6 @@ export const DateRangeType = t.type({ }); export type Summary = t.TypeOf; -export type CheckGeo = t.TypeOf; export type Location = t.TypeOf; export type StatesIndexStatus = t.TypeOf; export type DateRange = t.TypeOf; diff --git a/x-pack/legacy/plugins/uptime/common/runtime_types/dynamic_settings.ts b/x-pack/legacy/plugins/uptime/common/runtime_types/dynamic_settings.ts index 8dedd4672eeae..985b51891da99 100644 --- a/x-pack/legacy/plugins/uptime/common/runtime_types/dynamic_settings.ts +++ b/x-pack/legacy/plugins/uptime/common/runtime_types/dynamic_settings.ts @@ -6,10 +6,20 @@ import * as t from 'io-ts'; -export const DynamicSettingsType = t.type({ - heartbeatIndices: t.string, +export const CertificatesStatesThresholdType = t.interface({ + warningState: t.number, + errorState: t.number, }); +export const DynamicSettingsType = t.intersection([ + t.type({ + heartbeatIndices: t.string, + }), + t.partial({ + certificatesThresholds: CertificatesStatesThresholdType, + }), +]); + export const DynamicSettingsSaveType = t.intersection([ t.type({ success: t.boolean, @@ -21,7 +31,12 @@ export const DynamicSettingsSaveType = t.intersection([ export type DynamicSettings = t.TypeOf; export type DynamicSettingsSaveResponse = t.TypeOf; +export type CertificatesStatesThreshold = t.TypeOf; export const defaultDynamicSettings: DynamicSettings = { heartbeatIndices: 'heartbeat-8*', + certificatesThresholds: { + errorState: 7, + warningState: 30, + }, }; diff --git a/x-pack/legacy/plugins/uptime/common/runtime_types/index.ts b/x-pack/legacy/plugins/uptime/common/runtime_types/index.ts index 652d60cbe304d..78aab3806ae04 100644 --- a/x-pack/legacy/plugins/uptime/common/runtime_types/index.ts +++ b/x-pack/legacy/plugins/uptime/common/runtime_types/index.ts @@ -5,6 +5,7 @@ */ export * from './alerts'; +export * from './certs'; export * from './common'; export * from './monitor'; export * from './overview_filters'; diff --git a/x-pack/legacy/plugins/uptime/common/runtime_types/monitor/index.ts b/x-pack/legacy/plugins/uptime/common/runtime_types/monitor/index.ts index 80b48d09dc5b8..46b19d8442a94 100644 --- a/x-pack/legacy/plugins/uptime/common/runtime_types/monitor/index.ts +++ b/x-pack/legacy/plugins/uptime/common/runtime_types/monitor/index.ts @@ -6,3 +6,4 @@ export * from './details'; export * from './locations'; +export * from './state'; diff --git a/x-pack/legacy/plugins/uptime/common/runtime_types/monitor/state.ts b/x-pack/legacy/plugins/uptime/common/runtime_types/monitor/state.ts new file mode 100644 index 0000000000000..90aa692f89a42 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/common/runtime_types/monitor/state.ts @@ -0,0 +1,145 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import * as t from 'io-ts'; + +export const CheckMonitorType = t.intersection([ + t.partial({ + name: t.string, + ip: t.union([t.array(t.string), t.string]), + }), + t.type({ + status: t.string, + }), +]); + +export const CheckType = t.intersection([ + t.partial({ + agent: t.partial({ + id: t.string, + }), + container: t.type({ + id: t.string, + }), + kubernetes: t.type({ + pod: t.type({ + uid: t.string, + }), + }), + observer: t.type({ + geo: t.partial({ + name: t.string, + location: t.partial({ + lat: t.number, + lon: t.number, + }), + }), + }), + }), + t.type({ + monitor: CheckMonitorType, + timestamp: t.number, + }), +]); + +export type Check = t.TypeOf; + +export const StateType = t.intersection([ + t.partial({ + checks: t.array(CheckType), + observer: t.partial({ + geo: t.partial({ + name: t.array(t.string), + }), + }), + summary: t.partial({ + up: t.number, + down: t.number, + geo: t.partial({ + name: t.string, + location: t.partial({ + lat: t.number, + lon: t.number, + }), + }), + }), + }), + t.type({ + timestamp: t.string, + url: t.partial({ + domain: t.string, + full: t.string, + path: t.string, + port: t.number, + scheme: t.string, + }), + }), +]); + +export const HistogramPointType = t.type({ + timestamp: t.number, + up: t.number, + down: t.number, +}); + +export type HistogramPoint = t.TypeOf; + +export const HistogramType = t.type({ + count: t.number, + points: t.array(HistogramPointType), +}); + +export type Histogram = t.TypeOf; + +export const MonitorSummaryType = t.intersection([ + t.type({ + monitor_id: t.string, + state: StateType, + }), + t.partial({ + histogram: HistogramType, + }), +]); + +export type MonitorSummary = t.TypeOf; + +export const MonitorSummaryResultType = t.intersection([ + t.partial({ + summaries: t.array(MonitorSummaryType), + }), + t.type({ + prevPagePagination: t.union([t.string, t.null]), + nextPagePagination: t.union([t.string, t.null]), + totalSummaryCount: t.number, + }), +]); + +export type MonitorSummaryResult = t.TypeOf; + +export const FetchMonitorStatesQueryArgsType = t.intersection([ + t.partial({ + pagination: t.string, + filters: t.string, + statusFilter: t.string, + }), + t.type({ + dateRangeStart: t.string, + dateRangeEnd: t.string, + pageSize: t.number, + }), +]); + +export type FetchMonitorStatesQueryArgs = t.TypeOf; + +export enum CursorDirection { + AFTER = 'AFTER', + BEFORE = 'BEFORE', +} + +export enum SortOrder { + ASC = 'ASC', + DESC = 'DESC', +} diff --git a/x-pack/legacy/plugins/uptime/common/types/index.ts b/x-pack/legacy/plugins/uptime/common/types/index.ts index fcbb92caf26d5..a32eabd49a3e5 100644 --- a/x-pack/legacy/plugins/uptime/common/types/index.ts +++ b/x-pack/legacy/plugins/uptime/common/types/index.ts @@ -35,3 +35,7 @@ export interface MonitorDurationResult { /** The average values for the monitor duration. */ locationDurationLines: LocationDurationLine[]; } + +export interface MonitorIdParam { + monitorId: string; +} diff --git a/x-pack/legacy/plugins/uptime/public/apps/plugin.ts b/x-pack/legacy/plugins/uptime/public/apps/plugin.ts index eec49418910f8..e73598c44c9f0 100644 --- a/x-pack/legacy/plugins/uptime/public/apps/plugin.ts +++ b/x-pack/legacy/plugins/uptime/public/apps/plugin.ts @@ -4,23 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { - LegacyCoreStart, - LegacyCoreSetup, - PluginInitializerContext, - AppMountParameters, -} from 'src/core/public'; -import { PluginsStart, PluginsSetup } from 'ui/new_platform/new_platform'; +import { LegacyCoreSetup, PluginInitializerContext, AppMountParameters } from 'src/core/public'; +import { PluginsSetup } from 'ui/new_platform/new_platform'; import { FeatureCatalogueCategory } from '../../../../../../src/plugins/home/public'; import { UMFrontendLibs } from '../lib/lib'; import { PLUGIN } from '../../common/constants'; import { getKibanaFrameworkAdapter } from '../lib/adapters/framework/new_platform_adapter'; -export interface StartObject { - core: LegacyCoreStart; - plugins: PluginsStart; -} - export interface SetupObject { core: LegacyCoreSetup; plugins: PluginsSetup; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/location_link.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/common/__tests__/__snapshots__/location_link.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/location_link.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/common/__tests__/__snapshots__/location_link.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/uptime_date_picker.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/common/__tests__/__snapshots__/uptime_date_picker.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/uptime_date_picker.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/common/__tests__/__snapshots__/uptime_date_picker.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/location_link.test.tsx b/x-pack/legacy/plugins/uptime/public/components/common/__tests__/location_link.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/location_link.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/__tests__/location_link.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/uptime_date_picker.test.tsx b/x-pack/legacy/plugins/uptime/public/components/common/__tests__/uptime_date_picker.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/uptime_date_picker.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/__tests__/uptime_date_picker.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/chart_empty_state.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/chart_empty_state.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/chart_empty_state.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/chart_empty_state.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/chart_wrapper.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/chart_wrapper.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/chart_wrapper.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/chart_wrapper.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/donut_chart.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/donut_chart.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/donut_chart.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/donut_chart.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/donut_chart_legend.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/donut_chart_legend.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/donut_chart_legend.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/donut_chart_legend.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/donut_chart_legend_row.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/donut_chart_legend_row.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/donut_chart_legend_row.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/donut_chart_legend_row.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/duration_charts.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/duration_charts.test.tsx.snap similarity index 99% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/duration_charts.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/duration_charts.test.tsx.snap index 6c38f3e338cfd..96918ab68f716 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/__snapshots__/duration_charts.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/__snapshots__/duration_charts.test.tsx.snap @@ -53,7 +53,6 @@ exports[`MonitorCharts component renders the component without errors 1`] = ` > { const component = shallowWithRouter( diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/get_tick_format.test.ts b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/get_tick_format.test.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/get_tick_format.test.ts rename to x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/get_tick_format.test.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/monitor_bar_series.test.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/monitor_bar_series.test.tsx similarity index 90% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/monitor_bar_series.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/monitor_bar_series.test.tsx index 5d4e112aa5f28..4522f8d633fa6 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/monitor_bar_series.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/monitor_bar_series.test.tsx @@ -7,14 +7,13 @@ import React from 'react'; import { MonitorBarSeries, MonitorBarSeriesProps } from '../monitor_bar_series'; import { renderWithRouter, shallowWithRouter } from '../../../../lib'; -import { SummaryHistogramPoint } from '../../../../../common/graphql/types'; +import { HistogramPoint } from '../../../../../common/runtime_types'; describe('MonitorBarSeries component', () => { let props: MonitorBarSeriesProps; - let histogramSeries: SummaryHistogramPoint[]; + let histogramSeries: HistogramPoint[]; beforeEach(() => { props = { - dangerColor: 'A danger color', histogramSeries: [ { timestamp: 124, @@ -193,16 +192,12 @@ describe('MonitorBarSeries component', () => { }); it('shallow renders nothing if the data series is null', () => { - const component = shallowWithRouter( - - ); + const component = shallowWithRouter(); expect(component).toEqual({}); }); it('renders if the data series is present', () => { - const component = renderWithRouter( - - ); + const component = renderWithRouter(); expect(component).toMatchSnapshot(); }); }); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/ping_histogram.test.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/ping_histogram.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/__tests__/ping_histogram.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/__tests__/ping_histogram.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/annotation_tooltip.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/annotation_tooltip.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/annotation_tooltip.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/annotation_tooltip.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_empty_state.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/chart_empty_state.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_empty_state.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/chart_empty_state.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_wrapper/chart_wrapper.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/chart_wrapper/chart_wrapper.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_wrapper/chart_wrapper.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/chart_wrapper/chart_wrapper.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_wrapper/index.ts b/x-pack/legacy/plugins/uptime/public/components/common/charts/chart_wrapper/index.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/chart_wrapper/index.ts rename to x-pack/legacy/plugins/uptime/public/components/common/charts/chart_wrapper/index.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/donut_chart.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/donut_chart.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/donut_chart.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/donut_chart.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/donut_chart_legend.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/donut_chart_legend.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/donut_chart_legend.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/donut_chart_legend.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/donut_chart_legend_row.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/donut_chart_legend_row.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/donut_chart_legend_row.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/donut_chart_legend_row.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/common/charts/duration_chart.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/duration_chart.tsx new file mode 100644 index 0000000000000..c82b2a1cf9fe2 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/common/charts/duration_chart.tsx @@ -0,0 +1,122 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useState } from 'react'; +import { i18n } from '@kbn/i18n'; +import moment from 'moment'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { Axis, Chart, Position, timeFormatter, Settings, SeriesIdentifier } from '@elastic/charts'; +import { getChartDateLabel } from '../../../lib/helper'; +import { LocationDurationLine } from '../../../../common/types'; +import { DurationLineSeriesList } from './duration_line_series_list'; +import { ChartWrapper } from './chart_wrapper'; +import { useUrlParams } from '../../../hooks'; +import { getTickFormat } from './get_tick_format'; +import { ChartEmptyState } from './chart_empty_state'; +import { DurationAnomaliesBar } from './duration_line_bar_list'; +import { AnomalyRecords } from '../../../state/actions'; + +interface DurationChartProps { + /** + * Timeseries data that is used to express an average line series + * on the duration chart. One entry per location + */ + locationDurationLines: LocationDurationLine[]; + + /** + * To represent the loading spinner on chart + */ + loading: boolean; + + anomalies: AnomalyRecords | null; +} + +/** + * This chart is intended to visualize monitor duration performance over time to + * the users in a helpful way. Its x-axis is based on a timeseries, the y-axis is in + * milliseconds. + * @param props The props required for this component to render properly + */ +export const DurationChartComponent = ({ + locationDurationLines, + anomalies, + loading, +}: DurationChartProps) => { + const hasLines = locationDurationLines.length > 0; + const [getUrlParams, updateUrlParams] = useUrlParams(); + const { absoluteDateRangeStart: min, absoluteDateRangeEnd: max } = getUrlParams(); + + const [hiddenLegends, setHiddenLegends] = useState([]); + + const onBrushEnd = (minX: number, maxX: number) => { + updateUrlParams({ + dateRangeStart: moment(minX).toISOString(), + dateRangeEnd: moment(maxX).toISOString(), + }); + }; + + const legendToggleVisibility = (legendItem: SeriesIdentifier | null) => { + if (legendItem) { + setHiddenLegends(prevState => { + if (prevState.includes(legendItem.specId)) { + return [...prevState.filter(item => item !== legendItem.specId)]; + } else { + return [...prevState, legendItem.specId]; + } + }); + } + }; + + return ( + + {hasLines ? ( + + + + getTickFormat(d)} + title={i18n.translate('xpack.uptime.monitorCharts.durationChart.leftAxis.title', { + defaultMessage: 'Duration ms', + })} + /> + + + + ) : ( + up }} + /> + } + title={i18n.translate('xpack.uptime.durationChart.emptyPrompt.title', { + defaultMessage: 'No duration data available', + })} + /> + )} + + ); +}; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_line_bar_list.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/duration_line_bar_list.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_line_bar_list.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/duration_line_bar_list.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_line_series_list.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/duration_line_series_list.tsx similarity index 97% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_line_series_list.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/duration_line_series_list.tsx index 912bc5bb0501b..4223e918393b6 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_line_series_list.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/common/charts/duration_line_series_list.tsx @@ -21,7 +21,7 @@ export const DurationLineSeriesList = ({ lines }: Props) => ( // this id is used for the line chart representing the average duration length data={line.map(({ x, y }) => [x, microsToMillis(y || null)])} id={`loc-avg-${name}`} - key={`locline-${name}`} + key={`loc-line-${name}`} name={name} xAccessor={0} xScaleType="time" diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/get_tick_format.ts b/x-pack/legacy/plugins/uptime/public/components/common/charts/get_tick_format.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/get_tick_format.ts rename to x-pack/legacy/plugins/uptime/public/components/common/charts/get_tick_format.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/index.ts b/x-pack/legacy/plugins/uptime/public/components/common/charts/index.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/index.ts rename to x-pack/legacy/plugins/uptime/public/components/common/charts/index.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/monitor_bar_series.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/monitor_bar_series.tsx similarity index 87% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/monitor_bar_series.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/monitor_bar_series.tsx index 6a1e255d308d7..5e11685e36140 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/monitor_bar_series.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/common/charts/monitor_bar_series.tsx @@ -14,23 +14,20 @@ import { timeFormatter, } from '@elastic/charts'; import { i18n } from '@kbn/i18n'; -import React from 'react'; +import React, { useContext } from 'react'; import moment from 'moment'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiText, EuiToolTip } from '@elastic/eui'; -import { SummaryHistogramPoint } from '../../../../common/graphql/types'; +import { HistogramPoint } from '../../../../common/runtime_types'; import { getChartDateLabel, seriesHasDownValues } from '../../../lib/helper'; import { useUrlParams } from '../../../hooks'; +import { UptimeThemeContext } from '../../../contexts'; export interface MonitorBarSeriesProps { - /** - * The color to use for the display of down states. - */ - dangerColor: string; /** * The timeseries data to display. */ - histogramSeries: SummaryHistogramPoint[] | null; + histogramSeries: HistogramPoint[] | null; } /** @@ -38,7 +35,10 @@ export interface MonitorBarSeriesProps { * so we will only render the series component if there are down counts for the selected monitor. * @param props - the values for the monitor this chart visualizes */ -export const MonitorBarSeries = ({ dangerColor, histogramSeries }: MonitorBarSeriesProps) => { +export const MonitorBarSeries = ({ histogramSeries }: MonitorBarSeriesProps) => { + const { + colors: { danger }, + } = useContext(UptimeThemeContext); const [getUrlParams, updateUrlParams] = useUrlParams(); const { absoluteDateRangeStart, absoluteDateRangeEnd } = getUrlParams(); @@ -68,7 +68,7 @@ export const MonitorBarSeries = ({ dangerColor, histogramSeries }: MonitorBarSer /> [timestamp, down])} name={i18n.translate('xpack.uptime.monitorList.downLineSeries.downLabel', { defaultMessage: 'Down checks', diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/ping_histogram.tsx b/x-pack/legacy/plugins/uptime/public/components/common/charts/ping_histogram.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/charts/ping_histogram.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/charts/ping_histogram.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/higher_order/__tests__/__snapshots__/responsive_wrapper.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/common/higher_order/__tests__/__snapshots__/responsive_wrapper.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/higher_order/__tests__/__snapshots__/responsive_wrapper.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/common/higher_order/__tests__/__snapshots__/responsive_wrapper.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/higher_order/__tests__/responsive_wrapper.test.tsx b/x-pack/legacy/plugins/uptime/public/components/common/higher_order/__tests__/responsive_wrapper.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/higher_order/__tests__/responsive_wrapper.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/higher_order/__tests__/responsive_wrapper.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/higher_order/index.ts b/x-pack/legacy/plugins/uptime/public/components/common/higher_order/index.ts similarity index 79% rename from x-pack/legacy/plugins/uptime/public/components/higher_order/index.ts rename to x-pack/legacy/plugins/uptime/public/components/common/higher_order/index.ts index e0e14456cfc68..0682f6d0478f3 100644 --- a/x-pack/legacy/plugins/uptime/public/components/higher_order/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/common/higher_order/index.ts @@ -4,5 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { UptimeGraphQLQueryProps, withUptimeGraphQL } from './uptime_graphql_query'; export { ResponsiveWrapperProps, withResponsiveWrapper } from './responsive_wrapper'; diff --git a/x-pack/legacy/plugins/uptime/public/components/higher_order/responsive_wrapper.tsx b/x-pack/legacy/plugins/uptime/public/components/common/higher_order/responsive_wrapper.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/higher_order/responsive_wrapper.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/higher_order/responsive_wrapper.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/location_link.tsx b/x-pack/legacy/plugins/uptime/public/components/common/location_link.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/location_link.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/location_link.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/uptime_date_picker.tsx b/x-pack/legacy/plugins/uptime/public/components/common/uptime_date_picker.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/uptime_date_picker.tsx rename to x-pack/legacy/plugins/uptime/public/components/common/uptime_date_picker.tsx index 7d2123af8ff9c..4254004dba4e0 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/uptime_date_picker.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/common/uptime_date_picker.tsx @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiSuperDatePicker } from '@elastic/eui'; import React, { useContext } from 'react'; +import { EuiSuperDatePicker } from '@elastic/eui'; import { useUrlParams } from '../../hooks'; import { CLIENT_DEFAULTS } from '../../../common/constants'; import { UptimeRefreshContext, UptimeSettingsContext } from '../../contexts'; diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx b/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx deleted file mode 100644 index cf35dbf4e5206..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/connected/charts/ping_histogram.tsx +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { useEffect } from 'react'; -import { connect } from 'react-redux'; -import { AppState } from '../../../state'; -import { - PingHistogramComponent, - PingHistogramComponentProps, -} from '../../functional/charts/ping_histogram'; -import { getPingHistogram } from '../../../state/actions'; -import { selectPingHistogram } from '../../../state/selectors'; -import { withResponsiveWrapper, ResponsiveWrapperProps } from '../../higher_order'; -import { GetPingHistogramParams, HistogramResult } from '../../../../common/runtime_types'; -import { useGetUrlParams } from '../../../hooks'; - -type Props = ResponsiveWrapperProps & - Pick & - DispatchProps & { lastRefresh: number; monitorId?: string; esKuery?: string }; - -const PingHistogramContainer: React.FC = ({ - data, - loadData, - monitorId, - lastRefresh, - height, - loading, - esKuery, -}) => { - const { - absoluteDateRangeStart, - absoluteDateRangeEnd, - dateRangeStart: dateStart, - dateRangeEnd: dateEnd, - statusFilter, - } = useGetUrlParams(); - - useEffect(() => { - loadData({ monitorId, dateStart, dateEnd, statusFilter, filters: esKuery }); - }, [loadData, dateStart, dateEnd, monitorId, statusFilter, lastRefresh, esKuery]); - return ( - - ); -}; - -interface StateProps { - data: HistogramResult | null; - loading: boolean; - lastRefresh: number; - esKuery: string; -} - -interface DispatchProps { - loadData: typeof getPingHistogram; -} - -const mapStateToProps = (state: AppState): StateProps => ({ ...selectPingHistogram(state) }); - -const mapDispatchToProps = (dispatch: any): DispatchProps => ({ - loadData: (params: GetPingHistogramParams) => { - return dispatch(getPingHistogram(params)); - }, -}); - -export const PingHistogram = connect< - StateProps, - DispatchProps, - Pick, - AppState ->( - mapStateToProps, - mapDispatchToProps -)(withResponsiveWrapper(PingHistogramContainer)); diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/charts/snapshot_container.tsx b/x-pack/legacy/plugins/uptime/public/components/connected/charts/snapshot_container.tsx deleted file mode 100644 index 39ead242527f8..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/connected/charts/snapshot_container.tsx +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { useEffect } from 'react'; -import { connect } from 'react-redux'; -import { useGetUrlParams } from '../../../hooks'; -import { AppState } from '../../../state'; -import { getSnapshotCountAction } from '../../../state/actions'; -import { SnapshotComponent } from '../../functional/snapshot'; -import { Snapshot as SnapshotType } from '../../../../common/runtime_types'; -import { SnapShotQueryParams } from '../../../state/api'; - -/** - * Props expected from parent components. - */ -interface OwnProps { - /** - * Height is needed, since by default charts takes height of 100% - */ - height?: string; -} - -/** - * Props given by the Redux store based on action input. - */ -interface StoreProps { - count: SnapshotType; - lastRefresh: number; - loading: boolean; - esKuery: string; -} - -/** - * Contains functions that will dispatch actions used - * for this component's life cycle - */ -interface DispatchProps { - loadSnapshotCount: typeof getSnapshotCountAction; -} - -/** - * Props used to render the Snapshot component. - */ -type Props = OwnProps & StoreProps & DispatchProps; - -export const Container: React.FC = ({ - count, - height, - lastRefresh, - loading, - esKuery, - loadSnapshotCount, -}: Props) => { - const { dateRangeStart, dateRangeEnd, statusFilter } = useGetUrlParams(); - - useEffect(() => { - loadSnapshotCount({ dateRangeStart, dateRangeEnd, filters: esKuery, statusFilter }); - }, [dateRangeStart, dateRangeEnd, esKuery, lastRefresh, loadSnapshotCount, statusFilter]); - return ; -}; - -/** - * Provides state to connected component. - * @param state the root app state - */ -const mapStateToProps = ({ - snapshot: { count, loading }, - ui: { lastRefresh, esKuery }, -}: AppState): StoreProps => ({ - count, - lastRefresh, - loading, - esKuery, -}); - -/** - * Used for fetching snapshot counts. - * @param dispatch redux-provided action dispatcher - */ -const mapDispatchToProps = (dispatch: any) => ({ - loadSnapshotCount: (params: SnapShotQueryParams): DispatchProps => { - return dispatch(getSnapshotCountAction(params)); - }, -}); - -export const Snapshot = connect( - // @ts-ignore connect is expecting null | undefined for some reason - mapStateToProps, - mapDispatchToProps -)(Container); diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/index.ts b/x-pack/legacy/plugins/uptime/public/components/connected/index.ts deleted file mode 100644 index be3cc5b65aa0e..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/connected/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { AlertMonitorStatus, ToggleAlertFlyoutButton, UptimeAlertsFlyoutWrapper } from './alerts'; -export { PingHistogram } from './charts/ping_histogram'; -export { Snapshot } from './charts/snapshot_container'; -export { KueryBar } from './kuerybar/kuery_bar_container'; -export { FilterGroup } from './filter_group/filter_group_container'; -export { MonitorStatusDetails } from './monitor/status_details_container'; -export { MonitorStatusBar } from './monitor/status_bar_container'; -export { MonitorListDrawer } from './monitor/list_drawer_container'; -export { MonitorListActionsPopover } from './monitor/drawer_popover_container'; -export { PingList, PingListProps } from './pings'; -export { DurationChart } from './charts/monitor_duration'; -export { EmptyState } from './empty_state/empty_state'; diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/monitor/status_bar_container.tsx b/x-pack/legacy/plugins/uptime/public/components/connected/monitor/status_bar_container.tsx deleted file mode 100644 index 3a96aa7c0275b..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/connected/monitor/status_bar_container.tsx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { useContext, useEffect } from 'react'; -import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; -import { AppState } from '../../../state'; -import { monitorLocationsSelector, monitorStatusSelector } from '../../../state/selectors'; -import { MonitorStatusBarComponent } from '../../functional/monitor_status_details/monitor_status_bar'; -import { getMonitorStatusAction } from '../../../state/actions'; -import { useGetUrlParams } from '../../../hooks'; -import { Ping } from '../../../../common/runtime_types'; -import { MonitorLocations } from '../../../../common/runtime_types/monitor'; -import { UptimeRefreshContext } from '../../../contexts'; - -interface StateProps { - monitorStatus: Ping; - monitorLocations: MonitorLocations; -} - -interface DispatchProps { - loadMonitorStatus: typeof getMonitorStatusAction; -} - -interface OwnProps { - monitorId: string; -} - -type Props = OwnProps & StateProps & DispatchProps; - -const Container: React.FC = ({ - loadMonitorStatus, - monitorId, - monitorStatus, - monitorLocations, -}: Props) => { - const { lastRefresh } = useContext(UptimeRefreshContext); - - const { dateRangeStart: dateStart, dateRangeEnd: dateEnd } = useGetUrlParams(); - - useEffect(() => { - loadMonitorStatus({ dateStart, dateEnd, monitorId }); - }, [monitorId, dateStart, dateEnd, loadMonitorStatus, lastRefresh]); - - return ( - - ); -}; - -const mapStateToProps = (state: AppState, ownProps: OwnProps) => ({ - monitorStatus: monitorStatusSelector(state), - monitorLocations: monitorLocationsSelector(state, ownProps.monitorId), -}); - -const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({ - loadMonitorStatus: params => dispatch(getMonitorStatusAction(params)), -}); - -// @ts-ignore TODO: Investigate typescript issues here -export const MonitorStatusBar = connect( - // @ts-ignore TODO: Investigate typescript issues here - mapStateToProps, - mapDispatchToProps -)(Container); diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/monitor/status_details_container.tsx b/x-pack/legacy/plugins/uptime/public/components/connected/monitor/status_details_container.tsx deleted file mode 100644 index 9d2e48830fbfe..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/connected/monitor/status_details_container.tsx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { useContext, useEffect } from 'react'; -import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; -import { useGetUrlParams } from '../../../hooks'; -import { AppState } from '../../../state'; -import { monitorLocationsSelector } from '../../../state/selectors'; -import { getMonitorLocationsAction, MonitorLocationsPayload } from '../../../state/actions/monitor'; -import { MonitorStatusDetailsComponent } from '../../functional/monitor_status_details'; -import { MonitorLocations } from '../../../../common/runtime_types'; -import { UptimeRefreshContext } from '../../../contexts'; - -interface OwnProps { - monitorId: string; -} - -interface StoreProps { - monitorLocations: MonitorLocations; -} - -interface DispatchProps { - loadMonitorLocations: typeof getMonitorLocationsAction; -} - -type Props = OwnProps & StoreProps & DispatchProps; - -export const Container: React.FC = ({ - loadMonitorLocations, - monitorLocations, - monitorId, -}: Props) => { - const { lastRefresh } = useContext(UptimeRefreshContext); - - const { dateRangeStart: dateStart, dateRangeEnd: dateEnd } = useGetUrlParams(); - - useEffect(() => { - loadMonitorLocations({ dateStart, dateEnd, monitorId }); - }, [loadMonitorLocations, monitorId, dateStart, dateEnd, lastRefresh]); - - return ( - - ); -}; -const mapStateToProps = (state: AppState, { monitorId }: OwnProps) => ({ - monitorLocations: monitorLocationsSelector(state, monitorId), -}); - -const mapDispatchToProps = (dispatch: Dispatch) => ({ - loadMonitorLocations: (params: MonitorLocationsPayload) => { - dispatch(getMonitorLocationsAction(params)); - }, -}); - -export const MonitorStatusDetails = connect( - // @ts-ignore TODO: Investigate typescript issues here - mapStateToProps, - mapDispatchToProps -)(Container); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_chart.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_chart.tsx deleted file mode 100644 index d149e7a6deb5a..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/charts/duration_chart.tsx +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { useState } from 'react'; -import { i18n } from '@kbn/i18n'; -import moment from 'moment'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiTitle } from '@elastic/eui'; -import { Axis, Chart, Position, timeFormatter, Settings } from '@elastic/charts'; -import { SeriesIdentifier } from '@elastic/charts/dist/chart_types/xy_chart/utils/series'; -import { getChartDateLabel } from '../../../lib/helper'; -import { LocationDurationLine } from '../../../../common/types'; -import { DurationLineSeriesList } from './duration_line_series_list'; -import { ChartWrapper } from './chart_wrapper'; -import { useUrlParams } from '../../../hooks'; -import { getTickFormat } from './get_tick_format'; -import { ChartEmptyState } from './chart_empty_state'; -import { DurationAnomaliesBar } from './duration_line_bar_list'; -import { MLIntegrationComponent } from '../../monitor_details/ml/ml_integeration'; -import { AnomalyRecords } from '../../../state/actions'; - -interface DurationChartProps { - /** - * Timeseries data that is used to express an average line series - * on the duration chart. One entry per location - */ - locationDurationLines: LocationDurationLine[]; - - /** - * To represent the loading spinner on chart - */ - loading: boolean; - - hasMLJob: boolean; - - anomalies: AnomalyRecords | null; -} - -/** - * This chart is intended to visualize monitor duration performance over time to - * the users in a helpful way. Its x-axis is based on a timeseries, the y-axis is in - * milliseconds. - * @param props The props required for this component to render properly - */ -export const DurationChartComponent = ({ - locationDurationLines, - anomalies, - loading, - hasMLJob, -}: DurationChartProps) => { - const hasLines = locationDurationLines.length > 0; - const [getUrlParams, updateUrlParams] = useUrlParams(); - const { absoluteDateRangeStart: min, absoluteDateRangeEnd: max } = getUrlParams(); - - const [hiddenLegends, setHiddenLegends] = useState([]); - - const onBrushEnd = (minX: number, maxX: number) => { - updateUrlParams({ - dateRangeStart: moment(minX).toISOString(), - dateRangeEnd: moment(maxX).toISOString(), - }); - }; - - const legendToggleVisibility = (legendItem: SeriesIdentifier | null) => { - if (legendItem) { - setHiddenLegends(prevState => { - if (prevState.includes(legendItem.specId)) { - return [...prevState.filter(item => item !== legendItem.specId)]; - } else { - return [...prevState, legendItem.specId]; - } - }); - } - }; - - return ( - <> - - - - -

- {hasMLJob ? ( - - ) : ( - - )} -

-
-
- - - -
- - - {hasLines ? ( - - - - getTickFormat(d)} - title={i18n.translate('xpack.uptime.monitorCharts.durationChart.leftAxis.title', { - defaultMessage: 'Duration ms', - })} - /> - - - - ) : ( - up }} - /> - } - title={i18n.translate('xpack.uptime.durationChart.emptyPrompt.title', { - defaultMessage: 'No duration data available', - })} - /> - )} - -
- - ); -}; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/__snapshots__/data_missing.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/__snapshots__/data_missing.test.tsx.snap deleted file mode 100644 index 2182bfb4e656c..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/__snapshots__/data_missing.test.tsx.snap +++ /dev/null @@ -1,52 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`DataMissing component renders basePath and headingMessage 1`] = ` - - - - - - - - , - } - } - /> -

- } - iconType="uptimeApp" - title={ - -

- bar -

-
- } - /> -
-
-
-`; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/__snapshots__/empty_state.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/__snapshots__/empty_state.test.tsx.snap deleted file mode 100644 index 2d45bbd18a60c..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/__snapshots__/empty_state.test.tsx.snap +++ /dev/null @@ -1,1141 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`EmptyState component does not render empty state with appropriate base path and no docs 1`] = ` - - - -
- -
- -
- - -
- - - - , - } - } - /> -

- } - iconType="uptimeApp" - title={ - -

- No uptime data found -

-
- } - > -
- -
- - -
- - - - - -

- No uptime data found -

-
-
- -
- - -
-

- - - , - } - } - > - - - - Configure Heartbeat - - - - to start logging uptime data. - -

-
-
- - -
- -
- -
- -
- - - -`; - -exports[`EmptyState component doesn't render child components when count is falsy 1`] = ` - - - - - - -

- Loading… -

-
- - } - > -
- - - -
- - - - -
- - -

- Loading… -

-
-
- - - -
- - - -`; - -exports[`EmptyState component notifies when index does not exist 1`] = ` - - - -
- -
- -
- - -
- - - - , - } - } - /> -

- } - iconType="uptimeApp" - title={ - -

- Uptime index not found -

-
- } - > -
- -
- - -
- - - - - -

- Uptime index not found -

-
-
- -
- - -
-

- - - , - } - } - > - - - - Configure Heartbeat - - - - to start logging uptime data. - -

-
-
- - -
- -
- -
- -
- - - -`; - -exports[`EmptyState component renders child components when count is truthy 1`] = ` - -
- Foo -
-
- Bar -
-
- Baz -
-
-`; - -exports[`EmptyState component renders error message when an error occurs 1`] = ` - - - -
- -
- -
- -

- There was an error fetching your data. -

- - } - iconColor="subdued" - iconType="securityApp" - title={ - -

- Error -

-
- } - > -
- -
- - -
- - - - - -

- Error -

-
-
- -
- - -
-

- There was an error fetching your data. -

-
-
- - -
- -
- -
- -
- - - -`; - -exports[`EmptyState component renders loading state if no errors or doc count 1`] = ` - - - - - - -

- Loading… -

-
- - } - > -
- - - -
- - - - -
- - -

- Loading… -

-
-
- - - -
- - - -`; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/data_missing.test.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/data_missing.test.tsx deleted file mode 100644 index 8605d2966aaae..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/data_missing.test.tsx +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -import React from 'react'; -import { DataMissing } from '../data_missing'; - -describe('DataMissing component', () => { - it('renders basePath and headingMessage', () => { - const component = shallowWithIntl(); - expect(component).toMatchSnapshot(); - }); -}); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/data_missing.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/data_missing.tsx deleted file mode 100644 index 337c08774e8e8..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/data_missing.tsx +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { - EuiFlexGroup, - EuiEmptyPrompt, - EuiFlexItem, - EuiSpacer, - EuiPanel, - EuiTitle, - EuiLink, -} from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; -import React, { useContext } from 'react'; -import { UptimeSettingsContext } from '../../../contexts'; - -interface DataMissingProps { - headingMessage: string; -} - -export const DataMissing = ({ headingMessage }: DataMissingProps) => { - const { basePath } = useContext(UptimeSettingsContext); - return ( - - - - - -

{headingMessage}

- - } - body={ -

- - - - ), - }} - /> -

- } - /> -
-
-
- ); -}; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_index.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_index.tsx deleted file mode 100644 index 0141198ec15e0..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_index.tsx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { - EuiEmptyPrompt, - EuiFlexGroup, - EuiFlexItem, - EuiLink, - EuiPanel, - EuiSpacer, - EuiTitle, -} from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; -import React, { Fragment } from 'react'; - -interface EmptyIndexProps { - basePath: string; -} - -export const EmptyIndex = ({ basePath }: EmptyIndexProps) => ( - - - - - -

- -

- - } - body={ - -

- - - - ), - }} - /> -

-
- } - /> -
-
-
-); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/index.ts b/x-pack/legacy/plugins/uptime/public/components/functional/index.ts deleted file mode 100644 index d82912a6216e8..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { - ToggleAlertFlyoutButtonComponent, - UptimeAlertsContextProvider, - UptimeAlertsFlyoutWrapperComponent, -} from './alerts'; -export * from './alerts'; -export { DonutChart } from './charts/donut_chart'; -export { KueryBarComponent } from './kuery_bar/kuery_bar'; -export { MonitorCharts } from './monitor_charts'; -export { MonitorList } from './monitor_list'; -export { OverviewPageParsingErrorCallout } from './overview_page_parsing_error_callout'; -export { PingListComponent } from './ping_list'; -export { PingHistogramComponent } from './charts'; -export { StatusPanel } from './status_panel'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_list_pagination.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_list_pagination.test.tsx.snap deleted file mode 100644 index db5bfa72deb36..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_list_pagination.test.tsx.snap +++ /dev/null @@ -1,307 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`MonitorListPagination component renders a no items message when no data is provided 1`] = ` - - - -
- -
-
- - - - - - - - - - - - - - - - - - -
-
-`; - -exports[`MonitorListPagination component renders the monitor list 1`] = ` - - - -
- -
-
- - - - - - - - - - - - - - - - - - -
-
-`; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list.test.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list.test.tsx deleted file mode 100644 index d2030155d0092..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list.test.tsx +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -import React from 'react'; -import { MonitorSummaryResult } from '../../../../../common/graphql/types'; -import { MonitorListComponent } from '../monitor_list'; -import { renderWithRouter } from '../../../../lib'; - -describe('MonitorList component', () => { - let result: MonitorSummaryResult; - - beforeEach(() => { - result = { - summaries: [ - { - monitor_id: 'foo', - state: { - checks: [ - { - monitor: { - ip: '127.0.0.1', - status: 'up', - }, - timestamp: '124', - }, - { - monitor: { - ip: '127.0.0.2', - status: 'down', - }, - timestamp: '125', - }, - { - monitor: { - ip: '127.0.0.3', - status: 'down', - }, - timestamp: '126', - }, - ], - summary: { - up: 1, - down: 2, - }, - timestamp: '123', - }, - }, - { - monitor_id: 'bar', - state: { - checks: [ - { - monitor: { - ip: '127.0.0.1', - status: 'up', - }, - timestamp: '125', - }, - { - monitor: { - ip: '127.0.0.2', - status: 'up', - }, - timestamp: '126', - }, - ], - summary: { - up: 2, - down: 0, - }, - timestamp: '125', - }, - }, - ], - totalSummaryCount: 2, - }; - }); - - it('shallow renders the monitor list', () => { - const component = shallowWithIntl( - - ); - - expect(component).toMatchSnapshot(); - }); - - it('renders a no items message when no data is provided', () => { - const component = shallowWithIntl( - - ); - expect(component).toMatchSnapshot(); - }); - - it('renders the monitor list', () => { - const component = renderWithRouter( - - ); - - expect(component).toMatchSnapshot(); - }); -}); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list_pagination.test.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list_pagination.test.tsx deleted file mode 100644 index b08b8b3fabc3e..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list_pagination.test.tsx +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -import React from 'react'; -import { - CursorDirection, - MonitorSummaryResult, - SortOrder, -} from '../../../../../common/graphql/types'; -import { MonitorListComponent } from '../monitor_list'; - -describe('MonitorListPagination component', () => { - let result: MonitorSummaryResult; - - beforeEach(() => { - result = { - prevPagePagination: JSON.stringify({ - cursorKey: { monitor_id: 123 }, - cursorDirection: CursorDirection.BEFORE, - sortOrder: SortOrder.ASC, - }), - nextPagePagination: JSON.stringify({ - cursorKey: { monitor_id: 456 }, - cursorDirection: CursorDirection.AFTER, - sortOrder: SortOrder.ASC, - }), - summaries: [ - { - monitor_id: 'foo', - state: { - checks: [ - { - monitor: { - ip: '127.0.0.1', - status: 'up', - }, - timestamp: '124', - }, - { - monitor: { - ip: '127.0.0.2', - status: 'down', - }, - timestamp: '125', - }, - { - monitor: { - ip: '127.0.0.3', - status: 'down', - }, - timestamp: '126', - }, - ], - summary: { - up: 1, - down: 2, - }, - timestamp: '123', - }, - }, - { - monitor_id: 'bar', - state: { - checks: [ - { - monitor: { - ip: '127.0.0.1', - status: 'up', - }, - timestamp: '125', - }, - { - monitor: { - ip: '127.0.0.2', - status: 'up', - }, - timestamp: '126', - }, - ], - summary: { - up: 2, - down: 0, - }, - timestamp: '125', - }, - }, - ], - totalSummaryCount: 2, - }; - }); - - it('renders the monitor list', () => { - const component = shallowWithIntl( - - ); - - expect(component).toMatchSnapshot(); - }); - - it('renders a no items message when no data is provided', () => { - const component = shallowWithIntl( - - ); - expect(component).toMatchSnapshot(); - }); -}); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list.tsx deleted file mode 100644 index a9fb1ce2f4be1..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list.tsx +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { - EuiButtonIcon, - EuiBasicTable, - EuiFlexGroup, - EuiFlexItem, - EuiIcon, - EuiLink, - EuiPanel, - EuiSpacer, - EuiTitle, -} from '@elastic/eui'; -import { FormattedMessage } from '@kbn/i18n/react'; -import React, { useState } from 'react'; -import styled from 'styled-components'; -import { withUptimeGraphQL, UptimeGraphQLQueryProps } from '../../higher_order'; -import { monitorStatesQuery } from '../../../queries/monitor_states_query'; -import { - MonitorSummary, - MonitorSummaryResult, - SummaryHistogramPoint, -} from '../../../../common/graphql/types'; -import { MonitorListStatusColumn } from './monitor_list_status_column'; -import { formatUptimeGraphQLErrorList } from '../../../lib/helper/format_error_list'; -import { ExpandedRowMap } from './types'; -import { MonitorBarSeries } from '../charts'; -import { MonitorPageLink } from './monitor_page_link'; -import { OverviewPageLink } from './overview_page_link'; -import * as labels from './translations'; -import { MonitorListDrawer } from '../../connected'; -import { MonitorListPageSizeSelect } from './monitor_list_page_size_select'; - -interface MonitorListQueryResult { - monitorStates?: MonitorSummaryResult; -} - -interface MonitorListProps { - dangerColor: string; - hasActiveFilters: boolean; - successColor: string; - linkParameters?: string; - pageSize: number; - setPageSize: (size: number) => void; -} - -type Props = UptimeGraphQLQueryProps & MonitorListProps; - -const TruncatedEuiLink = styled(EuiLink)` - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -`; - -export const MonitorListComponent = (props: Props) => { - const { dangerColor, data, errors, hasActiveFilters, linkParameters, loading } = props; - const [drawerIds, updateDrawerIds] = useState([]); - - const items = data?.monitorStates?.summaries ?? []; - - const nextPagePagination = data?.monitorStates?.nextPagePagination ?? ''; - const prevPagePagination = data?.monitorStates?.prevPagePagination ?? ''; - - const getExpandedRowMap = () => { - return drawerIds.reduce((map: ExpandedRowMap, id: string) => { - return { - ...map, - [id]: ( - monitorId === id)} - /> - ), - }; - }, {}); - }; - - const columns = [ - { - align: 'left' as const, - field: 'state.monitor.status', - name: labels.STATUS_COLUMN_LABEL, - mobileOptions: { - fullWidth: true, - }, - render: (status: string, { state: { timestamp, checks } }: MonitorSummary) => { - return ( - - ); - }, - }, - { - align: 'left' as const, - field: 'state.monitor.name', - name: labels.NAME_COLUMN_LABEL, - mobileOptions: { - fullWidth: true, - }, - render: (name: string, summary: MonitorSummary) => ( - - {name ? name : `Unnamed - ${summary.monitor_id}`} - - ), - sortable: true, - }, - { - align: 'left' as const, - field: 'state.url.full', - name: labels.URL, - render: (url: string, summary: MonitorSummary) => ( - - {url} - - ), - }, - { - align: 'center' as const, - field: 'histogram.points', - name: labels.HISTORY_COLUMN_LABEL, - mobileOptions: { - show: false, - }, - render: (histogramSeries: SummaryHistogramPoint[] | null) => ( - - ), - }, - { - align: 'right' as const, - field: 'monitor_id', - name: '', - sortable: true, - isExpander: true, - width: '24px', - render: (id: string) => { - return ( - { - if (drawerIds.includes(id)) { - updateDrawerIds(drawerIds.filter(p => p !== id)); - } else { - updateDrawerIds([...drawerIds, id]); - } - }} - /> - ); - }, - }, - ]; - - return ( - <> - - -
- -
-
- - - - - - - - - - - - - - - - - - -
- - ); -}; - -export const MonitorList = withUptimeGraphQL( - MonitorListComponent, - monitorStatesQuery -); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/search_schema.ts b/x-pack/legacy/plugins/uptime/public/components/functional/search_schema.ts deleted file mode 100644 index bd451a9835288..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/functional/search_schema.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const filterBarSearchSchema = { - strict: true, - fields: { - 'monitor.id': { type: 'string' }, - 'monitor.status': { type: 'string' }, - 'monitor.ip': { type: 'string' }, - 'monitor.host': { type: 'string' }, - 'monitor.scheme': { type: 'string' }, - 'url.port': { type: 'number' }, - }, -}; diff --git a/x-pack/legacy/plugins/uptime/public/components/higher_order/uptime_graphql_query.tsx b/x-pack/legacy/plugins/uptime/public/components/higher_order/uptime_graphql_query.tsx deleted file mode 100644 index 6839050cec7a8..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/components/higher_order/uptime_graphql_query.tsx +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { OperationVariables } from 'apollo-client'; -import { GraphQLError } from 'graphql'; -import React, { Fragment, useContext, useEffect, useState } from 'react'; -import { withApollo, WithApolloClient } from 'react-apollo'; -import { formatUptimeGraphQLErrorList } from '../../lib/helper/format_error_list'; -import { UptimeRefreshContext } from '../../contexts'; - -export interface UptimeGraphQLQueryProps { - loading: boolean; - data?: T; - errors?: GraphQLError[]; -} - -interface UptimeGraphQLProps { - implementsCustomErrorState?: boolean; - variables: OperationVariables; -} - -/** - * This HOC abstracts the task of querying our GraphQL endpoint, - * which eliminates the need for a lot of boilerplate code in the other components. - * - * @type T - the expected result's type - * @type P - any props the wrapped component will require - * @param WrappedComponent - the consuming component - * @param query - the graphQL query - */ -export function withUptimeGraphQL(WrappedComponent: any, query: any) { - type Props = UptimeGraphQLProps & WithApolloClient & P; - - return withApollo((props: Props) => { - const { lastRefresh } = useContext(UptimeRefreshContext); - const [loading, setLoading] = useState(true); - const [data, setData] = useState(undefined); - const [errors, setErrors] = useState(undefined); - let updateState = ( - loadingVal: boolean, - dataVal: T | undefined, - errorsVal: GraphQLError[] | undefined - ) => { - setLoading(loadingVal); - setData(dataVal); - setErrors(errorsVal); - }; - const { client, implementsCustomErrorState, variables } = props; - const fetch = () => { - setLoading(true); - client - .query({ fetchPolicy: 'network-only', query, variables }) - .then( - (result: any) => { - updateState(result.loading, result.data, result.errors); - }, - (result: any) => { - updateState(false, undefined, result.graphQLErrors); - } - ); - }; - useEffect(() => { - fetch(); - - /** - * If the `then` handler in `fetch`'s promise is fired after - * this component has unmounted, it will try to set state on an - * unmounted component, which indicates a memory leak and will trigger - * React warnings. - * - * We counteract this side effect by providing a cleanup function that will - * reassign the update function to do nothing with the returned values. - */ - return () => { - // this component is planned to be deprecated, for the time being - // we will want to preserve this for the reason above. - // eslint-disable-next-line react-hooks/exhaustive-deps - updateState = () => {}; - }; - }, [variables, lastRefresh]); - if (!implementsCustomErrorState && errors && errors.length > 0) { - return {formatUptimeGraphQLErrorList(errors)}; - } - return ; - }); -} diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/monitor_charts.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/__tests__/__snapshots__/monitor_charts.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/monitor_charts.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/__tests__/__snapshots__/monitor_charts.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/monitor_charts.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/__tests__/monitor_charts.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/monitor_charts.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/__tests__/monitor_charts.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor/index.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/index.ts new file mode 100644 index 0000000000000..cb7b27afded02 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export * from './ml'; +export * from './ping_list'; +export * from './location_map'; +export * from './monitor_status_details'; +export * from './ping_histogram'; +export * from './monitor_charts'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_map.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/__snapshots__/location_map.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_map.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/__snapshots__/location_map.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_missing.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/__snapshots__/location_missing.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_missing.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/__snapshots__/location_missing.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_status_tags.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/__snapshots__/location_status_tags.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_status_tags.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/__snapshots__/location_status_tags.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_map.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/location_map.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_map.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/location_map.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_missing.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/location_missing.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_missing.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/location_missing.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_status_tags.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/location_status_tags.test.tsx similarity index 97% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_status_tags.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/location_status_tags.test.tsx index 2359938dbbc35..7dde38af99fc3 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_status_tags.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/__tests__/location_status_tags.test.tsx @@ -8,9 +8,8 @@ import React from 'react'; import moment from 'moment'; import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { MonitorLocation } from '../../../../../common/runtime_types/monitor'; -import { LocationStatusTags } from '../'; +import { LocationStatusTags } from '../index'; -// Failing: https://github.com/elastic/kibana/issues/54818 describe('LocationStatusTags component', () => { let monitorLocations: MonitorLocation[]; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/__tests__/__mocks__/mock.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/__tests__/__mocks__/mock.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/__tests__/__mocks__/mock.ts rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/__tests__/__mocks__/mock.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/__tests__/map_config.test.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/__tests__/map_config.test.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/__tests__/map_config.test.ts rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/__tests__/map_config.test.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/embedded_map.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/embedded_map.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/embedded_map.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/embedded_map.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/low_poly_layer.json b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/low_poly_layer.json similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/low_poly_layer.json rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/low_poly_layer.json diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/map_config.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/map_config.ts similarity index 98% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/map_config.ts rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/map_config.ts index a43edae438252..ddb52e119fa87 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/map_config.ts +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/map_config.ts @@ -5,7 +5,7 @@ */ import lowPolyLayerFeatures from './low_poly_layer.json'; -import { LocationPoint } from './embedded_map.js'; +import { LocationPoint } from './embedded_map'; import { UptimeAppColors } from '../../../../uptime_app'; /** diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/translations.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/translations.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/embeddables/translations.ts rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/embeddables/translations.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/index.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/index.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/index.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/index.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_map.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/location_map.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_map.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/location_map.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_missing.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/location_missing.tsx similarity index 97% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_missing.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/location_missing.tsx index a20889f6cc653..6ce31e4cc8243 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_missing.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/location_missing.tsx @@ -16,7 +16,7 @@ import { } from '@elastic/eui'; import styled from 'styled-components'; import { FormattedMessage } from '@kbn/i18n/react'; -import { LocationLink } from '../monitor_list/monitor_list_drawer'; +import { LocationLink } from '../../common/location_link'; const EuiPopoverRight = styled(EuiFlexItem)` margin-left: auto; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_status_tags.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/location_map/location_status_tags.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_status_tags.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/location_map/location_status_tags.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/confirm_delete.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/confirm_delete.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/confirm_delete.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/confirm_delete.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/license_info.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/license_info.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/license_info.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/license_info.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_flyout.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/ml_flyout.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_flyout.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/ml_flyout.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_integerations.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/ml_integerations.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_integerations.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/ml_integerations.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_job_link.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/ml_job_link.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_job_link.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/ml_job_link.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_manage_job.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/ml_manage_job.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/__snapshots__/ml_manage_job.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/__snapshots__/ml_manage_job.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/confirm_delete.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/confirm_delete.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/confirm_delete.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/confirm_delete.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/license_info.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/license_info.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/license_info.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/license_info.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/ml_flyout.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/ml_flyout.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/ml_flyout.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/ml_flyout.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/ml_integerations.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/ml_integerations.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/ml_integerations.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/ml_integerations.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/ml_job_link.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/ml_job_link.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/ml_job_link.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/ml_job_link.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/ml_manage_job.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/ml_manage_job.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/__tests__/ml_manage_job.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/__tests__/ml_manage_job.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/confirm_delete.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/confirm_delete.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/confirm_delete.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/confirm_delete.tsx diff --git a/x-pack/legacy/plugins/uptime/common/domain_types/index.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/index.ts similarity index 81% rename from x-pack/legacy/plugins/uptime/common/domain_types/index.ts rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/index.ts index 1cf72ca2dac0b..c644c94d13878 100644 --- a/x-pack/legacy/plugins/uptime/common/domain_types/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/index.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export * from './monitors'; +export { ManageMLJobComponent } from './manage_ml_job'; diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/license_info.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/license_info.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/license_info.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/license_info.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/manage_ml_job.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/manage_ml_job.tsx similarity index 97% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/manage_ml_job.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/manage_ml_job.tsx index ec3e8bb2b9f68..46ac24e9455e5 100644 --- a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/manage_ml_job.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/manage_ml_job.tsx @@ -13,7 +13,7 @@ import { UptimeSettingsContext } from '../../../contexts'; import * as labels from './translations'; import { getMLJobLinkHref } from './ml_job_link'; import { useGetUrlParams } from '../../../hooks'; -import { useMonitorId } from '../../../hooks/use_monitor'; +import { useMonitorId } from '../../../hooks'; interface Props { hasMLJob: boolean; diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_flyout.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_flyout.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_flyout.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_flyout.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_flyout_container.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_flyout_container.tsx similarity index 98% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_flyout_container.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_flyout_container.tsx index a13de192cc443..c3e8579ca4837 100644 --- a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_flyout_container.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_flyout_container.tsx @@ -25,7 +25,7 @@ import { ML_JOB_ID } from '../../../../common/constants'; import { UptimeRefreshContext, UptimeSettingsContext } from '../../../contexts'; import { useGetUrlParams } from '../../../hooks'; import { getDynamicSettings } from '../../../state/actions/dynamic_settings'; -import { useMonitorId } from '../../../hooks/use_monitor'; +import { useMonitorId } from '../../../hooks'; interface Props { onClose: () => void; diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_integeration.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_integeration.tsx similarity index 98% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_integeration.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_integeration.tsx index e053ca733cb8c..4963a901f0ecc 100644 --- a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_integeration.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_integeration.tsx @@ -21,7 +21,7 @@ import * as labels from './translations'; import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; import { ManageMLJobComponent } from './manage_ml_job'; import { JobStat } from '../../../../../../../plugins/ml/common/types/data_recognizer'; -import { useMonitorId } from '../../../hooks/use_monitor'; +import { useMonitorId } from '../../../hooks'; export const MLIntegrationComponent = () => { const [isMlFlyoutOpen, setIsMlFlyoutOpen] = useState(false); diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_job_link.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_job_link.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/ml_job_link.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/ml_job_link.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/translations.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/translations.tsx similarity index 95% rename from x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/translations.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ml/translations.tsx index 32374674771e8..bcc3fca770652 100644 --- a/x-pack/legacy/plugins/uptime/public/components/monitor_details/ml/translations.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ml/translations.tsx @@ -96,13 +96,6 @@ export const MANAGE_ANOMALY_DETECTION = i18n.translate( } ); -export const VIEW_EXISTING_JOB = i18n.translate( - 'xpack.uptime.ml.enableAnomalyDetectionPanel.callout.jobExistsDescription.viewJobLinkText', - { - defaultMessage: 'View existing job', - } -); - export const ML_MANAGEMENT_PAGE = i18n.translate( 'xpack.uptime.ml.enableAnomalyDetectionPanel.manageMLJobDescription.mlJobsPageLinkText', { diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_charts.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_charts.tsx similarity index 68% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_charts.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/monitor_charts.tsx index c5edd0fd85977..f9cc1aa52b902 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_charts.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_charts.tsx @@ -6,7 +6,8 @@ import React from 'react'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; -import { PingHistogram, DurationChart } from '../connected'; +import { PingHistogram } from './ping_histogram/ping_histogram_container'; +import { MonitorDuration } from './monitor_duration/monitor_duration_container'; interface MonitorChartsProps { monitorId: string; @@ -16,10 +17,10 @@ export const MonitorCharts = ({ monitorId }: MonitorChartsProps) => { return ( - + - + ); diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_duration/index.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_duration/index.ts new file mode 100644 index 0000000000000..aa3230a3f9bc0 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_duration/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { MonitorDuration } from './monitor_duration_container'; +export { MonitorDurationComponent } from './monitor_duration'; diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_duration/monitor_duration.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_duration/monitor_duration.tsx new file mode 100644 index 0000000000000..af1c8dbdc49e3 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_duration/monitor_duration.tsx @@ -0,0 +1,66 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { EuiFlexGroup, EuiFlexItem, EuiPanel, EuiTitle } from '@elastic/eui'; +import { LocationDurationLine } from '../../../../common/types'; +import { MLIntegrationComponent } from '../ml/ml_integeration'; +import { AnomalyRecords } from '../../../state/actions'; +import { DurationChartComponent } from '../../common/charts'; + +interface DurationChartProps { + loading: boolean; + hasMLJob: boolean; + anomalies: AnomalyRecords | null; + locationDurationLines: LocationDurationLine[]; +} + +/** + * This chart is intended to visualize monitor duration performance over time to + * the users in a helpful way. Its x-axis is based on a timeseries, the y-axis is in + * milliseconds. + * @param props The props required for this component to render properly + */ +export const MonitorDurationComponent = ({ + locationDurationLines, + anomalies, + loading, + hasMLJob, +}: DurationChartProps) => { + return ( + + + + +

+ {hasMLJob ? ( + + ) : ( + + )} +

+
+
+ + + +
+ +
+ ); +}; diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/charts/monitor_duration.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_duration/monitor_duration_container.tsx similarity index 91% rename from x-pack/legacy/plugins/uptime/public/components/connected/charts/monitor_duration.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/monitor_duration/monitor_duration_container.tsx index 40480905350af..7e39b977f1271 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/charts/monitor_duration.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_duration/monitor_duration_container.tsx @@ -12,7 +12,6 @@ import { getMLCapabilitiesAction, getMonitorDurationAction, } from '../../../state/actions'; -import { DurationChartComponent } from '../../functional/charts'; import { anomaliesSelector, hasMLFeatureAvailable, @@ -22,12 +21,10 @@ import { import { UptimeRefreshContext } from '../../../contexts'; import { getMLJobId } from '../../../state/api/ml_anomaly'; import { JobStat } from '../../../../../../../plugins/ml/common/types/data_recognizer'; +import { MonitorDurationComponent } from './monitor_duration'; +import { MonitorIdParam } from '../../../../common/types'; -interface Props { - monitorId: string; -} - -export const DurationChart: React.FC = ({ monitorId }: Props) => { +export const MonitorDuration: React.FC = ({ monitorId }) => { const { dateRangeStart, dateRangeEnd, @@ -75,7 +72,7 @@ export const DurationChart: React.FC = ({ monitorId }: Props) => { }, [dispatch]); return ( - { let monitorLocations: MonitorLocation[]; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/index.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/index.ts similarity index 64% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/index.ts rename to x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/index.ts index 385788cc825a0..e95f14472e9e8 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/index.ts @@ -5,5 +5,8 @@ */ export { MonitorStatusBarComponent } from './monitor_status_bar'; -export { MonitorStatusDetailsComponent } from './monitor_status_details'; +export { MonitorStatusDetailsComponent } from './status_details'; export { StatusByLocations } from './monitor_status_bar/status_by_location'; + +export { MonitorStatusDetails } from './status_details_container'; +export { MonitorStatusBar } from './monitor_status_bar/status_bar_container'; diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/index.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/index.ts new file mode 100644 index 0000000000000..3c861412a39e9 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { MonitorSSLCertificate } from './ssl_certificate'; +export { MonitorStatusBarComponent } from './status_bar'; +export { MonitorStatusBar } from './status_bar_container'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/monitor_ssl_certificate.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/ssl_certificate.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/monitor_ssl_certificate.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/ssl_certificate.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/monitor_status_bar.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/status_bar.tsx similarity index 95% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/monitor_status_bar.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/status_bar.tsx index ac3cedc517995..36159dc29eccd 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/monitor_status_bar.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/status_bar.tsx @@ -14,7 +14,7 @@ import { EuiFlexGroup, EuiFlexItem, } from '@elastic/eui'; -import { MonitorSSLCertificate } from './monitor_ssl_certificate'; +import { MonitorSSLCertificate } from './ssl_certificate'; import * as labels from './translations'; import { StatusByLocations } from './status_by_location'; import { Ping } from '../../../../../common/runtime_types'; @@ -22,7 +22,7 @@ import { MonitorLocations } from '../../../../../common/runtime_types'; interface MonitorStatusBarProps { monitorId: string; - monitorStatus: Ping; + monitorStatus: Ping | null; monitorLocations: MonitorLocations; } diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/status_bar_container.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/status_bar_container.tsx new file mode 100644 index 0000000000000..9562295437515 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/status_bar_container.tsx @@ -0,0 +1,40 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useContext, useEffect } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { monitorLocationsSelector, monitorStatusSelector } from '../../../../state/selectors'; +import { MonitorStatusBarComponent } from './index'; +import { getMonitorStatusAction } from '../../../../state/actions'; +import { useGetUrlParams } from '../../../../hooks'; +import { UptimeRefreshContext } from '../../../../contexts'; +import { MonitorIdParam } from '../../../../../common/types'; +import { AppState } from '../../../../state'; + +export const MonitorStatusBar: React.FC = ({ monitorId }) => { + const { lastRefresh } = useContext(UptimeRefreshContext); + + const { dateRangeStart: dateStart, dateRangeEnd: dateEnd } = useGetUrlParams(); + + const dispatch = useDispatch(); + + const monitorStatus = useSelector(monitorStatusSelector); + const monitorLocations = useSelector((state: AppState) => + monitorLocationsSelector(state, monitorId) + ); + + useEffect(() => { + dispatch(getMonitorStatusAction({ dateStart, dateEnd, monitorId })); + }, [monitorId, dateStart, dateEnd, lastRefresh, dispatch]); + + return ( + + ); +}; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/status_by_location.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/status_by_location.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/status_by_location.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/status_by_location.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/translations.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/translations.ts similarity index 99% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/translations.ts rename to x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/translations.ts index 1c2844f4f6ccf..f60a1ceeaafb8 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/translations.ts +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/monitor_status_bar/translations.ts @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + import { i18n } from '@kbn/i18n'; export const healthStatusMessageAriaLabel = i18n.translate( diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_details.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/status_details.tsx similarity index 97% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_details.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/status_details.tsx index 7dea73da7bba0..ebd16b05ecb4a 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_details.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/status_details.tsx @@ -10,7 +10,7 @@ import styled from 'styled-components'; import { LocationMap } from '../location_map'; import { UptimeRefreshContext } from '../../../contexts'; import { MonitorLocations } from '../../../../common/runtime_types'; -import { MonitorStatusBar } from '../../connected'; +import { MonitorStatusBar } from './monitor_status_bar'; interface MonitorStatusDetailsProps { monitorId: string; diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/status_details_container.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/status_details_container.tsx new file mode 100644 index 0000000000000..251f3562f9d1a --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/status_details_container.tsx @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useContext, useEffect } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { useGetUrlParams } from '../../../hooks'; +import { monitorLocationsSelector } from '../../../state/selectors'; +import { getMonitorLocationsAction } from '../../../state/actions/monitor'; +import { MonitorStatusDetailsComponent } from './index'; +import { UptimeRefreshContext } from '../../../contexts'; +import { AppState } from '../../../state'; +import { MonitorIdParam } from '../../../../common/types'; + +export const MonitorStatusDetails: React.FC = ({ monitorId }) => { + const { lastRefresh } = useContext(UptimeRefreshContext); + + const { dateRangeStart: dateStart, dateRangeEnd: dateEnd } = useGetUrlParams(); + + const dispatch = useDispatch(); + const monitorLocations = useSelector((state: AppState) => + monitorLocationsSelector(state, monitorId) + ); + + useEffect(() => { + dispatch(getMonitorLocationsAction({ dateStart, dateEnd, monitorId })); + }, [monitorId, dateStart, dateEnd, lastRefresh, dispatch]); + + return ( + + ); +}; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/translations.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/translations.ts similarity index 99% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/translations.ts rename to x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/translations.ts index 1c2844f4f6ccf..f60a1ceeaafb8 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_status_details/monitor_status_bar/translations.ts +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/monitor_status_details/translations.ts @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + import { i18n } from '@kbn/i18n'; export const healthStatusMessageAriaLabel = i18n.translate( diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/pings/index.ts b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_histogram/index.ts similarity index 80% rename from x-pack/legacy/plugins/uptime/public/components/connected/pings/index.ts rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_histogram/index.ts index 95ced104e5188..c980b41167d0c 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/pings/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_histogram/index.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { PingList, PingListProps } from './ping_list'; +export { PingHistogram } from './ping_histogram_container'; diff --git a/x-pack/legacy/plugins/uptime/public/components/monitor/ping_histogram/ping_histogram_container.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_histogram/ping_histogram_container.tsx new file mode 100644 index 0000000000000..c0e17966f5b9f --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_histogram/ping_histogram_container.tsx @@ -0,0 +1,48 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useEffect } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { PingHistogramComponent } from '../../common/charts'; +import { getPingHistogram } from '../../../state/actions'; +import { selectPingHistogram } from '../../../state/selectors'; +import { useGetUrlParams } from '../../../hooks'; +import { useMonitorId } from '../../../hooks'; +import { ResponsiveWrapperProps, withResponsiveWrapper } from '../../common/higher_order'; + +interface Props { + height: string; +} + +const Container: React.FC = ({ height }) => { + const { + statusFilter, + absoluteDateRangeStart, + absoluteDateRangeEnd, + dateRangeStart: dateStart, + dateRangeEnd: dateEnd, + } = useGetUrlParams(); + + const dispatch = useDispatch(); + const monitorId = useMonitorId(); + + const { loading, data, esKuery, lastRefresh } = useSelector(selectPingHistogram); + + useEffect(() => { + dispatch(getPingHistogram({ monitorId, dateStart, dateEnd, statusFilter, filters: esKuery })); + }, [dateStart, dateEnd, monitorId, statusFilter, lastRefresh, esKuery, dispatch]); + return ( + + ); +}; + +export const PingHistogram = withResponsiveWrapper(Container); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/doc_link_body.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/__snapshots__/doc_link_body.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/doc_link_body.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/__snapshots__/doc_link_body.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/expanded_row.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/__snapshots__/expanded_row.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/expanded_row.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/__snapshots__/expanded_row.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/ping_list.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/__snapshots__/ping_list.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/__snapshots__/ping_list.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/__snapshots__/ping_list.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/doc_link_body.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/doc_link_body.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/doc_link_body.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/doc_link_body.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/expanded_row.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/expanded_row.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/expanded_row.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/expanded_row.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/ping_list.test.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_list.test.tsx similarity index 99% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/ping_list.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_list.test.tsx index ec256a886aa16..cb8413ba08a81 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/__tests__/ping_list.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/__tests__/ping_list.test.tsx @@ -7,8 +7,8 @@ import React from 'react'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { PingListComponent, toggleDetails } from '../ping_list'; -import { ExpandedRowMap } from '../../monitor_list/types'; import { Ping, PingsResponse } from '../../../../../common/runtime_types'; +import { ExpandedRowMap } from '../../../overview/monitor_list/types'; describe('PingList component', () => { let response: PingsResponse; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/doc_link_body.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/doc_link_body.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/doc_link_body.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/doc_link_body.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/expanded_row.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/expanded_row.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/expanded_row.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/expanded_row.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/index.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/index.tsx similarity index 85% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/index.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/index.tsx index 808f3f90ef015..7fc19bbc9622b 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/index.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/index.tsx @@ -5,3 +5,4 @@ */ export { PingListComponent } from './ping_list'; +export { PingList } from './ping_list_container'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/location_name.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/location_name.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/location_name.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/location_name.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/ping_list.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/ping_list.tsx similarity index 98% rename from x-pack/legacy/plugins/uptime/public/components/functional/ping_list/ping_list.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/ping_list.tsx index 934dfd961f9e0..5dfc1c0647430 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/ping_list/ping_list.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/ping_list.tsx @@ -26,9 +26,9 @@ import styled from 'styled-components'; import { Ping, GetPingsParams, DateRange } from '../../../../common/runtime_types'; import { convertMicrosecondsToMilliseconds as microsToMillis } from '../../../lib/helper'; import { LocationName } from './location_name'; -import { Pagination } from './../monitor_list'; +import { Pagination } from '../../overview/monitor_list'; import { PingListExpandedRowComponent } from './expanded_row'; -import { PingListProps } from '../../connected/pings'; +import { PingListProps } from './ping_list_container'; export const AllLocationOption = { 'data-test-subj': 'xpack.uptime.pingList.locationOptions.all', @@ -139,7 +139,7 @@ export const PingListComponent = (props: Props) => { })) ); - const hasStatus: boolean = pings.reduce( + const hasStatus = pings.reduce( (hasHttpStatus: boolean, currentPing) => hasHttpStatus || !!currentPing.http?.response?.status_code, false diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/pings/ping_list.tsx b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/ping_list_container.tsx similarity index 96% rename from x-pack/legacy/plugins/uptime/public/components/connected/pings/ping_list.tsx rename to x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/ping_list_container.tsx index 5b32a623495f1..3c3caab365e3a 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/pings/ping_list.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/monitor/ping_list/ping_list_container.tsx @@ -10,7 +10,7 @@ import { selectPingList } from '../../../state/selectors'; import { getPings } from '../../../state/actions'; import { GetPingsParams } from '../../../../common/runtime_types'; import { UptimeSettingsContext } from '../../../contexts'; -import { PingListComponent } from '../../functional'; +import { PingListComponent } from './index'; export interface PingListProps { monitorId: string; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/overview_page_parsing_error_callout.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/__tests__/__snapshots__/parsing_error_callout.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/overview_page_parsing_error_callout.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/__tests__/__snapshots__/parsing_error_callout.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/snapshot.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/__tests__/__snapshots__/snapshot.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/snapshot.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/__tests__/__snapshots__/snapshot.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/snapshot_heading.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/__tests__/__snapshots__/snapshot_heading.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/__snapshots__/snapshot_heading.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/__tests__/__snapshots__/snapshot_heading.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/overview_page_parsing_error_callout.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/__tests__/parsing_error_callout.test.tsx similarity index 76% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/overview_page_parsing_error_callout.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/__tests__/parsing_error_callout.test.tsx index fbe55dfedc2fc..01204c33b79d5 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/overview_page_parsing_error_callout.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/__tests__/parsing_error_callout.test.tsx @@ -6,13 +6,13 @@ import React from 'react'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -import { OverviewPageParsingErrorCallout } from '../overview_page_parsing_error_callout'; +import { ParsingErrorCallout } from '../parsing_error_callout'; describe('OverviewPageParsingErrorCallout', () => { it('renders without errors when a valid error is provided', () => { expect( shallowWithIntl( - ) @@ -21,6 +21,6 @@ describe('OverviewPageParsingErrorCallout', () => { it('renders without errors when an error with no message is provided', () => { const error: any = {}; - expect(shallowWithIntl()).toMatchSnapshot(); + expect(shallowWithIntl()).toMatchSnapshot(); }); }); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/snapshot.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/__tests__/snapshot.test.tsx similarity index 92% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/snapshot.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/__tests__/snapshot.test.tsx index 214b0394369f7..cfcab673dcb35 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/snapshot.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/__tests__/snapshot.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { Snapshot } from '../../../../common/runtime_types'; -import { SnapshotComponent } from '../snapshot'; +import { SnapshotComponent } from '../snapshot/snapshot'; describe('Snapshot component', () => { const snapshot: Snapshot = { diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/snapshot_heading.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/__tests__/snapshot_heading.test.tsx similarity index 93% rename from x-pack/legacy/plugins/uptime/public/components/functional/__tests__/snapshot_heading.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/__tests__/snapshot_heading.test.tsx index 70d082b26d653..805c116ef538a 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/__tests__/snapshot_heading.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/__tests__/snapshot_heading.test.tsx @@ -6,7 +6,7 @@ import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import React from 'react'; -import { SnapshotHeading } from '../snapshot_heading'; +import { SnapshotHeading } from '../snapshot/snapshot_heading'; describe('SnapshotHeading', () => { it('renders custom heading for no down monitors', () => { diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/alerts/__tests__/alert_monitor_status.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/__tests__/alert_monitor_status.test.tsx similarity index 98% rename from x-pack/legacy/plugins/uptime/public/components/functional/alerts/__tests__/alert_monitor_status.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/__tests__/alert_monitor_status.test.tsx index af8d17d1fc242..8f33b6f652b9d 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/alerts/__tests__/alert_monitor_status.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/__tests__/alert_monitor_status.test.tsx @@ -14,8 +14,8 @@ import { mountWithIntl } from 'test_utils/enzyme_helpers'; describe('alert monitor status component', () => { describe('handleAlertFieldNumberChange', () => { - let mockSetIsInvalid: jest.Mock; - let mockSetFieldValue: jest.Mock; + let mockSetIsInvalid: jest.Mock; + let mockSetFieldValue: jest.Mock; beforeEach(() => { mockSetIsInvalid = jest.fn(); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/alerts/alert_monitor_status.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/alert_monitor_status.tsx similarity index 99% rename from x-pack/legacy/plugins/uptime/public/components/functional/alerts/alert_monitor_status.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/alert_monitor_status.tsx index b86e85f35b17d..83892bf23dced 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/alerts/alert_monitor_status.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/alert_monitor_status.tsx @@ -19,7 +19,7 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { DataPublicPluginSetup } from 'src/plugins/data/public'; -import { KueryBar } from '../../connected/kuerybar/kuery_bar_container'; +import { KueryBar } from '..'; interface AlertFieldNumberProps { 'aria-label': string; diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/alerts/alert_monitor_status.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx similarity index 86% rename from x-pack/legacy/plugins/uptime/public/components/connected/alerts/alert_monitor_status.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx index 1529ab6db8875..9dd27db0be607 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/alerts/alert_monitor_status.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx @@ -7,8 +7,8 @@ import React from 'react'; import { useSelector } from 'react-redux'; import { DataPublicPluginSetup } from 'src/plugins/data/public'; -import { selectMonitorStatusAlert } from '../../../state/selectors'; -import { AlertMonitorStatusComponent } from '../../functional/alerts/alert_monitor_status'; +import { selectMonitorStatusAlert } from '../../../../state/selectors'; +import { AlertMonitorStatusComponent } from '../index'; interface Props { autocomplete: DataPublicPluginSetup['autocomplete']; diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/alerts/index.ts b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/index.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/connected/alerts/index.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/index.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/alerts/toggle_alert_flyout_button.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/toggle_alert_flyout_button.tsx similarity index 80% rename from x-pack/legacy/plugins/uptime/public/components/connected/alerts/toggle_alert_flyout_button.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/toggle_alert_flyout_button.tsx index 43b0be45365a1..45ba72d76fba6 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/alerts/toggle_alert_flyout_button.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/toggle_alert_flyout_button.tsx @@ -6,8 +6,8 @@ import React from 'react'; import { useDispatch } from 'react-redux'; -import { ToggleAlertFlyoutButtonComponent } from '../../functional'; -import { setAlertFlyoutVisible } from '../../../state/actions'; +import { setAlertFlyoutVisible } from '../../../../state/actions'; +import { ToggleAlertFlyoutButtonComponent } from '../index'; export const ToggleAlertFlyoutButton = () => { const dispatch = useDispatch(); diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/alerts/uptime_alerts_flyout_wrapper.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/uptime_alerts_flyout_wrapper.tsx similarity index 83% rename from x-pack/legacy/plugins/uptime/public/components/connected/alerts/uptime_alerts_flyout_wrapper.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/uptime_alerts_flyout_wrapper.tsx index a49468ad3dd06..7bfd44a762455 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/alerts/uptime_alerts_flyout_wrapper.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/alerts_containers/uptime_alerts_flyout_wrapper.tsx @@ -6,9 +6,9 @@ import React from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { UptimeAlertsFlyoutWrapperComponent } from '../../functional'; -import { setAlertFlyoutVisible } from '../../../state/actions'; -import { selectAlertFlyoutVisibility } from '../../../state/selectors'; +import { setAlertFlyoutVisible } from '../../../../state/actions'; +import { selectAlertFlyoutVisibility } from '../../../../state/selectors'; +import { UptimeAlertsFlyoutWrapperComponent } from '../index'; interface Props { alertTypeId?: string; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/alerts/index.ts b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/index.ts similarity index 93% rename from x-pack/legacy/plugins/uptime/public/components/functional/alerts/index.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/index.ts index 275333b60c5ee..5ca0f4c3fe8a7 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/alerts/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/index.ts @@ -8,3 +8,4 @@ export { AlertMonitorStatusComponent } from './alert_monitor_status'; export { ToggleAlertFlyoutButtonComponent } from './toggle_alert_flyout_button'; export { UptimeAlertsContextProvider } from './uptime_alerts_context_provider'; export { UptimeAlertsFlyoutWrapperComponent } from './uptime_alerts_flyout_wrapper'; +export * from './alerts_containers'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/alerts/toggle_alert_flyout_button.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/toggle_alert_flyout_button.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/alerts/toggle_alert_flyout_button.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/toggle_alert_flyout_button.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/alerts/uptime_alerts_context_provider.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/uptime_alerts_context_provider.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/alerts/uptime_alerts_context_provider.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/uptime_alerts_context_provider.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/alerts/uptime_alerts_flyout_wrapper.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/alerts/uptime_alerts_flyout_wrapper.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/alerts/uptime_alerts_flyout_wrapper.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/alerts/uptime_alerts_flyout_wrapper.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/__snapshots__/data_or_index_missing.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/__snapshots__/data_or_index_missing.test.tsx.snap new file mode 100644 index 0000000000000..25ac5a1f0974e --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/__snapshots__/data_or_index_missing.test.tsx.snap @@ -0,0 +1,92 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DataOrIndexMissing component renders headingMessage 1`] = ` + + + + + + + + + + + + + + + + + } + body={ + +

+ +

+

+ +

+
+ } + iconType="logoUptime" + title={ + +

+ + heartbeat-* + , + } + } + /> +

+
+ } + /> +
+
+
+`; diff --git a/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/__snapshots__/empty_state.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/__snapshots__/empty_state.test.tsx.snap new file mode 100644 index 0000000000000..d0e7af24e1c1b --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/__snapshots__/empty_state.test.tsx.snap @@ -0,0 +1,1627 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EmptyState component does not render empty state with appropriate base path and no docs 1`] = ` + + + , + } + } + /> + } + > + +
+ +
+ +
+ + +
+ + + + + + + + + + + + + } + body={ + +

+ +

+

+ +

+
+ } + iconType="logoUptime" + title={ + +

+ , + } + } + /> +

+
+ } + > +
+ +
+ + +
+ + + + + +

+ , + } + } + > + No uptime data found in index + + +

+
+
+ +
+ + +
+

+ + If you have not setup heartbeat yet, you can setup heartbeat to start monitoring your services. + +

+

+ + If you have setup heartbeat and confirmed data is being sent to Elasticsearch, update your index pattern settings and insure they are aligned with your Heartbeat config. + +

+
+
+ + + + + +
+ +
+ + + + +`; + +exports[`EmptyState component doesn't render child components when count is falsy 1`] = ` + + + + + + + +

+ Loading… +

+
+ + } + > +
+ + + +
+ + + + +
+ + +

+ Loading… +

+
+
+ + + +
+ + + + +`; + +exports[`EmptyState component notifies when index does not exist 1`] = ` + + + , + } + } + /> + } + > + +
+ +
+ +
+ + +
+ + + + + + + + + + + + + } + body={ + +

+ +

+

+ +

+
+ } + iconType="logoUptime" + title={ + +

+ , + } + } + /> +

+
+ } + > +
+ +
+ + +
+ + + + + +

+ , + } + } + > + No indices found matching pattern + + +

+
+
+ +
+ + +
+

+ + If you have not setup heartbeat yet, you can setup heartbeat to start monitoring your services. + +

+

+ + If you have setup heartbeat and confirmed data is being sent to Elasticsearch, update your index pattern settings and insure they are aligned with your Heartbeat config. + +

+
+
+ + + + + +
+ +
+ + + + +`; + +exports[`EmptyState component renders child components when count is truthy 1`] = ` + + +
+ Foo +
+
+ Bar +
+
+ Baz +
+
+
+`; + +exports[`EmptyState component renders error message when an error occurs 1`] = ` + + + + +
+ +
+ +
+ +

+ There was an error fetching your data. +

+ + } + iconColor="subdued" + iconType="securityApp" + title={ + +

+ Error +

+
+ } + > +
+ +
+ + +
+ + + + + +

+ Error +

+
+
+ +
+ + +
+

+ There was an error fetching your data. +

+
+
+ + +
+ +
+ +
+ +
+ + + + +`; + +exports[`EmptyState component renders loading state if no errors or doc count 1`] = ` + + + + + + + +

+ Loading… +

+
+ + } + > +
+ + + +
+ + + + +
+ + +

+ Loading… +

+
+
+ + + +
+ + + + +`; diff --git a/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/data_or_index_missing.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/data_or_index_missing.test.tsx new file mode 100644 index 0000000000000..333802962fd3e --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/data_or_index_missing.test.tsx @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { DataOrIndexMissing } from '../data_or_index_missing'; + +describe('DataOrIndexMissing component', () => { + it('renders headingMessage', () => { + const headingMessage = ( + heartbeat-*
}} + /> + ); + const component = shallowWithIntl(); + expect(component).toMatchSnapshot(); + }); +}); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/empty_state.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/empty_state.test.tsx similarity index 89% rename from x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/empty_state.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/empty_state.test.tsx index a74ad543c3318..acfe2ada5b68d 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/__tests__/empty_state.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/__tests__/empty_state.test.tsx @@ -5,11 +5,11 @@ */ import React from 'react'; -import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { EmptyStateComponent } from '../empty_state'; import { StatesIndexStatus } from '../../../../../common/runtime_types'; import { IHttpFetchError } from '../../../../../../../../../target/types/core/public/http'; import { HttpFetchError } from '../../../../../../../../../src/core/public/http/http_fetch_error'; +import { mountWithRouter, shallowWithRouter } from '../../../../lib'; describe('EmptyState component', () => { let statesIndexStatus: StatesIndexStatus; @@ -22,7 +22,7 @@ describe('EmptyState component', () => { }); it('renders child components when count is truthy', () => { - const component = shallowWithIntl( + const component = shallowWithRouter(
Foo
Bar
@@ -33,7 +33,7 @@ describe('EmptyState component', () => { }); it(`doesn't render child components when count is falsy`, () => { - const component = mountWithIntl( + const component = mountWithRouter(
Shouldn't be rendered
@@ -45,7 +45,7 @@ describe('EmptyState component', () => { const errors: IHttpFetchError[] = [ new HttpFetchError('There was an error fetching your data.', 'error', {} as any), ]; - const component = mountWithIntl( + const component = mountWithRouter(
Shouldn't appear...
@@ -54,7 +54,7 @@ describe('EmptyState component', () => { }); it('renders loading state if no errors or doc count', () => { - const component = mountWithIntl( + const component = mountWithRouter(
Should appear even while loading...
@@ -67,7 +67,7 @@ describe('EmptyState component', () => { docCount: 0, indexExists: true, }; - const component = mountWithIntl( + const component = mountWithRouter(
If this is in the snapshot the test should fail
@@ -77,7 +77,7 @@ describe('EmptyState component', () => { it('notifies when index does not exist', () => { statesIndexStatus.indexExists = false; - const component = mountWithIntl( + const component = mountWithRouter(
This text should not render
diff --git a/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/data_or_index_missing.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/data_or_index_missing.tsx new file mode 100644 index 0000000000000..88c0920138f68 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/data_or_index_missing.tsx @@ -0,0 +1,86 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { + EuiFlexGroup, + EuiEmptyPrompt, + EuiFlexItem, + EuiSpacer, + EuiPanel, + EuiTitle, + EuiButton, +} from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; +import React, { useContext } from 'react'; +import { UptimeSettingsContext } from '../../../contexts'; +import { DynamicSettings } from '../../../../common/runtime_types'; + +interface DataMissingProps { + headingMessage: JSX.Element; + settings?: DynamicSettings; +} + +export const DataOrIndexMissing = ({ headingMessage, settings }: DataMissingProps) => { + const { basePath } = useContext(UptimeSettingsContext); + return ( + + + + + +

{headingMessage}

+ + } + body={ + <> +

+ +

+

+ +

+ + } + actions={ + + + + + + + + + + + + + } + /> +
+
+
+ ); +}; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_state.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state.tsx similarity index 62% rename from x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_state.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state.tsx index ae6a1b892bc99..651103a34bf21 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_state.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state.tsx @@ -5,11 +5,11 @@ */ import React, { Fragment } from 'react'; -import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; import { EmptyStateError } from './empty_state_error'; import { EmptyStateLoading } from './empty_state_loading'; -import { DataMissing } from './data_missing'; -import { StatesIndexStatus } from '../../../../common/runtime_types'; +import { DataOrIndexMissing } from './data_or_index_missing'; +import { DynamicSettings, StatesIndexStatus } from '../../../../common/runtime_types'; import { IHttpFetchError } from '../../../../../../../../target/types/core/public/http'; interface EmptyStateProps { @@ -17,6 +17,7 @@ interface EmptyStateProps { statesIndexStatus: StatesIndexStatus | null; loading: boolean; errors?: IHttpFetchError[]; + settings?: DynamicSettings; } export const EmptyStateComponent = ({ @@ -24,6 +25,7 @@ export const EmptyStateComponent = ({ statesIndexStatus, loading, errors, + settings, }: EmptyStateProps) => { if (errors?.length) { return ; @@ -32,18 +34,28 @@ export const EmptyStateComponent = ({ const { indexExists, docCount } = statesIndexStatus; if (!indexExists) { return ( - {settings?.heartbeatIndices} }} + /> + } /> ); } else if (indexExists && docCount === 0) { return ( - {settings?.heartbeatIndices}
}} + /> + } /> ); } diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/empty_state/empty_state.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state_container.tsx similarity index 57% rename from x-pack/legacy/plugins/uptime/public/components/connected/empty_state/empty_state.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state_container.tsx index 55c92e70b6066..9a62cb9cdaeee 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/empty_state/empty_state.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state_container.tsx @@ -7,26 +7,44 @@ import React, { useContext, useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { indexStatusAction } from '../../../state/actions'; -import { indexStatusSelector } from '../../../state/selectors'; -import { EmptyStateComponent } from '../../functional/empty_state/empty_state'; +import { indexStatusSelector, selectDynamicSettings } from '../../../state/selectors'; +import { EmptyStateComponent } from './index'; import { UptimeRefreshContext } from '../../../contexts'; +import { getDynamicSettings } from '../../../state/actions/dynamic_settings'; export const EmptyState: React.FC = ({ children }) => { const { data, loading, error } = useSelector(indexStatusSelector); const { lastRefresh } = useContext(UptimeRefreshContext); + const { settings } = useSelector(selectDynamicSettings); + + const heartbeatIndices = settings?.heartbeatIndices || ''; + const dispatch = useDispatch(); useEffect(() => { - dispatch(indexStatusAction.get()); + if (!data || data?.docCount === 0 || data?.indexExists === false) { + dispatch(indexStatusAction.get()); + } + // Don't add data , it will create endless loop + // eslint-disable-next-line react-hooks/exhaustive-deps }, [dispatch, lastRefresh]); + useEffect(() => { + dispatch(indexStatusAction.get()); + }, [dispatch, heartbeatIndices]); + + useEffect(() => { + dispatch(getDynamicSettings()); + }, [dispatch]); + return ( ); }; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_state_error.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state_error.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_state_error.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state_error.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_state_loading.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state_loading.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/empty_state/empty_state_loading.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/empty_state/empty_state_loading.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/index.ts b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/index.ts new file mode 100644 index 0000000000000..9f2a668f4c3a5 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/overview/empty_state/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { EmptyStateComponent } from './empty_state'; +export { EmptyState } from './empty_state_container'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/__snapshots__/filter_popover.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/__snapshots__/filter_popover.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/__snapshots__/filter_popover.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/__snapshots__/filter_popover.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/__snapshots__/filter_status_button.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/__snapshots__/filter_status_button.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/__snapshots__/filter_status_button.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/__snapshots__/filter_status_button.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/__snapshots__/parse_filter_map.test.ts.snap b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/__snapshots__/parse_filter_map.test.ts.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/__snapshots__/parse_filter_map.test.ts.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/__snapshots__/parse_filter_map.test.ts.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/filter_popover.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/filter_popover.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/filter_popover.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/filter_popover.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/filter_status_button.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/filter_status_button.test.tsx similarity index 93% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/filter_status_button.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/filter_status_button.test.tsx index 1813229a97d1b..2ad4d971cf3b0 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/filter_status_button.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/filter_status_button.test.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { FilterStatusButton, FilterStatusButtonProps } from '../filter_status_button'; -import { shallowWithRouter } from '../../../../lib/'; +import { shallowWithRouter } from '../../../../lib'; describe('FilterStatusButton', () => { let props: FilterStatusButtonProps; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/parse_filter_map.test.ts b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/parse_filter_map.test.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/parse_filter_map.test.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/parse_filter_map.test.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/toggle_selected_item.test.ts b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/toggle_selected_item.test.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/__tests__/toggle_selected_item.test.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/__tests__/toggle_selected_item.test.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_group.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/filter_group.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_group.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/filter_group.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/filter_group/filter_group_container.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/filter_group_container.tsx similarity index 94% rename from x-pack/legacy/plugins/uptime/public/components/connected/filter_group/filter_group_container.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/filter_group_container.tsx index 569c6bb883cbd..3612604fdf116 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/filter_group/filter_group_container.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/filter_group_container.tsx @@ -7,10 +7,10 @@ import React, { useContext, useEffect } from 'react'; import { connect } from 'react-redux'; import { useUrlParams } from '../../../hooks'; -import { parseFiltersMap } from '../../functional/filter_group/parse_filter_map'; +import { parseFiltersMap } from './parse_filter_map'; import { AppState } from '../../../state'; import { fetchOverviewFilters, GetOverviewFiltersPayload } from '../../../state/actions'; -import { FilterGroupComponent } from '../../functional/filter_group'; +import { FilterGroupComponent } from './index'; import { OverviewFilters } from '../../../../common/runtime_types/overview_filters'; import { UptimeRefreshContext } from '../../../contexts'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_popover.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/filter_popover.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_popover.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/filter_popover.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_status_button.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/filter_status_button.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/filter_status_button.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/filter_status_button.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/index.ts b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/index.ts similarity index 84% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/index.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/index.ts index 2aae026144d8f..933fddf1cde27 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/index.ts @@ -5,3 +5,4 @@ */ export { FilterGroupComponent } from './filter_group'; +export { FilterGroup } from './filter_group_container'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/parse_filter_map.ts b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/parse_filter_map.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/parse_filter_map.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/parse_filter_map.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/toggle_selected_item.ts b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/toggle_selected_item.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/toggle_selected_item.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/toggle_selected_item.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/filter_group/uptime_filter_button.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/filter_group/uptime_filter_button.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/filter_group/uptime_filter_button.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/filter_group/uptime_filter_button.tsx diff --git a/x-pack/legacy/plugins/siem/server/index.ts b/x-pack/legacy/plugins/uptime/public/components/overview/index.ts similarity index 50% rename from x-pack/legacy/plugins/siem/server/index.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/index.ts index 8513f871cb6c1..ac293e9233c8c 100644 --- a/x-pack/legacy/plugins/siem/server/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/overview/index.ts @@ -4,9 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PluginInitializerContext } from '../../../../../src/core/server'; -import { Plugin } from './plugin'; +export * from './monitor_list'; +export * from './empty_state'; +export * from './filter_group'; +export * from './alerts'; +export * from './snapshot'; +export * from './kuery_bar'; -export const plugin = (context: PluginInitializerContext) => { - return new Plugin(context); -}; +export { ParsingErrorCallout } from './parsing_error_callout'; diff --git a/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/index.ts b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/index.ts new file mode 100644 index 0000000000000..60801a0ab705a --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { KueryBarComponent } from './kuery_bar'; +export { KueryBar } from './kuery_bar_container'; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/kuery_bar.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/kuery_bar.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/kuery_bar.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/kuery_bar.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/kuerybar/kuery_bar_container.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/kuery_bar_container.tsx similarity index 90% rename from x-pack/legacy/plugins/uptime/public/components/connected/kuerybar/kuery_bar_container.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/kuery_bar_container.tsx index 132ae57b5154f..5e1e184b2d6e6 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/kuerybar/kuery_bar_container.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/kuery_bar_container.tsx @@ -8,7 +8,7 @@ import { connect } from 'react-redux'; import { AppState } from '../../../state'; import { selectIndexPattern } from '../../../state/selectors'; import { getIndexPattern } from '../../../state/actions'; -import { KueryBarComponent } from '../../functional/kuery_bar/kuery_bar'; +import { KueryBarComponent } from './kuery_bar'; const mapStateToProps = (state: AppState) => ({ ...selectIndexPattern(state) }); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/click_outside.js b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/click_outside.js similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/click_outside.js rename to x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/click_outside.js diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.d.ts b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/index.d.ts similarity index 95% rename from x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.d.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/index.d.ts index c9f43b3a620bd..defde6203a8c5 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.d.ts +++ b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/index.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { Component } from 'react'; +import React from 'react'; interface TypeaheadProps { onChange: (inputValue: string, selectionStart: number) => void; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.js b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/index.js similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/index.js rename to x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/index.js diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/suggestion.js b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/suggestion.js similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/suggestion.js rename to x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/suggestion.js diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/suggestions.js b/x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/suggestions.js similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/kuery_bar/typeahead/suggestions.js rename to x-pack/legacy/plugins/uptime/public/components/overview/kuery_bar/typeahead/suggestions.js diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_list.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/__snapshots__/monitor_list.test.tsx.snap similarity index 52% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_list.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/__snapshots__/monitor_list.test.tsx.snap index 2b8bc0bb06ddf..ed5602323d254 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_list.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/__snapshots__/monitor_list.test.tsx.snap @@ -1,125 +1,535 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`MonitorList component renders a no items message when no data is provided 1`] = ` - - - -
- -
-
- - + + +`; + +exports[`MonitorList component MonitorListPagination component renders the pagination 1`] = ` + + + +`; + +exports[`MonitorList component renders a no items message when no data is provided 1`] = ` + + + +`; + +exports[`MonitorList component renders error list 1`] = ` + + + +`; + +exports[`MonitorList component renders loading state 1`] = ` + + - - - - - - - - - - - - - - - - -
-
+ } + /> + `; exports[`MonitorList component renders the monitor list 1`] = ` @@ -672,185 +1082,132 @@ exports[`MonitorList component renders the monitor list 1`] = ` `; exports[`MonitorList component shallow renders the monitor list 1`] = ` - - - -
- -
-
- - + - - - - - - - - - - - - - - - - -
-
+ } + /> + `; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_list_status_column.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/__snapshots__/monitor_list_status_column.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_list_status_column.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/__snapshots__/monitor_list_status_column.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_page_link.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/__snapshots__/monitor_page_link.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/__snapshots__/monitor_page_link.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/__snapshots__/monitor_page_link.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list.test.tsx new file mode 100644 index 0000000000000..9b1d799a23e37 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list.test.tsx @@ -0,0 +1,284 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { + MonitorSummaryResult, + CursorDirection, + SortOrder, +} from '../../../../../common/runtime_types'; +import { MonitorListComponent } from '../monitor_list'; +import { renderWithRouter, shallowWithRouter } from '../../../../lib'; + +describe('MonitorList component', () => { + let result: MonitorSummaryResult; + let localStorageMock: any; + + beforeEach(() => { + localStorageMock = { + getItem: jest.fn().mockImplementation(() => '25'), + setItem: jest.fn(), + }; + + // @ts-ignore replacing a call to localStorage we use for monitor list size + global.localStorage = localStorageMock; + result = { + nextPagePagination: null, + prevPagePagination: null, + summaries: [ + { + monitor_id: 'foo', + state: { + checks: [ + { + monitor: { + ip: '127.0.0.1', + status: 'up', + }, + timestamp: 124, + }, + { + monitor: { + ip: '127.0.0.2', + status: 'down', + }, + timestamp: 125, + }, + { + monitor: { + ip: '127.0.0.3', + status: 'down', + }, + timestamp: 126, + }, + ], + summary: { + up: 1, + down: 2, + }, + timestamp: '123', + url: {}, + }, + }, + { + monitor_id: 'bar', + state: { + checks: [ + { + monitor: { + ip: '127.0.0.1', + status: 'up', + }, + timestamp: 125, + }, + { + monitor: { + ip: '127.0.0.2', + status: 'up', + }, + timestamp: 126, + }, + ], + summary: { + up: 2, + down: 0, + }, + timestamp: '125', + url: {}, + }, + }, + ], + totalSummaryCount: 2, + }; + }); + + it('shallow renders the monitor list', () => { + const component = shallowWithRouter( + + ); + + expect(component).toMatchSnapshot(); + }); + + it('renders a no items message when no data is provided', () => { + const component = shallowWithRouter( + + ); + expect(component).toMatchSnapshot(); + }); + + it('renders the monitor list', () => { + const component = renderWithRouter( + + ); + + expect(component).toMatchSnapshot(); + }); + + it('renders error list', () => { + const component = shallowWithRouter( + + ); + + expect(component).toMatchSnapshot(); + }); + + it('renders loading state', () => { + const component = shallowWithRouter( + + ); + + expect(component).toMatchSnapshot(); + }); + + describe('MonitorListPagination component', () => { + let paginationResult: MonitorSummaryResult; + + beforeEach(() => { + paginationResult = { + prevPagePagination: JSON.stringify({ + cursorKey: { monitor_id: 123 }, + cursorDirection: CursorDirection.BEFORE, + sortOrder: SortOrder.ASC, + }), + nextPagePagination: JSON.stringify({ + cursorKey: { monitor_id: 456 }, + cursorDirection: CursorDirection.AFTER, + sortOrder: SortOrder.ASC, + }), + summaries: [ + { + monitor_id: 'foo', + state: { + checks: [ + { + monitor: { + ip: '127.0.0.1', + status: 'up', + }, + timestamp: 124, + }, + { + monitor: { + ip: '127.0.0.2', + status: 'down', + }, + timestamp: 125, + }, + { + monitor: { + ip: '127.0.0.3', + status: 'down', + }, + timestamp: 126, + }, + ], + summary: { + up: 1, + down: 2, + }, + timestamp: '123', + url: {}, + }, + }, + { + monitor_id: 'bar', + state: { + checks: [ + { + monitor: { + ip: '127.0.0.1', + status: 'up', + }, + timestamp: 125, + }, + { + monitor: { + ip: '127.0.0.2', + status: 'up', + }, + timestamp: 126, + }, + ], + summary: { + up: 2, + down: 0, + }, + timestamp: '125', + url: {}, + }, + }, + ], + totalSummaryCount: 2, + }; + }); + + it('renders the pagination', () => { + const component = shallowWithRouter( + + ); + + expect(component).toMatchSnapshot(); + }); + + it('renders a no items message when no data is provided', () => { + const component = shallowWithRouter( + + ); + + expect(component).toMatchSnapshot(); + }); + }); +}); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list_page_size_select.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_page_size_select.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list_page_size_select.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_page_size_select.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list_status_column.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_status_column.test.tsx similarity index 79% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list_status_column.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_status_column.test.tsx index 406e18535f34c..d765c0b33ea4b 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_list_status_column.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_list_status_column.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import moment from 'moment'; import { renderWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { getLocationStatus, MonitorListStatusColumn } from '../monitor_list_status_column'; -import { Check } from '../../../../../common/graphql/types'; +import { Check } from '../../../../../common/runtime_types'; import { STATUS } from '../../../../../common/constants'; describe('MonitorListStatusColumn', () => { @@ -29,9 +29,6 @@ describe('MonitorListStatusColumn', () => { beforeEach(() => { upChecks = [ { - agent: { id: '6a2f2a1c-e346-49ed-8418-6d48af8841d6' }, - container: null, - kubernetes: null, monitor: { ip: '104.86.46.103', name: '', @@ -46,12 +43,9 @@ describe('MonitorListStatusColumn', () => { }, }, }, - timestamp: '1579794631464', + timestamp: 1579794631464, }, { - agent: { id: '1117fd01-bc1a-4aa5-bfab-40ab455eadf9' }, - container: null, - kubernetes: null, monitor: { ip: '104.86.46.103', name: '', @@ -66,12 +60,9 @@ describe('MonitorListStatusColumn', () => { }, }, }, - timestamp: '1579794634220', + timestamp: 1579794634220, }, { - agent: { id: 'eda59510-45e8-4dfe-b0f8-959c449e3565' }, - container: null, - kubernetes: null, monitor: { ip: '104.86.46.103', name: '', @@ -86,15 +77,12 @@ describe('MonitorListStatusColumn', () => { }, }, }, - timestamp: '1579794628368', + timestamp: 1579794628368, }, ]; downChecks = [ { - agent: { id: '6a2f2a1c-e346-49ed-8418-6d48af8841d6' }, - container: null, - kubernetes: null, monitor: { ip: '104.86.46.103', name: '', @@ -109,12 +97,9 @@ describe('MonitorListStatusColumn', () => { }, }, }, - timestamp: '1579794631464', + timestamp: 1579794631464, }, { - agent: { id: '1117fd01-bc1a-4aa5-bfab-40ab455eadf9' }, - container: null, - kubernetes: null, monitor: { ip: '104.86.46.103', name: '', @@ -129,12 +114,9 @@ describe('MonitorListStatusColumn', () => { }, }, }, - timestamp: '1579794634220', + timestamp: 1579794634220, }, { - agent: { id: 'eda59510-45e8-4dfe-b0f8-959c449e3565' }, - container: null, - kubernetes: null, monitor: { ip: '104.86.46.103', name: '', @@ -149,15 +131,12 @@ describe('MonitorListStatusColumn', () => { }, }, }, - timestamp: '1579794628368', + timestamp: 1579794628368, }, ]; checks = [ { - agent: { id: '6a2f2a1c-e346-49ed-8418-6d48af8841d6' }, - container: null, - kubernetes: null, monitor: { ip: '104.86.46.103', name: '', @@ -172,12 +151,9 @@ describe('MonitorListStatusColumn', () => { }, }, }, - timestamp: '1579794631464', + timestamp: 1579794631464, }, { - agent: { id: '1117fd01-bc1a-4aa5-bfab-40ab455eadf9' }, - container: null, - kubernetes: null, monitor: { ip: '104.86.46.103', name: '', @@ -192,12 +168,9 @@ describe('MonitorListStatusColumn', () => { }, }, }, - timestamp: '1579794634220', + timestamp: 1579794634220, }, { - agent: { id: 'eda59510-45e8-4dfe-b0f8-959c449e3565' }, - container: null, - kubernetes: null, monitor: { ip: '104.86.46.103', name: '', @@ -212,7 +185,7 @@ describe('MonitorListStatusColumn', () => { }, }, }, - timestamp: '1579794628368', + timestamp: 1579794628368, }, ]; }); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_page_link.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_page_link.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/monitor_page_link.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/monitor_page_link.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/parse_timestamp.test.ts b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/parse_timestamp.test.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/__tests__/parse_timestamp.test.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/__tests__/parse_timestamp.test.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/index.ts b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/index.ts similarity index 59% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/index.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/index.ts index a83330a7a3a0b..45e8822a317a4 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/index.ts @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -export { MonitorList } from './monitor_list'; +export { MonitorListComponent } from './monitor_list'; export { Criteria, Pagination } from './types'; export { LocationLink } from './monitor_list_drawer'; +export { MonitorListDrawer } from './monitor_list_drawer/list_drawer_container'; +export { ActionsPopover } from './monitor_list_drawer/actions_popover/actions_popover_container'; diff --git a/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx new file mode 100644 index 0000000000000..18e2e2437e147 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx @@ -0,0 +1,240 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { + EuiButtonIcon, + EuiBasicTable, + EuiFlexGroup, + EuiFlexItem, + EuiIcon, + EuiLink, + EuiPanel, + EuiSpacer, + EuiTitle, +} from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; +import React, { useState, useEffect } from 'react'; +import styled from 'styled-components'; +import { HistogramPoint, FetchMonitorStatesQueryArgs } from '../../../../common/runtime_types'; +import { MonitorSummary } from '../../../../common/runtime_types'; +import { MonitorListStatusColumn } from './monitor_list_status_column'; +import { ExpandedRowMap } from './types'; +import { MonitorBarSeries } from '../../common/charts'; +import { MonitorPageLink } from './monitor_page_link'; +import { OverviewPageLink } from './overview_page_link'; +import * as labels from './translations'; +import { MonitorListPageSizeSelect } from './monitor_list_page_size_select'; +import { MonitorListDrawer } from './monitor_list_drawer/list_drawer_container'; +import { MonitorListProps } from './monitor_list_container'; +import { MonitorList } from '../../../state/reducers/monitor_list'; +import { useUrlParams } from '../../../hooks'; + +interface Props extends MonitorListProps { + lastRefresh: number; + monitorList: MonitorList; + getMonitorList: (params: FetchMonitorStatesQueryArgs) => void; +} + +const TruncatedEuiLink = styled(EuiLink)` + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +`; + +const DEFAULT_PAGE_SIZE = 10; +const LOCAL_STORAGE_KEY = 'xpack.uptime.monitorList.pageSize'; +const getPageSizeValue = () => { + const value = parseInt(localStorage.getItem(LOCAL_STORAGE_KEY) ?? '', 10); + if (isNaN(value)) { + return DEFAULT_PAGE_SIZE; + } + return value; +}; + +export const MonitorListComponent: React.FC = ({ + filters, + getMonitorList, + lastRefresh, + monitorList: { list, error, loading }, + linkParameters, +}) => { + const [pageSize, setPageSize] = useState(getPageSizeValue()); + const [drawerIds, updateDrawerIds] = useState([]); + + const [getUrlValues] = useUrlParams(); + const { dateRangeStart, dateRangeEnd, pagination, statusFilter } = getUrlValues(); + + useEffect(() => { + getMonitorList({ + dateRangeStart, + dateRangeEnd, + filters, + pageSize, + pagination, + statusFilter, + }); + }, [ + getMonitorList, + dateRangeStart, + dateRangeEnd, + filters, + lastRefresh, + pageSize, + pagination, + statusFilter, + ]); + + const items = list.summaries ?? []; + + const nextPagePagination = list.nextPagePagination ?? ''; + const prevPagePagination = list.prevPagePagination ?? ''; + + const getExpandedRowMap = () => { + return drawerIds.reduce((map: ExpandedRowMap, id: string) => { + return { + ...map, + [id]: ( + monitorId === id)} + /> + ), + }; + }, {}); + }; + + const columns = [ + { + align: 'left' as const, + field: 'state.monitor.status', + name: labels.STATUS_COLUMN_LABEL, + mobileOptions: { + fullWidth: true, + }, + render: (status: string, { state: { timestamp, checks } }: MonitorSummary) => { + return ( + + ); + }, + }, + { + align: 'left' as const, + field: 'state.monitor.name', + name: labels.NAME_COLUMN_LABEL, + mobileOptions: { + fullWidth: true, + }, + render: (name: string, summary: MonitorSummary) => ( + + {name ? name : `Unnamed - ${summary.monitor_id}`} + + ), + sortable: true, + }, + { + align: 'left' as const, + field: 'state.url.full', + name: labels.URL, + render: (url: string, summary: MonitorSummary) => ( + + {url} + + ), + }, + { + align: 'center' as const, + field: 'histogram.points', + name: labels.HISTORY_COLUMN_LABEL, + mobileOptions: { + show: false, + }, + render: (histogramSeries: HistogramPoint[] | null) => ( + + ), + }, + { + align: 'right' as const, + field: 'monitor_id', + name: '', + sortable: true, + isExpander: true, + width: '24px', + render: (id: string) => { + return ( + { + if (drawerIds.includes(id)) { + updateDrawerIds(drawerIds.filter(p => p !== id)); + } else { + updateDrawerIds([...drawerIds, id]); + } + }} + /> + ); + }, + }, + ]; + + return ( + + +
+ +
+
+ + + + + + + + + + + + + + + + + + +
+ ); +}; diff --git a/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_container.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_container.tsx new file mode 100644 index 0000000000000..5bfe6ff0c5b4f --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_container.tsx @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useCallback } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { getMonitorList } from '../../../state/actions'; +import { FetchMonitorStatesQueryArgs } from '../../../../common/runtime_types'; +import { monitorListSelector } from '../../../state/selectors'; +import { MonitorListComponent } from './index'; + +export interface MonitorListProps { + filters?: string; + linkParameters?: string; +} + +export const MonitorList: React.FC = props => { + const dispatch = useDispatch(); + + const dispatchCallback = useCallback( + (params: FetchMonitorStatesQueryArgs) => { + dispatch(getMonitorList(params)); + }, + [dispatch] + ); + + const monitorListState = useSelector(monitorListSelector); + + return ( + + ); +}; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/integration_group.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/integration_group.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/integration_group.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/integration_group.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/integration_link.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/integration_link.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/integration_link.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/integration_link.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_list_drawer.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_list_drawer.test.tsx.snap similarity index 97% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_list_drawer.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_list_drawer.test.tsx.snap index cf754581b1a33..4520b760be379 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_list_drawer.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_list_drawer.test.tsx.snap @@ -71,21 +71,21 @@ exports[`MonitorListDrawer component renders a MonitorListDrawer when there are "ip": "127.0.0.1", "status": "up", }, - "timestamp": "121", + "timestamp": 121, }, Object { "monitor": Object { "ip": "127.0.0.2", "status": "down", }, - "timestamp": "123", + "timestamp": 123, }, Object { "monitor": Object { "ip": "127.0.0.3", "status": "up", }, - "timestamp": "125", + "timestamp": 125, }, ], "summary": Object { @@ -175,7 +175,7 @@ exports[`MonitorListDrawer component renders a MonitorListDrawer when there is o "ip": "127.0.0.1", "status": "up", }, - "timestamp": "121", + "timestamp": 121, }, ], "summary": Object { diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_status_list.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_status_list.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_status_list.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_status_list.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_status_row.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_status_row.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_status_row.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/monitor_status_row.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/most_recent_error.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/most_recent_error.test.tsx.snap similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/__snapshots__/most_recent_error.test.tsx.snap rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/__snapshots__/most_recent_error.test.tsx.snap diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/data.json b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/data.json similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/data.json rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/data.json diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx similarity index 87% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx index 723f8f9f4430a..25cf400bcd0fd 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_group.test.tsx @@ -5,9 +5,9 @@ */ import React from 'react'; -import { MonitorSummary } from '../../../../../../common/graphql/types'; +import { MonitorSummary } from '../../../../../../common/runtime_types'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; -import { IntegrationGroup } from '../integration_group'; +import { IntegrationGroup } from '../actions_popover/integration_group'; describe('IntegrationGroup', () => { let summary: MonitorSummary; @@ -19,6 +19,7 @@ describe('IntegrationGroup', () => { summary: {}, checks: [], timestamp: '123', + url: {}, }, }; }); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx similarity index 93% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx index ba313f255f13d..8ee83bc38957b 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/integration_link.test.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { IntegrationLink } from '../integration_link'; +import { IntegrationLink } from '../actions_popover/integration_link'; import { shallowWithIntl } from 'test_utils/enzyme_helpers'; describe('IntegrationLink component', () => { diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/monitor_list_drawer.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_list_drawer.test.tsx similarity index 90% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/monitor_list_drawer.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_list_drawer.test.tsx index d870acefaaea6..4bc0c3f0a40ba 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/monitor_list_drawer.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_list_drawer.test.tsx @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ import 'jest'; -import { MonitorSummary, Check } from '../../../../../../common/graphql/types'; import React from 'react'; import { MonitorListDrawerComponent } from '../monitor_list_drawer'; -import { MonitorDetails } from '../../../../../../common/runtime_types'; +import { Check, MonitorDetails, MonitorSummary } from '../../../../../../common/runtime_types'; import { shallowWithRouter } from '../../../../../lib'; describe('MonitorListDrawer component', () => { @@ -24,7 +23,7 @@ describe('MonitorListDrawer component', () => { ip: '127.0.0.1', status: 'up', }, - timestamp: '121', + timestamp: 121, }, ], summary: { @@ -77,21 +76,21 @@ describe('MonitorListDrawer component', () => { ip: '127.0.0.1', status: 'up', }, - timestamp: '121', + timestamp: 121, }, { monitor: { ip: '127.0.0.2', status: 'down', }, - timestamp: '123', + timestamp: 123, }, { monitor: { ip: '127.0.0.3', status: 'up', }, - timestamp: '125', + timestamp: 125, }, ]; summary.state.checks = checks; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx similarity index 61% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx index 8c07d0b1a7d22..c7f3aef4075e1 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_list.test.tsx @@ -8,7 +8,7 @@ import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import React from 'react'; import moment from 'moment'; import { MonitorStatusList } from '../monitor_status_list'; -import { Check } from '../../../../../../common/graphql/types'; +import { Check } from '../../../../../../common/runtime_types'; describe('MonitorStatusList component', () => { let checks: Check[]; @@ -21,110 +21,92 @@ describe('MonitorStatusList component', () => { beforeEach(() => { checks = [ { - agent: { id: '8f9a37fb-573a-4fdc-9895-440a5b39c250' }, monitor: { ip: '151.101.130.217', name: 'elastic', status: 'up', }, observer: { - geo: { name: null, location: null }, + geo: {}, }, - timestamp: '1570538236414', + timestamp: 1570538236414, }, { - agent: { id: '8f9a37fb-573a-4fdc-9895-440a5b39c250' }, monitor: { ip: '151.101.194.217', name: 'elastic', status: 'up', }, observer: { - geo: { name: null, location: null }, + geo: {}, }, - timestamp: '1570538236414', + timestamp: 1570538236414, }, { - agent: { id: '8f9a37fb-573a-4fdc-9895-440a5b39c250' }, monitor: { ip: '151.101.2.217', name: 'elastic', status: 'up', }, observer: { - geo: { name: null, location: null }, + geo: {}, }, - timestamp: '1570538236414', + timestamp: 1570538236414, }, { - agent: { id: '8f9a37fb-573a-4fdc-9895-440a5b39c250' }, - container: null, - kubernetes: null, monitor: { ip: '151.101.66.217', name: 'elastic', status: 'up', }, observer: { - geo: { name: null, location: null }, + geo: {}, }, - timestamp: '1570538236414', + timestamp: 1570538236414, }, { - agent: { id: '8f9a37fb-573a-4fdc-9895-440a5b39c250' }, - container: null, - kubernetes: null, monitor: { ip: '2a04:4e42:200::729', name: 'elastic', status: 'down', }, observer: { - geo: { name: null, location: null }, + geo: {}, }, - timestamp: '1570538236414', + timestamp: 1570538236414, }, { - agent: { id: '8f9a37fb-573a-4fdc-9895-440a5b39c250' }, - container: null, - kubernetes: null, monitor: { ip: '2a04:4e42:400::729', name: 'elastic', status: 'down', }, observer: { - geo: { name: null, location: null }, + geo: {}, }, - timestamp: '1570538236414', + timestamp: 1570538236414, }, { - agent: { id: '8f9a37fb-573a-4fdc-9895-440a5b39c250' }, - container: null, - kubernetes: null, monitor: { ip: '2a04:4e42:600::729', name: 'elastic', status: 'down', }, observer: { - geo: { name: null, location: null }, + geo: {}, }, - timestamp: '1570538236414', + timestamp: 1570538236414, }, { - agent: { id: '8f9a37fb-573a-4fdc-9895-440a5b39c250' }, - container: null, - kubernetes: null, monitor: { ip: '2a04:4e42::729', name: 'elastic', status: 'down', }, observer: { - geo: { name: null, location: null }, + geo: {}, }, - timestamp: '1570538236414', + timestamp: 1570538236414, }, ]; }); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/monitor_status_row.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_row.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/monitor_status_row.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/monitor_status_row.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/most_recent_error.test.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/most_recent_error.test.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/__tests__/most_recent_error.test.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/__tests__/most_recent_error.test.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_list_actions_popover.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/actions_popover.tsx similarity index 89% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_list_actions_popover.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/actions_popover.tsx index 6b946baa8d403..e86e6b309214f 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_list_actions_popover.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/actions_popover.tsx @@ -9,20 +9,20 @@ import { i18n } from '@kbn/i18n'; import React from 'react'; import { EuiPopover, EuiButton } from '@elastic/eui'; import { IntegrationGroup } from './integration_group'; -import { MonitorSummary } from '../../../../../common/graphql/types'; -import { toggleIntegrationsPopover, PopoverState } from '../../../../state/actions'; +import { MonitorSummary } from '../../../../../../common/runtime_types'; +import { toggleIntegrationsPopover, PopoverState } from '../../../../../state/actions'; -interface MonitorListActionsPopoverProps { +interface ActionsPopoverProps { summary: MonitorSummary; popoverState: PopoverState | null; togglePopoverIsVisible: typeof toggleIntegrationsPopover; } -export const MonitorListActionsPopoverComponent = ({ +export const ActionsPopoverComponent = ({ summary, popoverState, togglePopoverIsVisible, -}: MonitorListActionsPopoverProps) => { +}: ActionsPopoverProps) => { const popoverId = `${summary.monitor_id}_popover`; const monitorUrl: string | undefined = get(summary, 'state.url.full', undefined); diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/monitor/drawer_popover_container.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/actions_popover_container.tsx similarity index 63% rename from x-pack/legacy/plugins/uptime/public/components/connected/monitor/drawer_popover_container.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/actions_popover_container.tsx index be29e12f716a9..b1c25ddd7a338 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/monitor/drawer_popover_container.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/actions_popover_container.tsx @@ -5,10 +5,10 @@ */ import { connect } from 'react-redux'; -import { AppState } from '../../../state'; -import { isIntegrationsPopupOpen } from '../../../state/selectors'; -import { PopoverState, toggleIntegrationsPopover } from '../../../state/actions'; -import { MonitorListActionsPopoverComponent } from '../../functional/monitor_list/monitor_list_drawer'; +import { AppState } from '../../../../../state'; +import { isIntegrationsPopupOpen } from '../../../../../state/selectors'; +import { PopoverState, toggleIntegrationsPopover } from '../../../../../state/actions'; +import { ActionsPopoverComponent } from '../index'; const mapStateToProps = (state: AppState) => ({ popoverState: isIntegrationsPopupOpen(state), @@ -20,7 +20,4 @@ const mapDispatchToProps = (dispatch: any) => ({ }, }); -export const MonitorListActionsPopover = connect( - mapStateToProps, - mapDispatchToProps -)(MonitorListActionsPopoverComponent); +export const ActionsPopover = connect(mapStateToProps, mapDispatchToProps)(ActionsPopoverComponent); diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/integration_group.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/integration_group.tsx similarity index 98% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/integration_group.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/integration_group.tsx index 34bff58a3e2d9..bbcba7238748d 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/integration_group.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/integration_group.tsx @@ -18,9 +18,9 @@ import { getLoggingContainerHref, getLoggingIpHref, getLoggingKubernetesHref, -} from '../../../../lib/helper'; -import { MonitorSummary } from '../../../../../common/graphql/types'; -import { UptimeSettingsContext } from '../../../../contexts'; +} from '../../../../../lib/helper'; +import { MonitorSummary } from '../../../../../../common/runtime_types'; +import { UptimeSettingsContext } from '../../../../../contexts'; interface IntegrationGroupProps { summary: MonitorSummary; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/integration_link.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/integration_link.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/integration_link.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/actions_popover/integration_link.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/index.ts b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/index.ts similarity index 63% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/index.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/index.ts index 2933a71c2240b..32c722b806f2b 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/index.ts +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/index.ts @@ -4,5 +4,5 @@ * you may not use this file except in compliance with the Elastic License. */ -export { LocationLink } from './location_link'; -export { MonitorListActionsPopoverComponent } from './monitor_list_actions_popover'; +export { LocationLink } from '../../../common/location_link'; +export { ActionsPopoverComponent } from './actions_popover/actions_popover'; diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/monitor/list_drawer_container.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/list_drawer_container.tsx similarity index 70% rename from x-pack/legacy/plugins/uptime/public/components/connected/monitor/list_drawer_container.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/list_drawer_container.tsx index 70da62d5833af..bec32ace27f2b 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/monitor/list_drawer_container.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/list_drawer_container.tsx @@ -6,14 +6,13 @@ import React, { useEffect } from 'react'; import { connect } from 'react-redux'; -import { AppState } from '../../../state'; -import { monitorDetailsSelector } from '../../../state/selectors'; -import { MonitorDetailsActionPayload } from '../../../state/actions/types'; -import { getMonitorDetailsAction } from '../../../state/actions/monitor'; -import { MonitorListDrawerComponent } from '../../functional/monitor_list/monitor_list_drawer/monitor_list_drawer'; -import { useGetUrlParams } from '../../../hooks'; -import { MonitorSummary } from '../../../../common/graphql/types'; -import { MonitorDetails } from '../../../../common/runtime_types/monitor'; +import { AppState } from '../../../../state'; +import { monitorDetailsSelector } from '../../../../state/selectors'; +import { MonitorDetailsActionPayload } from '../../../../state/actions/types'; +import { getMonitorDetailsAction } from '../../../../state/actions/monitor'; +import { MonitorListDrawerComponent } from './monitor_list_drawer'; +import { useGetUrlParams } from '../../../../hooks'; +import { MonitorDetails, MonitorSummary } from '../../../../../common/runtime_types'; interface ContainerProps { summary: MonitorSummary; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_list_drawer.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/monitor_list_drawer.tsx similarity index 87% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_list_drawer.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/monitor_list_drawer.tsx index 8383596ccc346..8e97ce4d692d7 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_list_drawer.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/monitor_list_drawer.tsx @@ -7,11 +7,10 @@ import React from 'react'; import styled from 'styled-components'; import { EuiLink, EuiSpacer, EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText } from '@elastic/eui'; -import { MonitorSummary } from '../../../../../common/graphql/types'; import { MostRecentError } from './most_recent_error'; import { MonitorStatusList } from './monitor_status_list'; -import { MonitorDetails } from '../../../../../common/runtime_types'; -import { MonitorListActionsPopover } from '../../../connected'; +import { MonitorDetails, MonitorSummary } from '../../../../../common/runtime_types'; +import { ActionsPopover } from './actions_popover/actions_popover_container'; const ContainerDiv = styled.div` padding: 10px; @@ -49,7 +48,7 @@ export function MonitorListDrawerComponent({ summary, monitorDetails }: MonitorL - + diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_status_list.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/monitor_status_list.tsx similarity index 94% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_status_list.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/monitor_status_list.tsx index a2042e379dd80..cd1a5a95b8adb 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_status_list.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/monitor_status_list.tsx @@ -8,9 +8,9 @@ import React from 'react'; import { get, capitalize } from 'lodash'; import { EuiCallOut, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { Check } from '../../../../../common/graphql/types'; -import { LocationLink } from './location_link'; +import { LocationLink } from '../../../common/location_link'; import { MonitorStatusRow } from './monitor_status_row'; +import { Check } from '../../../../../common/runtime_types'; import { STATUS, UNNAMED_LOCATION } from '../../../../../common/constants'; interface MonitorStatusListProps { diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_status_row.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/monitor_status_row.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/monitor_status_row.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/monitor_status_row.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/most_recent_error.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/most_recent_error.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_drawer/most_recent_error.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_drawer/most_recent_error.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_page_size_select.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_page_size_select.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_page_size_select.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_page_size_select.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_status_column.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_status_column.tsx similarity index 98% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_status_column.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_status_column.tsx index 7e23be572a6f9..8076fe66cc208 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_list_status_column.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_list_status_column.tsx @@ -11,7 +11,7 @@ import { capitalize } from 'lodash'; import styled from 'styled-components'; import { EuiHealth, EuiFlexGroup, EuiFlexItem, EuiText, EuiToolTip } from '@elastic/eui'; import { parseTimestamp } from './parse_timestamp'; -import { Check } from '../../../../common/graphql/types'; +import { Check } from '../../../../common/runtime_types'; import { STATUS, SHORT_TIMESPAN_LOCALE, diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_page_link.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_page_link.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/monitor_page_link.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/monitor_page_link.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/overview_page_link.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/overview_page_link.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/overview_page_link.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/overview_page_link.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/parse_timestamp.ts b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/parse_timestamp.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/parse_timestamp.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/parse_timestamp.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/translations.ts b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/translations.ts similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/translations.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/translations.ts diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/types.ts b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/types.ts similarity index 83% rename from x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/types.ts rename to x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/types.ts index a25603d3603d9..6a6cee4a7d96d 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/monitor_list/types.ts +++ b/x-pack/legacy/plugins/uptime/public/components/overview/monitor_list/types.ts @@ -4,13 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -export interface CondensedCheck { - childStatuses: CondensedCheckStatus[]; - location: string | null; - status: string; - timestamp: string; -} - export interface CondensedCheckStatus { ip?: string | null; status: string; diff --git a/x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/overview_container.tsx similarity index 74% rename from x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/overview_container.tsx index 79aaa071507e1..d64e489c48076 100644 --- a/x-pack/legacy/plugins/uptime/public/components/connected/pages/overview_container.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/overview_container.tsx @@ -5,10 +5,10 @@ */ import { connect } from 'react-redux'; -import { OverviewPageComponent } from '../../../pages/overview'; -import { selectIndexPattern } from '../../../state/selectors'; -import { AppState } from '../../../state'; -import { setEsKueryString } from '../../../state/actions'; +import { OverviewPageComponent } from '../../pages/overview'; +import { selectIndexPattern } from '../../state/selectors'; +import { AppState } from '../../state'; +import { setEsKueryString } from '../../state/actions'; interface DispatchProps { setEsKueryFilters: typeof setEsKueryString; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/overview_page_parsing_error_callout.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/parsing_error_callout.tsx similarity index 89% rename from x-pack/legacy/plugins/uptime/public/components/functional/overview_page_parsing_error_callout.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/parsing_error_callout.tsx index b71a4f2f8646a..96ea14cdf9f37 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/overview_page_parsing_error_callout.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/parsing_error_callout.tsx @@ -13,13 +13,11 @@ interface HasMessage { message: string; } -interface OverviewPageParsingErrorCalloutProps { +interface ParsingErrorCalloutProps { error: HasMessage; } -export const OverviewPageParsingErrorCallout = ({ - error, -}: OverviewPageParsingErrorCalloutProps) => ( +export const ParsingErrorCallout = ({ error }: ParsingErrorCalloutProps) => ( = ({ height }: Props) => { + const { dateRangeStart, dateRangeEnd, statusFilter } = useGetUrlParams(); + + const { count, lastRefresh, loading, esKuery } = useSelector(snapshotDataSelector); + + const dispatch = useDispatch(); + + useEffect(() => { + dispatch( + getSnapshotCountAction({ dateRangeStart, dateRangeEnd, filters: esKuery, statusFilter }) + ); + }, [dateRangeStart, dateRangeEnd, esKuery, lastRefresh, statusFilter, dispatch]); + return ; +}; diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/snapshot_heading.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/snapshot/snapshot_heading.tsx similarity index 100% rename from x-pack/legacy/plugins/uptime/public/components/functional/snapshot_heading.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/snapshot/snapshot_heading.tsx diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/status_panel.tsx b/x-pack/legacy/plugins/uptime/public/components/overview/status_panel.tsx similarity index 87% rename from x-pack/legacy/plugins/uptime/public/components/functional/status_panel.tsx rename to x-pack/legacy/plugins/uptime/public/components/overview/status_panel.tsx index 2c0be2aa15d6f..9edcb08a6d5b1 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/status_panel.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/overview/status_panel.tsx @@ -6,7 +6,8 @@ import React from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiPanel } from '@elastic/eui'; -import { PingHistogram, Snapshot } from '../connected'; +import { PingHistogram } from '../monitor'; +import { Snapshot } from './snapshot/snapshot_container'; const STATUS_CHART_HEIGHT = '160px'; diff --git a/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/__snapshots__/certificate_form.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/__snapshots__/certificate_form.test.tsx.snap new file mode 100644 index 0000000000000..36bc9bb860211 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/__snapshots__/certificate_form.test.tsx.snap @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CertificateForm shallow renders expected elements for valid props 1`] = ` + + + +`; diff --git a/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/__snapshots__/indices_form.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/__snapshots__/indices_form.test.tsx.snap new file mode 100644 index 0000000000000..93151198c0f49 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/__snapshots__/indices_form.test.tsx.snap @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CertificateForm shallow renders expected elements for valid props 1`] = ` + + + +`; diff --git a/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/certificate_form.test.tsx b/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/certificate_form.test.tsx new file mode 100644 index 0000000000000..a3158f3d72445 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/certificate_form.test.tsx @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { CertificateExpirationForm } from '../certificate_form'; +import { shallowWithRouter } from '../../../lib'; + +describe('CertificateForm', () => { + it('shallow renders expected elements for valid props', () => { + expect( + shallowWithRouter( + + ) + ).toMatchSnapshot(); + }); +}); diff --git a/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/indices_form.test.tsx b/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/indices_form.test.tsx new file mode 100644 index 0000000000000..654d51019d4e5 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/settings/__tests__/indices_form.test.tsx @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { IndicesForm } from '../indices_form'; +import { shallowWithRouter } from '../../../lib'; + +describe('CertificateForm', () => { + it('shallow renders expected elements for valid props', () => { + expect( + shallowWithRouter( + + ) + ).toMatchSnapshot(); + }); +}); diff --git a/x-pack/legacy/plugins/uptime/public/components/settings/certificate_form.tsx b/x-pack/legacy/plugins/uptime/public/components/settings/certificate_form.tsx new file mode 100644 index 0000000000000..5103caee1e1c0 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/settings/certificate_form.tsx @@ -0,0 +1,160 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { useSelector } from 'react-redux'; +import { + EuiDescribedFormGroup, + EuiFormRow, + EuiCode, + EuiFieldNumber, + EuiTitle, + EuiSpacer, + EuiSelect, + EuiFlexGroup, + EuiFlexItem, +} from '@elastic/eui'; +import { defaultDynamicSettings, DynamicSettings } from '../../../common/runtime_types'; +import { selectDynamicSettings } from '../../state/selectors'; + +type NumStr = string | number; + +export type OnFieldChangeType = (field: string, value?: NumStr) => void; + +export interface SettingsFormProps { + onChange: OnFieldChangeType; + formFields: DynamicSettings | null; + fieldErrors: any; + isDisabled: boolean; +} + +export const CertificateExpirationForm: React.FC = ({ + onChange, + formFields, + fieldErrors, + isDisabled, +}) => { + const dss = useSelector(selectDynamicSettings); + + return ( + <> + +

+ +

+
+ + + + + } + description={ + + } + > + {defaultDynamicSettings?.certificatesThresholds?.errorState} + ), + }} + /> + } + isInvalid={!!fieldErrors?.certificatesThresholds?.errorState} + label={ + + } + > + + + + onChange( + 'certificatesThresholds.errorState', + value === '' ? undefined : Number(value) + ) + } + /> + + + + + + + {defaultDynamicSettings?.certificatesThresholds?.warningState} + ), + }} + /> + } + isInvalid={!!fieldErrors?.certificatesThresholds?.warningState} + label={ + + } + > + + + + onChange('certificatesThresholds.warningState', Number(event.currentTarget.value)) + } + /> + + + + + + + + + ); +}; diff --git a/x-pack/legacy/plugins/uptime/public/components/settings/indices_form.tsx b/x-pack/legacy/plugins/uptime/public/components/settings/indices_form.tsx new file mode 100644 index 0000000000000..c28eca2ea229e --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/components/settings/indices_form.tsx @@ -0,0 +1,90 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { useSelector } from 'react-redux'; +import { + EuiDescribedFormGroup, + EuiFormRow, + EuiCode, + EuiFieldText, + EuiTitle, + EuiSpacer, +} from '@elastic/eui'; +import { defaultDynamicSettings } from '../../../common/runtime_types'; +import { selectDynamicSettings } from '../../state/selectors'; +import { SettingsFormProps } from './certificate_form'; + +export const IndicesForm: React.FC = ({ + onChange, + formFields, + fieldErrors, + isDisabled, +}) => { + const dss = useSelector(selectDynamicSettings); + + return ( + <> + +

+ +

+
+ + + + + } + description={ + + } + > + {defaultDynamicSettings.heartbeatIndices}, + }} + /> + } + isInvalid={!!fieldErrors?.heartbeatIndices} + label={ + + } + > + onChange('heartbeatIndices', event.currentTarget.value)} + /> + + + + ); +}; diff --git a/x-pack/legacy/plugins/uptime/public/contexts/uptime_settings_context.tsx b/x-pack/legacy/plugins/uptime/public/contexts/uptime_settings_context.tsx index c5a0ec4831798..137846de103b4 100644 --- a/x-pack/legacy/plugins/uptime/public/contexts/uptime_settings_context.tsx +++ b/x-pack/legacy/plugins/uptime/public/contexts/uptime_settings_context.tsx @@ -7,7 +7,7 @@ import React, { createContext, useMemo } from 'react'; import { UptimeAppProps } from '../uptime_app'; import { CLIENT_DEFAULTS, CONTEXT_DEFAULTS } from '../../common/constants'; -import { CommonlyUsedRange } from '../components/functional/uptime_date_picker'; +import { CommonlyUsedRange } from '../components/common/uptime_date_picker'; import { useGetUrlParams } from '../hooks'; import { ILicense } from '../../../../../plugins/licensing/common/types'; diff --git a/x-pack/legacy/plugins/uptime/public/hooks/__tests__/use_breadcrumbs.test.tsx b/x-pack/legacy/plugins/uptime/public/hooks/__tests__/use_breadcrumbs.test.tsx index 85961003fce72..1ce00fe7ce3af 100644 --- a/x-pack/legacy/plugins/uptime/public/hooks/__tests__/use_breadcrumbs.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/hooks/__tests__/use_breadcrumbs.test.tsx @@ -11,7 +11,7 @@ import { mountWithRouter } from '../../lib'; import { OVERVIEW_ROUTE } from '../../../common/constants'; import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; import { UptimeUrlParams, getSupportedUrlParams } from '../../lib/helper'; -import { makeBaseBreadcrumb, useBreadcrumbs } from '../../hooks/use_breadcrumbs'; +import { makeBaseBreadcrumb, useBreadcrumbs } from '../use_breadcrumbs'; describe('useBreadcrumbs', () => { it('sets the given breadcrumbs', () => { diff --git a/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/apollo_client_adapter.ts b/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/apollo_client_adapter.ts deleted file mode 100644 index 2cec0d5fc8c64..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/apollo_client_adapter.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { InMemoryCache } from 'apollo-cache-inmemory'; -import { ApolloClient } from 'apollo-client'; -import { HttpLink } from 'apollo-link-http'; -import { CreateGraphQLClient } from './framework_adapter_types'; - -export const createApolloClient: CreateGraphQLClient = (uri: string, xsrfHeader: string) => - new ApolloClient({ - link: new HttpLink({ uri, credentials: 'same-origin', headers: { 'kbn-xsrf': xsrfHeader } }), - cache: new InMemoryCache({ dataIdFromObject: () => undefined }), - }); diff --git a/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/framework_adapter_types.ts b/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/framework_adapter_types.ts deleted file mode 100644 index 34cf48514c932..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/framework_adapter_types.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { NormalizedCacheObject } from 'apollo-cache-inmemory'; -import { ApolloClient } from 'apollo-client'; - -export type GraphQLClient = ApolloClient; - -export type CreateGraphQLClient = (url: string, xsrfHeader: string) => GraphQLClient; diff --git a/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/new_platform_adapter.tsx b/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/new_platform_adapter.tsx index a2f3328b98612..71c73bf5ba5d4 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/new_platform_adapter.tsx +++ b/x-pack/legacy/plugins/uptime/public/lib/adapters/framework/new_platform_adapter.tsx @@ -20,7 +20,6 @@ import { DEFAULT_TIMEPICKER_QUICK_RANGES, } from '../../../../common/constants'; import { UMFrameworkAdapter } from '../../lib'; -import { createApolloClient } from './apollo_client_adapter'; export const getKibanaFrameworkAdapter = ( core: CoreStart, @@ -60,7 +59,6 @@ export const getKibanaFrameworkAdapter = ( const props: UptimeAppProps = { basePath: basePath.get(), canSave, - client: createApolloClient(`${basePath.get()}/api/uptime/graphql`, 'true'), core, darkMode: core.uiSettings.get(DEFAULT_DARK_MODE), commonlyUsedRanges: core.uiSettings.get(DEFAULT_TIMEPICKER_QUICK_RANGES), diff --git a/x-pack/legacy/plugins/uptime/public/lib/alert_types/index.ts b/x-pack/legacy/plugins/uptime/public/lib/alert_types/index.ts index f764505a6d683..74160577cb0b1 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/alert_types/index.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/alert_types/index.ts @@ -6,7 +6,7 @@ // TODO: after NP migration is complete we should be able to remove this lint ignore comment // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { AlertTypeModel } from '../../../../../../plugins/triggers_actions_ui/public/types'; +import { AlertTypeModel } from '../../../../../../plugins/triggers_actions_ui/public'; import { initMonitorStatusAlertType } from './monitor_status'; export type AlertTypeInitializer = (dependenies: { autocomplete: any }) => AlertTypeModel; diff --git a/x-pack/legacy/plugins/uptime/public/lib/alert_types/monitor_status.tsx b/x-pack/legacy/plugins/uptime/public/lib/alert_types/monitor_status.tsx index d059274159c7f..0624d20b197c0 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/alert_types/monitor_status.tsx +++ b/x-pack/legacy/plugins/uptime/public/lib/alert_types/monitor_status.tsx @@ -16,7 +16,7 @@ import { } from '../../../../../../plugins/triggers_actions_ui/public/types'; import { AlertTypeInitializer } from '.'; import { StatusCheckExecutorParamsType } from '../../../common/runtime_types'; -import { AlertMonitorStatus } from '../../components/connected/alerts'; +import { AlertMonitorStatus } from '../../components/overview/alerts/alerts_containers'; export const validate = (alertParams: any): ValidationResult => { const errors: Record = {}; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/__snapshots__/format_error_string.test.ts.snap b/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/__snapshots__/format_error_string.test.ts.snap deleted file mode 100644 index 8519157e4039e..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/__snapshots__/format_error_string.test.ts.snap +++ /dev/null @@ -1,7 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`formatErrorString returns a formatted string containing each error 1`] = ` -"Error: foo is bar -Error: bar is not foo -" -`; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/format_error_string.test.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/format_error_string.test.ts deleted file mode 100644 index ba437c05cbe2b..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/__tests__/format_error_string.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { formatUptimeGraphQLErrorList } from '../format_error_list'; - -describe('formatErrorString', () => { - it('returns an empty string for empty array', () => { - const result = formatUptimeGraphQLErrorList([]); - expect(result).toEqual(''); - }); - it('returns a formatted string containing each error', () => { - const result = formatUptimeGraphQLErrorList([ - { - message: 'foo is bar', - locations: undefined, - path: undefined, - nodes: undefined, - source: undefined, - positions: undefined, - originalError: undefined, - extensions: undefined, - name: 'test error', - }, - { - message: 'bar is not foo', - locations: undefined, - path: undefined, - nodes: undefined, - source: undefined, - positions: undefined, - originalError: undefined, - extensions: undefined, - name: 'test error', - }, - ]); - expect(result).toMatchSnapshot(); - }); -}); diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/charts/get_chart_date_label.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/charts/get_chart_date_label.ts index 126b1d85f749f..aa5a2b0f60e4f 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/charts/get_chart_date_label.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/charts/get_chart_date_label.ts @@ -11,7 +11,7 @@ import { CHART_FORMAT_LIMITS } from '../../../../common/constants'; /** * Generates an appropriate date formatting string intended for the y-axis * label of timeseries charts. The function will return day/month values for shorter - * timespans that cross the local date threshold, otherwise it estimates an appropriate + * time spans that cross the local date threshold, otherwise it estimates an appropriate * label for several different stops. * @param dateRangeStart the beginning of the date range * @param dateRangeEnd the end of the date range diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/charts/get_label_format.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/charts/get_label_format.ts index 668147fee8055..5957123e9257d 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/charts/get_label_format.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/charts/get_label_format.ts @@ -49,7 +49,7 @@ const dateStops: Array<{ key: number; value: string }> = [ ]; /** - * Returns an appropriate label format bbased on pre-defined intervals. + * Returns an appropriate label format based on pre-defined intervals. * @param delta The length of the timespan in milliseconds */ export const getLabelFormat = (delta: number): string => { diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/convert_measurements.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/convert_measurements.ts index 4ad9b81b9e660..da97b6400a9a5 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/convert_measurements.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/convert_measurements.ts @@ -8,7 +8,7 @@ const NUM_MICROSECONDS_IN_MILLISECOND = 1000; /** * This simply converts microseconds to milliseconds. People tend to prefer ms to us - * when visualizaing request duration times. + * when visualizing request duration times. */ export const convertMicrosecondsToMilliseconds = (microseconds: number | null): number | null => { if (!microseconds && microseconds !== 0) return null; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/format_error_list.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/format_error_list.ts deleted file mode 100644 index a23122c5eead5..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/format_error_list.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { i18n } from '@kbn/i18n'; -import { GraphQLError } from 'graphql'; - -export const formatUptimeGraphQLErrorList = (errors: GraphQLError[]) => - errors.reduce( - (errorString, error) => - errorString.concat( - `${i18n.translate('xpack.uptime.errorMessage', { - values: { message: error.message }, - defaultMessage: 'Error: {message}', - })}\n` - ), - '' - ); diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_apm_href.test.ts.snap b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_apm_href.test.ts.snap deleted file mode 100644 index 53d336b52bd24..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_apm_href.test.ts.snap +++ /dev/null @@ -1,5 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`getApmHref creates href with base path when present 1`] = `"foo/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`; - -exports[`getApmHref does not add a base path or extra slash when base path is empty string 1`] = `"/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_infra_href.test.ts.snap b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_infra_href.test.ts.snap deleted file mode 100644 index e79eb50d384a8..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_infra_href.test.ts.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`getInfraHref getInfraContainerHref creates a link for valid parameters 1`] = `"foo/app/metrics/link-to/container-detail/test-container-id"`; - -exports[`getInfraHref getInfraContainerHref does not specify a base path when none is available 1`] = `"/app/metrics/link-to/container-detail/test-container-id"`; - -exports[`getInfraHref getInfraContainerHref returns the first item when multiple container ids are supplied 1`] = `"bar/app/metrics/link-to/container-detail/test-container-id"`; - -exports[`getInfraHref getInfraIpHref creates a link for valid parameters 1`] = `"bar/app/metrics/inventory?waffleFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"`; - -exports[`getInfraHref getInfraIpHref does not specify a base path when none is available 1`] = `"/app/metrics/inventory?waffleFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"`; - -exports[`getInfraHref getInfraIpHref returns a url for ors between multiple ips 1`] = `"foo/app/metrics/inventory?waffleFilter=(expression:'host.ip%20%3A%20152.151.23.192%20or%20host.ip%20%3A%20151.101.202.217',kind:kuery)"`; - -exports[`getInfraHref getInfraKubernetesHref creates a link for valid parameters 1`] = `"foo/app/metrics/link-to/pod-detail/test-pod-uid"`; - -exports[`getInfraHref getInfraKubernetesHref does not specify a base path when none is available 1`] = `"/app/metrics/link-to/pod-detail/test-pod-uid"`; - -exports[`getInfraHref getInfraKubernetesHref selects the first pod uid when there are multiple 1`] = `"/app/metrics/link-to/pod-detail/test-pod-uid"`; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_logging_href.test.ts.snap b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_logging_href.test.ts.snap deleted file mode 100644 index cfac6ce133c8a..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/__snapshots__/get_logging_href.test.ts.snap +++ /dev/null @@ -1,13 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`getLoggingHref creates a container href with base path when present 1`] = `"bar/app/logs?logFilter=(expression:'container.id%20:%20test-container-id',kind:kuery)"`; - -exports[`getLoggingHref creates a container href without a base path if it's an empty string 1`] = `"/app/logs?logFilter=(expression:'container.id%20:%20test-container-id',kind:kuery)"`; - -exports[`getLoggingHref creates a pod href with base path when present 1`] = `"bar/app/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"`; - -exports[`getLoggingHref creates a pod href without a base path when it's an empty string 1`] = `"/app/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"`; - -exports[`getLoggingHref creates an ip href with base path when present 1`] = `"bar/app/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"`; - -exports[`getLoggingHref creates an ip href without a base path when it's an empty string 1`] = `"/app/logs?logFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"`; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_apm_href.test.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_apm_href.test.ts index db49e95896ac1..f27ed78d593ac 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_apm_href.test.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_apm_href.test.ts @@ -5,7 +5,7 @@ */ import { getApmHref } from '../get_apm_href'; -import { MonitorSummary } from '../../../../../common/graphql/types'; +import { MonitorSummary } from '../../../../../common/runtime_types'; describe('getApmHref', () => { let summary: MonitorSummary; @@ -29,7 +29,7 @@ describe('getApmHref', () => { uid: 'test-pod-id', }, }, - timestamp: '123', + timestamp: 123, }, ], timestamp: '123', @@ -43,11 +43,15 @@ describe('getApmHref', () => { it('creates href with base path when present', () => { const result = getApmHref(summary, 'foo', 'now-15m', 'now'); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"foo/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"` + ); }); it('does not add a base path or extra slash when base path is empty string', () => { const result = getApmHref(summary, '', 'now-15m', 'now'); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"` + ); }); }); diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_infra_href.test.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_infra_href.test.ts index c2360c321da8f..ee5db74af22c2 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_infra_href.test.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_infra_href.test.ts @@ -5,7 +5,7 @@ */ import { getInfraContainerHref, getInfraKubernetesHref, getInfraIpHref } from '../get_infra_href'; -import { MonitorSummary } from '../../../../../common/graphql/types'; +import { MonitorSummary } from '../../../../../common/runtime_types'; describe('getInfraHref', () => { let summary: MonitorSummary; @@ -13,7 +13,6 @@ describe('getInfraHref', () => { summary = { monitor_id: 'foo', state: { - summary: {}, checks: [ { monitor: { @@ -28,9 +27,11 @@ describe('getInfraHref', () => { uid: 'test-pod-uid', }, }, - timestamp: '123', + timestamp: 123, }, ], + summary: {}, + url: {}, timestamp: '123', }, }; @@ -38,11 +39,15 @@ describe('getInfraHref', () => { it('getInfraContainerHref creates a link for valid parameters', () => { const result = getInfraContainerHref(summary, 'foo'); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"foo/app/metrics/link-to/container-detail/test-container-id"` + ); }); it('getInfraContainerHref does not specify a base path when none is available', () => { - expect(getInfraContainerHref(summary, '')).toMatchSnapshot(); + expect(getInfraContainerHref(summary, '')).toMatchInlineSnapshot( + `"/app/metrics/link-to/container-detail/test-container-id"` + ); }); it('getInfraContainerHref returns undefined when no container id is present', () => { @@ -65,7 +70,7 @@ describe('getInfraHref', () => { uid: 'test-pod-uid', }, }, - timestamp: '123', + timestamp: 123, }, { monitor: { @@ -80,10 +85,12 @@ describe('getInfraHref', () => { uid: 'test-pod-uid-bar', }, }, - timestamp: '123', + timestamp: 123, }, ]; - expect(getInfraContainerHref(summary, 'bar')).toMatchSnapshot(); + expect(getInfraContainerHref(summary, 'bar')).toMatchInlineSnapshot( + `"bar/app/metrics/link-to/container-detail/test-container-id"` + ); }); it('getInfraContainerHref returns undefined when checks are undefined', () => { @@ -94,11 +101,13 @@ describe('getInfraHref', () => { it('getInfraKubernetesHref creates a link for valid parameters', () => { const result = getInfraKubernetesHref(summary, 'foo'); expect(result).not.toBeUndefined(); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot(`"foo/app/metrics/link-to/pod-detail/test-pod-uid"`); }); it('getInfraKubernetesHref does not specify a base path when none is available', () => { - expect(getInfraKubernetesHref(summary, '')).toMatchSnapshot(); + expect(getInfraKubernetesHref(summary, '')).toMatchInlineSnapshot( + `"/app/metrics/link-to/pod-detail/test-pod-uid"` + ); }); it('getInfraKubernetesHref returns undefined when no pod data is present', () => { @@ -121,7 +130,7 @@ describe('getInfraHref', () => { uid: 'test-pod-uid', }, }, - timestamp: '123', + timestamp: 123, }, { monitor: { @@ -136,10 +145,12 @@ describe('getInfraHref', () => { uid: 'test-pod-uid-bar', }, }, - timestamp: '123', + timestamp: 123, }, ]; - expect(getInfraKubernetesHref(summary, '')).toMatchSnapshot(); + expect(getInfraKubernetesHref(summary, '')).toMatchInlineSnapshot( + `"/app/metrics/link-to/pod-detail/test-pod-uid"` + ); }); it('getInfraKubernetesHref returns undefined when checks are undefined', () => { @@ -148,17 +159,21 @@ describe('getInfraHref', () => { }); it('getInfraKubernetesHref returns undefined when checks are null', () => { - summary.state.checks![0]!.kubernetes!.pod!.uid = null; + delete summary.state.checks![0]!.kubernetes!.pod!.uid; expect(getInfraKubernetesHref(summary, '')).toBeUndefined(); }); it('getInfraIpHref creates a link for valid parameters', () => { const result = getInfraIpHref(summary, 'bar'); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"bar/app/metrics/inventory?waffleFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"` + ); }); it('getInfraIpHref does not specify a base path when none is available', () => { - expect(getInfraIpHref(summary, '')).toMatchSnapshot(); + expect(getInfraIpHref(summary, '')).toMatchInlineSnapshot( + `"/app/metrics/inventory?waffleFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"` + ); }); it('getInfraIpHref returns undefined when ip is undefined', () => { @@ -167,14 +182,14 @@ describe('getInfraHref', () => { }); it('getInfraIpHref returns undefined when ip is null', () => { - summary.state.checks![0].monitor.ip = null; + delete summary.state.checks![0].monitor.ip; expect(getInfraIpHref(summary, 'foo')).toBeUndefined(); }); it('getInfraIpHref returns a url for ors between multiple ips', () => { summary.state.checks = [ { - timestamp: '123', + timestamp: 123, monitor: { ip: '152.151.23.192', status: 'up', @@ -193,10 +208,12 @@ describe('getInfraHref', () => { uid: 'test-pod-uid', }, }, - timestamp: '123', + timestamp: 123, }, ]; - expect(getInfraIpHref(summary, 'foo')).toMatchSnapshot(); + expect(getInfraIpHref(summary, 'foo')).toMatchInlineSnapshot( + `"foo/app/metrics/inventory?waffleFilter=(expression:'host.ip%20%3A%20152.151.23.192%20or%20host.ip%20%3A%20151.101.202.217',kind:kuery)"` + ); }); it('getInfraIpHref returns undefined if checks are undefined', () => { diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_logging_href.test.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_logging_href.test.ts index 1117fa1429962..b188a8d1b8ef6 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_logging_href.test.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/__tests__/get_logging_href.test.ts @@ -9,7 +9,7 @@ import { getLoggingKubernetesHref, getLoggingIpHref, } from '../get_logging_href'; -import { MonitorSummary } from '../../../../../common/graphql/types'; +import { MonitorSummary } from '../../../../../common/runtime_types'; describe('getLoggingHref', () => { let summary: MonitorSummary; @@ -33,10 +33,11 @@ describe('getLoggingHref', () => { uid: 'test-pod-id', }, }, - timestamp: '123', + timestamp: 123, }, ], timestamp: '123', + url: {}, }, }; }); @@ -44,37 +45,49 @@ describe('getLoggingHref', () => { it('creates a container href with base path when present', () => { const result = getLoggingContainerHref(summary, 'bar'); expect(result).not.toBeUndefined(); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"bar/app/logs?logFilter=(expression:'container.id%20:%20test-container-id',kind:kuery)"` + ); }); it(`creates a container href without a base path if it's an empty string`, () => { const result = getLoggingContainerHref(summary, ''); expect(result).not.toBeUndefined(); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"/app/logs?logFilter=(expression:'container.id%20:%20test-container-id',kind:kuery)"` + ); }); it(`creates an ip href with base path when present`, () => { const result = getLoggingKubernetesHref(summary, 'bar'); expect(result).not.toBeUndefined(); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"bar/app/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"` + ); }); it('creates a pod href with base path when present', () => { const result = getLoggingKubernetesHref(summary, 'bar'); expect(result).not.toBeUndefined(); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"bar/app/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"` + ); }); it(`creates a pod href without a base path when it's an empty string`, () => { const result = getLoggingKubernetesHref(summary, ''); expect(result).not.toBeUndefined(); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"/app/logs?logFilter=(expression:'pod.uid%20:%20test-pod-id',kind:kuery)"` + ); }); it(`creates an ip href without a base path when it's an empty string`, () => { const result = getLoggingIpHref(summary, ''); expect(result).not.toBeUndefined(); - expect(result).toMatchSnapshot(); + expect(result).toMatchInlineSnapshot( + `"/app/logs?logFilter=(expression:'host.ip%20%3A%20151.101.202.217',kind:kuery)"` + ); }); it('returns undefined if necessary container is not present', () => { @@ -83,7 +96,7 @@ describe('getLoggingHref', () => { }); it('returns undefined if necessary container is null', () => { - summary.state.checks![0].container!.id = null; + delete summary.state.checks![0].container!.id; expect(getLoggingContainerHref(summary, '')).toBeUndefined(); }); @@ -93,7 +106,7 @@ describe('getLoggingHref', () => { }); it('returns undefined if necessary pod is null', () => { - summary.state.checks![0].kubernetes!.pod!.uid = null; + delete summary.state.checks![0].kubernetes!.pod!.uid; expect(getLoggingKubernetesHref(summary, '')).toBeUndefined(); }); @@ -103,7 +116,7 @@ describe('getLoggingHref', () => { }); it('returns undefined ip href if ip is null', () => { - summary.state.checks![0].monitor.ip = null; + delete summary.state.checks![0].monitor.ip; expect(getLoggingIpHref(summary, '')).toBeUndefined(); }); }); diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/build_href.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/build_href.ts index 19e437651090b..0f830435be89d 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/build_href.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/build_href.ts @@ -5,7 +5,7 @@ */ import { get } from 'lodash'; -import { Check } from '../../../../common/graphql/types'; +import { Check } from '../../../../common/runtime_types'; /** * Builds URLs to the designated features by extracting values from the provided diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_apm_href.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_apm_href.ts index aaa57acee6c6a..0ff5a8acb3367 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_apm_href.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_apm_href.ts @@ -6,7 +6,7 @@ import { get } from 'lodash'; import { addBasePath } from './add_base_path'; -import { MonitorSummary } from '../../../../common/graphql/types'; +import { MonitorSummary } from '../../../../common/runtime_types'; export const getApmHref = ( summary: MonitorSummary, diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_infra_href.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_infra_href.ts index 73065be395c76..384067e4b033b 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_infra_href.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_infra_href.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { MonitorSummary } from '../../../../common/graphql/types'; +import { MonitorSummary } from '../../../../common/runtime_types'; import { addBasePath } from './add_base_path'; import { buildHref } from './build_href'; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_logging_href.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_logging_href.ts index b97b5a34855fb..222c7b57c9272 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_logging_href.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/observability_integration/get_logging_href.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { MonitorSummary } from '../../../../common/graphql/types'; +import { MonitorSummary } from '../../../../common/runtime_types'; import { addBasePath } from './add_base_path'; import { buildHref } from './build_href'; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/series_has_down_values.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/series_has_down_values.ts index 13079b912a147..4ebeb350ed892 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/series_has_down_values.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/series_has_down_values.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SummaryHistogramPoint } from '../../../common/graphql/types'; +import { HistogramPoint } from '../../../common/runtime_types'; -export const seriesHasDownValues = (series: SummaryHistogramPoint[] | null): boolean => { +export const seriesHasDownValues = (series: HistogramPoint[] | null): boolean => { return series ? series.some(point => !!point.down) : false; }; diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/url_params/__tests__/parse_absolute_date.test.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/url_params/__tests__/parse_absolute_date.test.ts index 691b38bdf9ca2..16888aec21cfe 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/url_params/__tests__/parse_absolute_date.test.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/helper/url_params/__tests__/parse_absolute_date.test.ts @@ -24,7 +24,7 @@ describe('parseAbsoluteDate', () => { it('returns the default value if the parser provides `undefined`', () => { dateMathSpy.mockReturnValue(undefined); - const result = parseAbsoluteDate('this is not a valid datae', 12345); + const result = parseAbsoluteDate('this is not a valid date', 12345); expect(result).toBe(12345); }); }); diff --git a/x-pack/legacy/plugins/uptime/public/lib/helper/url_params/__tests__/parse_autorefresh_interval.test.ts b/x-pack/legacy/plugins/uptime/public/lib/helper/url_params/__tests__/parse_autorefresh_interval.test.ts deleted file mode 100644 index a5c2168378089..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/lib/helper/url_params/__tests__/parse_autorefresh_interval.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { parseUrlInt } from '../parse_url_int'; - -describe('parseUrlInt', () => { - it('parses a number', () => { - const result = parseUrlInt('23', 50); - expect(result).toBe(23); - }); - - it('returns default value for empty string', () => { - const result = parseUrlInt('', 50); - expect(result).toBe(50); - }); - - it('returns default value for non-numeric string', () => { - const result = parseUrlInt('abc', 50); - expect(result).toBe(50); - }); -}); diff --git a/x-pack/legacy/plugins/uptime/public/lib/lib.ts b/x-pack/legacy/plugins/uptime/public/lib/lib.ts index aba151bf5aab3..7dd3aa9eed5ce 100644 --- a/x-pack/legacy/plugins/uptime/public/lib/lib.ts +++ b/x-pack/legacy/plugins/uptime/public/lib/lib.ts @@ -4,10 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { NormalizedCacheObject } from 'apollo-cache-inmemory'; -import ApolloClient from 'apollo-client'; -import React from 'react'; -import { ChromeBreadcrumb } from 'src/core/public'; +import { ReactElement } from 'react'; import { UMBadge } from '../badge'; import { UptimeAppProps } from '../uptime_app'; @@ -15,13 +12,9 @@ export interface UMFrontendLibs { framework: UMFrameworkAdapter; } -export type UMUpdateBreadcrumbs = (breadcrumbs: ChromeBreadcrumb[]) => void; - export type UMUpdateBadge = (badge: UMBadge) => void; -export type UMGraphQLClient = ApolloClient; // | OtherClientType - -export type BootstrapUptimeApp = (props: UptimeAppProps) => React.ReactElement; +export type BootstrapUptimeApp = (props: UptimeAppProps) => ReactElement; export interface UMFrameworkAdapter { render(element: any): void; diff --git a/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx b/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx index 683af81239c99..4495be9b24dc1 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/monitor.tsx @@ -8,12 +8,13 @@ import { EuiSpacer } from '@elastic/eui'; import React from 'react'; import { useSelector } from 'react-redux'; import { useTrackPageview } from '../../../../../plugins/observability/public'; -import { MonitorStatusDetails, PingList } from '../components/connected'; import { monitorStatusSelector } from '../state/selectors'; import { PageHeader } from './page_header'; -import { MonitorCharts } from '../components/functional'; import { useBreadcrumbs } from '../hooks/use_breadcrumbs'; import { useMonitorId, useUptimeTelemetry, UptimePage } from '../hooks'; +import { MonitorCharts } from '../components/monitor'; +import { MonitorStatusDetails } from '../components/monitor'; +import { PingList } from '../components/monitor'; export const MonitorPage: React.FC = () => { const monitorId = useMonitorId(); diff --git a/x-pack/legacy/plugins/uptime/public/pages/overview.tsx b/x-pack/legacy/plugins/uptime/public/pages/overview.tsx index 5550facaf42e9..adc36efa6f7db 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/overview.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/overview.tsx @@ -5,23 +5,19 @@ */ import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; -import React, { useContext, useEffect, useState } from 'react'; +import React, { useEffect } from 'react'; import styled from 'styled-components'; import { i18n } from '@kbn/i18n'; -import { - MonitorList, - OverviewPageParsingErrorCallout, - StatusPanel, -} from '../components/functional'; import { useUptimeTelemetry, UptimePage, useGetUrlParams } from '../hooks'; import { stringifyUrlParams } from '../lib/helper/stringify_url_params'; import { useTrackPageview } from '../../../../../plugins/observability/public'; import { DataPublicPluginSetup, IIndexPattern } from '../../../../../../src/plugins/data/public'; -import { UptimeThemeContext } from '../contexts'; -import { EmptyState, FilterGroup, KueryBar } from '../components/connected'; import { useUpdateKueryString } from '../hooks'; import { PageHeader } from './page_header'; import { useBreadcrumbs } from '../hooks/use_breadcrumbs'; +import { MonitorList } from '../components/overview/monitor_list/monitor_list_container'; +import { EmptyState, FilterGroup, KueryBar, ParsingErrorCallout } from '../components/overview'; +import { StatusPanel } from '../components/overview/status_panel'; interface OverviewPageProps { autocomplete: DataPublicPluginSetup['autocomplete']; @@ -40,34 +36,9 @@ const EuiFlexItemStyled = styled(EuiFlexItem)` } `; -// TODO: these values belong deeper down in the monitor -// list pagination control, but are here temporarily until we -// are done removing GraphQL -const DEFAULT_PAGE_SIZE = 10; -const LOCAL_STORAGE_KEY = 'xpack.uptime.monitorList.pageSize'; -const getMonitorListPageSizeValue = () => { - const value = parseInt(localStorage.getItem(LOCAL_STORAGE_KEY) ?? '', 10); - if (isNaN(value)) { - return DEFAULT_PAGE_SIZE; - } - return value; -}; - export const OverviewPageComponent = ({ autocomplete, indexPattern, setEsKueryFilters }: Props) => { - const { colors } = useContext(UptimeThemeContext); - // TODO: this is temporary until we migrate the monitor list to our Redux implementation - const [monitorListPageSize, setMonitorListPageSize] = useState( - getMonitorListPageSizeValue() - ); const { absoluteDateRangeStart, absoluteDateRangeEnd, ...params } = useGetUrlParams(); - const { - dateRangeStart, - dateRangeEnd, - pagination, - statusFilter, - search, - filters: urlFilters, - } = params; + const { search, filters: urlFilters } = params; useUptimeTelemetry(UptimePage.Overview); @@ -80,13 +51,6 @@ export const OverviewPageComponent = ({ autocomplete, indexPattern, setEsKueryFi setEsKueryFilters(esFilters ?? ''); }, [esFilters, setEsKueryFilters]); - const sharedProps = { - dateRangeStart, - dateRangeEnd, - statusFilter, - filters: esFilters, - }; - const linkParameters = stringifyUrlParams(params, true); const heading = i18n.translate('xpack.uptime.overviewPage.headerText', { @@ -112,25 +76,12 @@ export const OverviewPageComponent = ({ autocomplete, indexPattern, setEsKueryFi - {error && } + {error && } - + ); diff --git a/x-pack/legacy/plugins/uptime/public/pages/page_header.tsx b/x-pack/legacy/plugins/uptime/public/pages/page_header.tsx index 821a70c85dc7c..b10bc6ba44f8a 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/page_header.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/page_header.tsx @@ -8,16 +8,18 @@ import React from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiSpacer, EuiButtonEmpty } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { Link } from 'react-router-dom'; -import { UptimeDatePicker } from '../components/functional/uptime_date_picker'; +import { UptimeDatePicker } from '../components/common/uptime_date_picker'; import { SETTINGS_ROUTE } from '../../common/constants'; -import { ToggleAlertFlyoutButton } from '../components/connected'; +import { ToggleAlertFlyoutButton } from '../components/overview/alerts/alerts_containers'; interface PageHeaderProps { headingText: string; extraLinks?: boolean; datePicker?: boolean; } - +const SETTINGS_LINK_TEXT = i18n.translate('xpack.uptime.page_header.settingsLink', { + defaultMessage: 'Settings', +}); export const PageHeader = React.memo( ({ headingText, extraLinks = false, datePicker = true }: PageHeaderProps) => { const datePickerComponent = datePicker ? ( @@ -26,9 +28,6 @@ export const PageHeader = React.memo( ) : null; - const settingsLinkText = i18n.translate('xpack.uptime.page_header.settingsLink', { - defaultMessage: 'Settings', - }); const extraLinkComponents = !extraLinks ? null : ( @@ -37,7 +36,7 @@ export const PageHeader = React.memo( - {settingsLinkText} + {SETTINGS_LINK_TEXT} diff --git a/x-pack/legacy/plugins/uptime/public/pages/settings.tsx b/x-pack/legacy/plugins/uptime/public/pages/settings.tsx index 765b0e3c664bc..6defb96e0da3d 100644 --- a/x-pack/legacy/plugins/uptime/public/pages/settings.tsx +++ b/x-pack/legacy/plugins/uptime/public/pages/settings.tsx @@ -9,46 +9,54 @@ import { EuiButton, EuiButtonEmpty, EuiCallOut, - EuiCode, - EuiDescribedFormGroup, - EuiFieldText, EuiFlexGroup, EuiFlexItem, EuiForm, - EuiFormRow, EuiPanel, EuiSpacer, - EuiTitle, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { connect } from 'react-redux'; -import { isEqual } from 'lodash'; +import { useDispatch, useSelector } from 'react-redux'; +import { cloneDeep, isEqual, set } from 'lodash'; import { i18n } from '@kbn/i18n'; import { Link } from 'react-router-dom'; -import { AppState } from '../state'; import { selectDynamicSettings } from '../state/selectors'; -import { DynamicSettingsState } from '../state/reducers/dynamic_settings'; import { getDynamicSettings, setDynamicSettings } from '../state/actions/dynamic_settings'; -import { defaultDynamicSettings, DynamicSettings } from '../../common/runtime_types'; +import { DynamicSettings } from '../../common/runtime_types'; import { useBreadcrumbs } from '../hooks/use_breadcrumbs'; import { OVERVIEW_ROUTE } from '../../common/constants'; import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; import { UptimePage, useUptimeTelemetry } from '../hooks'; +import { IndicesForm } from '../components/settings/indices_form'; +import { + CertificateExpirationForm, + OnFieldChangeType, +} from '../components/settings/certificate_form'; + +const getFieldErrors = (formFields: DynamicSettings | null) => { + if (formFields) { + const blankStr = 'May not be blank'; + const { certificatesThresholds, heartbeatIndices } = formFields; + const heartbeatIndErr = heartbeatIndices.match(/^\S+$/) ? '' : blankStr; + const errorStateErr = certificatesThresholds?.errorState ? null : blankStr; + const warningStateErr = certificatesThresholds?.warningState ? null : blankStr; + return { + heartbeatIndices: heartbeatIndErr, + certificatesThresholds: + errorStateErr || warningStateErr + ? { + errorState: errorStateErr, + warningState: warningStateErr, + } + : null, + }; + } + return null; +}; -interface Props { - dynamicSettingsState: DynamicSettingsState; -} - -interface DispatchProps { - dispatchGetDynamicSettings: typeof getDynamicSettings; - dispatchSetDynamicSettings: typeof setDynamicSettings; -} +export const SettingsPage = () => { + const dss = useSelector(selectDynamicSettings); -export const SettingsPageComponent = ({ - dynamicSettingsState: dss, - dispatchGetDynamicSettings, - dispatchSetDynamicSettings, -}: Props & DispatchProps) => { const settingsBreadcrumbText = i18n.translate('xpack.uptime.settingsBreadcrumbText', { defaultMessage: 'Settings', }); @@ -56,9 +64,11 @@ export const SettingsPageComponent = ({ useUptimeTelemetry(UptimePage.Settings); + const dispatch = useDispatch(); + useEffect(() => { - dispatchGetDynamicSettings({}); - }, [dispatchGetDynamicSettings]); + dispatch(getDynamicSettings()); + }, [dispatch]); const [formFields, setFormFields] = useState(dss.settings || null); @@ -66,22 +76,22 @@ export const SettingsPageComponent = ({ setFormFields({ ...dss.settings }); } - const fieldErrors = formFields && { - heartbeatIndices: formFields.heartbeatIndices.match(/^\S+$/) ? null : 'May not be blank', - }; + const fieldErrors = getFieldErrors(formFields); + const isFormValid = !(fieldErrors && Object.values(fieldErrors).find(v => !!v)); - const onChangeFormField = (field: keyof DynamicSettings, value: any) => { + const onChangeFormField: OnFieldChangeType = (field, value) => { if (formFields) { - formFields[field] = value; - setFormFields({ ...formFields }); + const newFormFields = cloneDeep(formFields); + set(newFormFields, field, value); + setFormFields(cloneDeep(newFormFields)); } }; const onApply = (event: React.FormEvent) => { event.preventDefault(); if (formFields) { - dispatchSetDynamicSettings(formFields); + dispatch(setDynamicSettings(formFields)); } }; @@ -128,68 +138,18 @@ export const SettingsPageComponent = ({
- -

- -

-
- - - - - } - description={ - - } - > - {defaultDynamicSettings.heartbeatIndices} - ), - }} - /> - } - isInvalid={!!fieldErrors?.heartbeatIndices} - label={ - - } - > - - onChangeFormField('heartbeatIndices', event.currentTarget.value) - } - /> - - + + @@ -230,18 +190,3 @@ export const SettingsPageComponent = ({ ); }; - -const mapStateToProps = (state: AppState) => ({ - dynamicSettingsState: selectDynamicSettings(state), -}); - -const mapDispatchToProps = (dispatch: any) => ({ - dispatchGetDynamicSettings: () => { - return dispatch(getDynamicSettings({})); - }, - dispatchSetDynamicSettings: (settings: DynamicSettings) => { - return dispatch(setDynamicSettings(settings)); - }, -}); - -export const SettingsPage = connect(mapStateToProps, mapDispatchToProps)(SettingsPageComponent); diff --git a/x-pack/legacy/plugins/uptime/public/queries/monitor_states_query.ts b/x-pack/legacy/plugins/uptime/public/queries/monitor_states_query.ts deleted file mode 100644 index 676e638c239de..0000000000000 --- a/x-pack/legacy/plugins/uptime/public/queries/monitor_states_query.ts +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import gql from 'graphql-tag'; - -export const monitorStatesQueryString = ` -query MonitorStates($dateRangeStart: String!, $dateRangeEnd: String!, $pagination: String, $filters: String, $statusFilter: String, $pageSize: Int) { - monitorStates: getMonitorStates( - dateRangeStart: $dateRangeStart - dateRangeEnd: $dateRangeEnd - pagination: $pagination - filters: $filters - statusFilter: $statusFilter - pageSize: $pageSize - ) { - prevPagePagination - nextPagePagination - totalSummaryCount - summaries { - monitor_id - histogram { - count - points { - timestamp - up - down - } - } - state { - agent { - id - } - checks { - agent { - id - } - container { - id - } - kubernetes { - pod { - uid - } - } - monitor { - ip - name - status - } - observer { - geo { - name - location { - lat - lon - } - } - } - timestamp - } - geo { - name - location { - lat - lon - } - } - observer { - geo { - name - location { - lat - lon - } - } - } - monitor { - id - name - status - type - } - summary { - up - down - geo { - name - location { - lat - lon - } - } - } - url { - full - domain - } - timestamp - } - } - } -} -`; - -export const monitorStatesQuery = gql` - ${monitorStatesQueryString} -`; diff --git a/x-pack/legacy/plugins/uptime/public/routes.tsx b/x-pack/legacy/plugins/uptime/public/routes.tsx index bb0700287dbf1..b5e20ef8a70a9 100644 --- a/x-pack/legacy/plugins/uptime/public/routes.tsx +++ b/x-pack/legacy/plugins/uptime/public/routes.tsx @@ -7,7 +7,7 @@ import React, { FC } from 'react'; import { Route, Switch } from 'react-router-dom'; import { DataPublicPluginSetup } from '../../../../../src/plugins/data/public'; -import { OverviewPage } from './components/connected/pages/overview_container'; +import { OverviewPage } from './components/overview/overview_container'; import { MONITOR_ROUTE, OVERVIEW_ROUTE, SETTINGS_ROUTE } from '../common/constants'; import { MonitorPage, NotFoundPage, SettingsPage } from './pages'; diff --git a/x-pack/legacy/plugins/uptime/public/state/actions/dynamic_settings.ts b/x-pack/legacy/plugins/uptime/public/state/actions/dynamic_settings.ts index d78c725c4b599..3dbb1aa234621 100644 --- a/x-pack/legacy/plugins/uptime/public/state/actions/dynamic_settings.ts +++ b/x-pack/legacy/plugins/uptime/public/state/actions/dynamic_settings.ts @@ -6,7 +6,7 @@ import { createAction } from 'redux-actions'; import { DynamicSettings } from '../../../common/runtime_types'; -export const getDynamicSettings = createAction<{}>('GET_DYNAMIC_SETTINGS'); +export const getDynamicSettings = createAction('GET_DYNAMIC_SETTINGS'); export const getDynamicSettingsSuccess = createAction( 'GET_DYNAMIC_SETTINGS_SUCCESS' ); @@ -17,4 +17,3 @@ export const setDynamicSettingsSuccess = createAction( 'SET_DYNAMIC_SETTINGS_SUCCESS' ); export const setDynamicSettingsFail = createAction('SET_DYNAMIC_SETTINGS_FAIL'); -export const acknowledgeSetDynamicSettings = createAction<{}>('ACKNOWLEDGE_SET_DYNAMIC_SETTINGS'); diff --git a/x-pack/legacy/plugins/uptime/public/state/actions/index.ts b/x-pack/legacy/plugins/uptime/public/state/actions/index.ts index 4563e6bfc4f0e..0dc6baa0b2e50 100644 --- a/x-pack/legacy/plugins/uptime/public/state/actions/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/actions/index.ts @@ -7,6 +7,7 @@ export * from './overview_filters'; export * from './snapshot'; export * from './ui'; +export * from './monitor_list'; export * from './monitor_status'; export * from './index_patternts'; export * from './ping'; diff --git a/x-pack/legacy/plugins/uptime/public/state/actions/monitor_list.ts b/x-pack/legacy/plugins/uptime/public/state/actions/monitor_list.ts new file mode 100644 index 0000000000000..ee2267a9058af --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/actions/monitor_list.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { createAction } from 'redux-actions'; +import { FetchMonitorStatesQueryArgs, MonitorSummaryResult } from '../../../common/runtime_types'; + +export const getMonitorList = createAction('GET_MONITOR_LIST'); +export const getMonitorListSuccess = createAction('GET_MONITOR_LIST_SUCCESS'); +export const getMonitorListFailure = createAction('GET_MONITOR_LIST_FAIL'); diff --git a/x-pack/legacy/plugins/uptime/public/state/actions/monitor_status.ts b/x-pack/legacy/plugins/uptime/public/state/actions/monitor_status.ts index e8c862e209739..3d480e66c9e0b 100644 --- a/x-pack/legacy/plugins/uptime/public/state/actions/monitor_status.ts +++ b/x-pack/legacy/plugins/uptime/public/state/actions/monitor_status.ts @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + import { createAction } from 'redux-actions'; import { QueryParams } from './types'; import { Ping } from '../../../common/runtime_types'; diff --git a/x-pack/legacy/plugins/uptime/public/state/api/dynamic_settings.ts b/x-pack/legacy/plugins/uptime/public/state/api/dynamic_settings.ts index 8ade2aa4595dc..e52e40c53513c 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/dynamic_settings.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/dynamic_settings.ts @@ -14,22 +14,15 @@ import { apiService } from './utils'; const apiPath = '/api/uptime/dynamic_settings'; -interface BaseApiRequest { - basePath: string; -} - -type SaveApiRequest = BaseApiRequest & { +interface SaveApiRequest { settings: DynamicSettings; -}; +} -export const getDynamicSettings = async ({ - basePath, -}: BaseApiRequest): Promise => { +export const getDynamicSettings = async (): Promise => { return await apiService.get(apiPath, undefined, DynamicSettingsType); }; export const setDynamicSettings = async ({ - basePath, settings, }: SaveApiRequest): Promise => { return await apiService.post(apiPath, settings, DynamicSettingsSaveType); diff --git a/x-pack/legacy/plugins/uptime/public/state/api/index.ts b/x-pack/legacy/plugins/uptime/public/state/api/index.ts index 793762c0f4a10..a50afb3f866de 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/index.ts @@ -5,6 +5,7 @@ */ export * from './monitor'; +export * from './monitor_list'; export * from './overview_filters'; export * from './snapshot'; export * from './monitor_status'; diff --git a/x-pack/legacy/plugins/uptime/public/state/api/monitor.ts b/x-pack/legacy/plugins/uptime/public/state/api/monitor.ts index b36eccca98da9..c3d0a0180cf51 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/monitor.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/monitor.ts @@ -8,7 +8,7 @@ import { BaseParams } from './types'; import { MonitorDetailsType, MonitorLocationsType } from '../../../common/runtime_types'; import { QueryParams } from '../actions/types'; import { apiService } from './utils'; -import { API_URLS } from '../../../common/constants/rest_api'; +import { API_URLS } from '../../../common/constants'; interface ApiRequest { monitorId: string; diff --git a/x-pack/legacy/plugins/uptime/public/state/api/monitor_duration.ts b/x-pack/legacy/plugins/uptime/public/state/api/monitor_duration.ts index daf725119fcf3..91034f1784b15 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/monitor_duration.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/monitor_duration.ts @@ -6,7 +6,7 @@ import { BaseParams } from './types'; import { apiService } from './utils'; -import { API_URLS } from '../../../common/constants/rest_api'; +import { API_URLS } from '../../../common/constants'; export const fetchMonitorDuration = async ({ monitorId, dateStart, dateEnd }: BaseParams) => { const queryParams = { diff --git a/x-pack/legacy/plugins/uptime/public/state/api/monitor_list.ts b/x-pack/legacy/plugins/uptime/public/state/api/monitor_list.ts new file mode 100644 index 0000000000000..084bcb4bd2a91 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/api/monitor_list.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { API_URLS } from '../../../common/constants'; +import { apiService } from './utils'; +import { + FetchMonitorStatesQueryArgs, + MonitorSummaryResult, + MonitorSummaryResultType, +} from '../../../common/runtime_types'; + +export const fetchMonitorList = async ( + params: FetchMonitorStatesQueryArgs +): Promise => { + return await apiService.get(API_URLS.MONITOR_LIST, params, MonitorSummaryResultType); +}; diff --git a/x-pack/legacy/plugins/uptime/public/state/api/overview_filters.ts b/x-pack/legacy/plugins/uptime/public/state/api/overview_filters.ts index 9943bc27f11f0..6330d8a912210 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/overview_filters.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/overview_filters.ts @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { GetOverviewFiltersPayload } from '../actions/overview_filters'; +import { GetOverviewFiltersPayload } from '../actions'; import { OverviewFiltersType } from '../../../common/runtime_types'; import { apiService } from './utils'; -import { API_URLS } from '../../../common/constants/rest_api'; +import { API_URLS } from '../../../common/constants'; export const fetchOverviewFilters = async ({ dateRangeStart, diff --git a/x-pack/legacy/plugins/uptime/public/state/api/ping.ts b/x-pack/legacy/plugins/uptime/public/state/api/ping.ts index bbd3ddf399dcc..6de27879a49f5 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/ping.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/ping.ts @@ -13,7 +13,7 @@ import { HistogramResult, } from '../../../common/runtime_types'; import { apiService } from './utils'; -import { API_URLS } from '../../../common/constants/rest_api'; +import { API_URLS } from '../../../common/constants'; export const fetchPings: APIFn = async ({ dateRange: { from, to }, diff --git a/x-pack/legacy/plugins/uptime/public/state/api/snapshot.ts b/x-pack/legacy/plugins/uptime/public/state/api/snapshot.ts index e663d0241d688..9ee53dd2cbcef 100644 --- a/x-pack/legacy/plugins/uptime/public/state/api/snapshot.ts +++ b/x-pack/legacy/plugins/uptime/public/state/api/snapshot.ts @@ -6,7 +6,7 @@ import { SnapshotType, Snapshot } from '../../../common/runtime_types'; import { apiService } from './utils'; -import { API_URLS } from '../../../common/constants/rest_api'; +import { API_URLS } from '../../../common/constants'; export interface SnapShotQueryParams { dateRangeStart: string; diff --git a/x-pack/legacy/plugins/uptime/public/state/effects/dynamic_settings.ts b/x-pack/legacy/plugins/uptime/public/state/effects/dynamic_settings.ts index 9bc8bd95be68c..bee92813aa1f0 100644 --- a/x-pack/legacy/plugins/uptime/public/state/effects/dynamic_settings.ts +++ b/x-pack/legacy/plugins/uptime/public/state/effects/dynamic_settings.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { takeLatest, put, call, select } from 'redux-saga/effects'; +import { takeLatest, put, call } from 'redux-saga/effects'; import { Action } from 'redux-actions'; import { i18n } from '@kbn/i18n'; import { fetchEffectFactory } from './fetch_effect'; @@ -21,7 +21,6 @@ import { setDynamicSettings as setDynamicSettingsAPI, } from '../api'; import { DynamicSettings } from '../../../common/runtime_types'; -import { getBasePath } from '../selectors'; import { kibanaService } from '../kibana_service'; export function* fetchDynamicSettingsEffect() { @@ -46,8 +45,7 @@ export function* setDynamicSettingsEffect() { }); return; } - const basePath = yield select(getBasePath); - yield call(setDynamicSettingsAPI, { settings: action.payload, basePath }); + yield call(setDynamicSettingsAPI, { settings: action.payload }); yield put(setDynamicSettingsSuccess(action.payload)); kibanaService.core.notifications.toasts.addSuccess('Settings saved!'); } catch (err) { diff --git a/x-pack/legacy/plugins/uptime/public/state/effects/index.ts b/x-pack/legacy/plugins/uptime/public/state/effects/index.ts index 8df11312b6455..739179c5bbeae 100644 --- a/x-pack/legacy/plugins/uptime/public/state/effects/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/effects/index.ts @@ -8,6 +8,7 @@ import { fork } from 'redux-saga/effects'; import { fetchMonitorDetailsEffect } from './monitor'; import { fetchOverviewFiltersEffect } from './overview_filters'; import { fetchSnapshotCountEffect } from './snapshot'; +import { fetchMonitorListEffect } from './monitor_list'; import { fetchMonitorStatusEffect } from './monitor_status'; import { fetchDynamicSettingsEffect, setDynamicSettingsEffect } from './dynamic_settings'; import { fetchIndexPatternEffect } from './index_pattern'; @@ -20,6 +21,7 @@ export function* rootEffect() { yield fork(fetchMonitorDetailsEffect); yield fork(fetchSnapshotCountEffect); yield fork(fetchOverviewFiltersEffect); + yield fork(fetchMonitorListEffect); yield fork(fetchMonitorStatusEffect); yield fork(fetchDynamicSettingsEffect); yield fork(setDynamicSettingsEffect); diff --git a/x-pack/legacy/plugins/uptime/public/state/effects/monitor_list.ts b/x-pack/legacy/plugins/uptime/public/state/effects/monitor_list.ts new file mode 100644 index 0000000000000..b607641ecd7d0 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/effects/monitor_list.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; + * you may not use this file except in compliance with the Elastic License. + */ + +import { takeLatest } from 'redux-saga/effects'; +import { getMonitorList, getMonitorListSuccess, getMonitorListFailure } from '../actions'; +import { fetchMonitorList } from '../api'; +import { fetchEffectFactory } from './fetch_effect'; + +export function* fetchMonitorListEffect() { + yield takeLatest( + getMonitorList, + fetchEffectFactory(fetchMonitorList, getMonitorListSuccess, getMonitorListFailure) + ); +} diff --git a/x-pack/legacy/plugins/uptime/public/state/reducers/index.ts b/x-pack/legacy/plugins/uptime/public/state/reducers/index.ts index 0a3ff35df0599..294bde2f277ec 100644 --- a/x-pack/legacy/plugins/uptime/public/state/reducers/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/reducers/index.ts @@ -10,6 +10,7 @@ import { overviewFiltersReducer } from './overview_filters'; import { snapshotReducer } from './snapshot'; import { uiReducer } from './ui'; import { monitorStatusReducer } from './monitor_status'; +import { monitorListReducer } from './monitor_list'; import { dynamicSettingsReducer } from './dynamic_settings'; import { indexPatternReducer } from './index_pattern'; import { pingReducer } from './ping'; @@ -23,6 +24,7 @@ export const rootReducer = combineReducers({ overviewFilters: overviewFiltersReducer, snapshot: snapshotReducer, ui: uiReducer, + monitorList: monitorListReducer, monitorStatus: monitorStatusReducer, dynamicSettings: dynamicSettingsReducer, indexPattern: indexPatternReducer, diff --git a/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_duration.ts b/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_duration.ts index 0e1771c393e50..ec6b374c1057c 100644 --- a/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_duration.ts +++ b/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_duration.ts @@ -24,9 +24,9 @@ const initialState: MonitorDuration = { errors: [], }; -type PayLoad = MonitorDurationResult & Error; +type Payload = MonitorDurationResult & Error; -export const monitorDurationReducer = handleActions( +export const monitorDurationReducer = handleActions( { [String(getMonitorDurationAction)]: (state: MonitorDuration) => ({ ...state, diff --git a/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_list.ts b/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_list.ts new file mode 100644 index 0000000000000..cf895aebeb755 --- /dev/null +++ b/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_list.ts @@ -0,0 +1,51 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { handleActions, Action } from 'redux-actions'; +import { getMonitorList, getMonitorListSuccess, getMonitorListFailure } from '../actions'; +import { MonitorSummaryResult } from '../../../common/runtime_types'; + +export interface MonitorList { + list: MonitorSummaryResult; + error?: Error; + loading: boolean; +} + +export const initialState: MonitorList = { + list: { + nextPagePagination: null, + prevPagePagination: null, + summaries: [], + totalSummaryCount: 0, + }, + loading: false, +}; + +type Payload = MonitorSummaryResult & Error; + +export const monitorListReducer = handleActions( + { + [String(getMonitorList)]: (state: MonitorList) => ({ + ...state, + loading: true, + }), + [String(getMonitorListSuccess)]: ( + state: MonitorList, + action: Action + ) => ({ + ...state, + loading: false, + error: undefined, + list: { ...action.payload }, + }), + [String(getMonitorListFailure)]: (state: MonitorList, action: Action) => ({ + ...state, + error: action.payload, + loading: false, + }), + }, + initialState +); diff --git a/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_status.ts b/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_status.ts index fa3e377b5ebf4..a98e89a27a711 100644 --- a/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_status.ts +++ b/x-pack/legacy/plugins/uptime/public/state/reducers/monitor_status.ts @@ -26,7 +26,7 @@ type MonitorStatusPayload = QueryParams & Ping; export const monitorStatusReducer = handleActions( { - [String(getMonitorStatusAction)]: (state, action: Action) => ({ + [String(getMonitorStatusAction)]: state => ({ ...state, loading: true, }), @@ -43,7 +43,7 @@ export const monitorStatusReducer = handleActions) => ({ + [String(getMonitorStatusActionFail)]: state => ({ ...state, loading: false, }), diff --git a/x-pack/legacy/plugins/uptime/public/state/reducers/ui.ts b/x-pack/legacy/plugins/uptime/public/state/reducers/ui.ts index 702d314250521..c533f293fc940 100644 --- a/x-pack/legacy/plugins/uptime/public/state/reducers/ui.ts +++ b/x-pack/legacy/plugins/uptime/public/state/reducers/ui.ts @@ -13,7 +13,7 @@ import { triggerAppRefresh, UiPayload, setAlertFlyoutVisible, -} from '../actions/ui'; +} from '../actions'; export interface UiState { alertFlyoutVisible: boolean; diff --git a/x-pack/legacy/plugins/uptime/public/state/selectors/__tests__/index.test.ts b/x-pack/legacy/plugins/uptime/public/state/selectors/__tests__/index.test.ts index 77902f347f6f9..2b7c04178e9b4 100644 --- a/x-pack/legacy/plugins/uptime/public/state/selectors/__tests__/index.test.ts +++ b/x-pack/legacy/plugins/uptime/public/state/selectors/__tests__/index.test.ts @@ -71,6 +71,15 @@ describe('state selectors', () => { loading: false, errors: [], }, + monitorList: { + list: { + prevPagePagination: null, + nextPagePagination: null, + summaries: [], + totalSummaryCount: 0, + }, + loading: false, + }, ml: { mlJob: { data: null, diff --git a/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts b/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts index 37695e4274306..7260c61f44147 100644 --- a/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts +++ b/x-pack/legacy/plugins/uptime/public/state/selectors/index.ts @@ -46,6 +46,16 @@ export const selectPingList = ({ pingList, ui: { lastRefresh } }: AppState) => ( lastRefresh, }); +export const snapshotDataSelector = ({ + snapshot: { count, loading }, + ui: { lastRefresh, esKuery }, +}: AppState) => ({ + count, + lastRefresh, + loading, + esKuery, +}); + const mlCapabilitiesSelector = (state: AppState) => state.ml.mlCapabilities.data; export const hasMLFeatureAvailable = createSelector( @@ -92,3 +102,8 @@ export const selectMonitorStatusAlert = ({ indexPattern, overviewFilters, ui }: export const indexStatusSelector = ({ indexStatus }: AppState) => { return indexStatus.indexStatus; }; + +export const monitorListSelector = ({ monitorList, ui: { lastRefresh } }: AppState) => ({ + monitorList, + lastRefresh, +}); diff --git a/x-pack/legacy/plugins/uptime/public/uptime_app.tsx b/x-pack/legacy/plugins/uptime/public/uptime_app.tsx index dafb20dc9c323..92775a2663863 100644 --- a/x-pack/legacy/plugins/uptime/public/uptime_app.tsx +++ b/x-pack/legacy/plugins/uptime/public/uptime_app.tsx @@ -7,24 +7,25 @@ import { EuiPage, EuiErrorBoundary } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useEffect } from 'react'; -import { ApolloProvider } from 'react-apollo'; import { Provider as ReduxProvider } from 'react-redux'; import { BrowserRouter as Router } from 'react-router-dom'; import { I18nStart, ChromeBreadcrumb, CoreStart } from 'src/core/public'; import { PluginsSetup } from 'ui/new_platform/new_platform'; import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; -import { UMGraphQLClient, UMUpdateBadge } from './lib/lib'; +import { UMUpdateBadge } from './lib/lib'; import { UptimeRefreshContextProvider, UptimeSettingsContextProvider, UptimeThemeContextProvider, } from './contexts'; -import { CommonlyUsedRange } from './components/functional/uptime_date_picker'; +import { CommonlyUsedRange } from './components/common/uptime_date_picker'; import { store } from './state'; import { setBasePath } from './state/actions'; import { PageRouter } from './routes'; -import { UptimeAlertsFlyoutWrapper } from './components/connected'; -import { UptimeAlertsContextProvider } from './components/functional/alerts'; +import { + UptimeAlertsContextProvider, + UptimeAlertsFlyoutWrapper, +} from './components/overview/alerts'; import { kibanaService } from './state/kibana_service'; export interface UptimeAppColors { @@ -39,7 +40,6 @@ export interface UptimeAppColors { export interface UptimeAppProps { basePath: string; canSave: boolean; - client: UMGraphQLClient; core: CoreStart; darkMode: boolean; i18n: I18nStart; @@ -59,7 +59,6 @@ const Application = (props: UptimeAppProps) => { const { basePath, canSave, - client, core, darkMode, i18n: i18nCore, @@ -97,25 +96,23 @@ const Application = (props: UptimeAppProps) => { - - - - - - -
- - -
-
-
-
-
-
-
+ + + + + +
+ + +
+
+
+
+
+
diff --git a/x-pack/legacy/plugins/uptime/scripts/gql_gen.json b/x-pack/legacy/plugins/uptime/scripts/gql_gen.json deleted file mode 100644 index 87b8233dd1eeb..0000000000000 --- a/x-pack/legacy/plugins/uptime/scripts/gql_gen.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "flattenTypes": true, - "generatorConfig": {}, - "primitives": { - "String": "string", - "Int": "number", - "Float": "number", - "Boolean": "boolean", - "ID": "string" - } -} diff --git a/x-pack/legacy/plugins/uptime/scripts/infer_graphql_types.js b/x-pack/legacy/plugins/uptime/scripts/infer_graphql_types.js deleted file mode 100644 index 2499e15bf4e23..0000000000000 --- a/x-pack/legacy/plugins/uptime/scripts/infer_graphql_types.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -require('../../../../../src/setup_node_env'); - -const { resolve } = require('path'); -// eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved -const { generate } = require('graphql-code-generator'); - -const CONFIG_PATH = resolve(__dirname, 'gql_gen.json'); -const OUTPUT_INTROSPECTION_PATH = resolve('common', 'graphql', 'introspection.json'); -const OUTPUT_TYPES_PATH = resolve('common', 'graphql', 'types.ts'); -const SCHEMA_PATH = resolve(__dirname, 'graphql_schemas.ts'); - -async function main() { - await generate( - { - args: [], - config: CONFIG_PATH, - out: OUTPUT_INTROSPECTION_PATH, - overwrite: true, - schema: SCHEMA_PATH, - template: 'graphql-codegen-introspection-template', - }, - true - ); - await generate( - { - args: [], - config: CONFIG_PATH, - out: OUTPUT_TYPES_PATH, - overwrite: true, - schema: SCHEMA_PATH, - template: 'graphql-codegen-typescript-template', - }, - true - ); -} - -if (require.main === module) { - main(); -} diff --git a/x-pack/package.json b/x-pack/package.json index b2ec4c3dc3f6f..3c6146b491f60 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -85,7 +85,7 @@ "@types/node-fetch": "^2.5.0", "@types/nodemailer": "^6.2.1", "@types/object-hash": "^1.3.0", - "@types/papaparse": "^4.5.11", + "@types/papaparse": "^5.0.3", "@types/pngjs": "^3.3.2", "@types/prop-types": "^15.5.3", "@types/proper-lockfile": "^3.0.1", @@ -179,7 +179,7 @@ "@babel/core": "^7.9.0", "@babel/register": "^7.9.0", "@babel/runtime": "^7.9.2", - "@elastic/apm-rum-react": "^0.3.2", + "@elastic/apm-rum-react": "^1.1.1", "@elastic/datemath": "5.0.3", "@elastic/ems-client": "7.8.0", "@elastic/eui": "21.0.1", @@ -290,7 +290,7 @@ "oboe": "^2.1.4", "oppsy": "^2.0.0", "p-retry": "^4.2.0", - "papaparse": "^4.6.3", + "papaparse": "^5.2.0", "pdfmake": "^0.1.63", "pluralize": "3.1.0", "pngjs": "3.4.0", diff --git a/x-pack/plugins/actions/server/builtin_action_types/pagerduty.test.ts b/x-pack/plugins/actions/server/builtin_action_types/pagerduty.test.ts index 514c9759d7b56..e5521558bc2da 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/pagerduty.test.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/pagerduty.test.ts @@ -142,6 +142,25 @@ describe('validateParams()', () => { - [eventAction.2]: expected value to equal [acknowledge]" `); }); + + test('should validate and throw error when timestamp has spaces', () => { + const randoDate = new Date('1963-09-23T01:23:45Z').toISOString(); + const timestamp = ` ${randoDate}`; + expect(() => { + validateParams(actionType, { + timestamp, + }); + }).toThrowError(`error validating action params: error parsing timestamp "${timestamp}"`); + }); + + test('should validate and throw error when timestamp is invalid', () => { + const timestamp = `1963-09-55 90:23:45`; + expect(() => { + validateParams(actionType, { + timestamp, + }); + }).toThrowError(`error validating action params: error parsing timestamp "${timestamp}"`); + }); }); describe('execute()', () => { diff --git a/x-pack/plugins/actions/server/builtin_action_types/pagerduty.ts b/x-pack/plugins/actions/server/builtin_action_types/pagerduty.ts index 2b607d0dd41ba..f4d69a4a39e40 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/pagerduty.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/pagerduty.ts @@ -70,18 +70,26 @@ const ParamsSchema = schema.object( function validateParams(paramsObject: any): string | void { const params: ActionParamsType = paramsObject; - const { timestamp } = params; if (timestamp != null) { - let date; try { - date = Date.parse(timestamp); + const date = Date.parse(timestamp); + if (isNaN(date)) { + return i18n.translate('xpack.actions.builtin.pagerduty.invalidTimestampErrorMessage', { + defaultMessage: `error parsing timestamp "{timestamp}"`, + values: { + timestamp, + }, + }); + } } catch (err) { - return 'error parsing timestamp: ${err.message}'; - } - - if (isNaN(date)) { - return 'error parsing timestamp'; + return i18n.translate('xpack.actions.builtin.pagerduty.timestampParsingFailedErrorMessage', { + defaultMessage: `error parsing timestamp "{timestamp}": {message}`, + values: { + timestamp, + message: err.message, + }, + }); } } } diff --git a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts b/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts index 1acb6c563801c..cc07a0b90330d 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/servicenow/lib/index.ts @@ -147,7 +147,14 @@ class ServiceNow { comments: Comment[], field: string ): Promise { - const res = await Promise.all(comments.map(c => this.createComment(incidentId, c, field))); + // Create comments sequentially. + const promises = comments.reduce(async (prevPromise, currentComment) => { + const totalComments = await prevPromise; + const res = await this.createComment(incidentId, currentComment, field); + return [...totalComments, res]; + }, Promise.resolve([] as CommentResponse[])); + + const res = await promises; return res; } diff --git a/x-pack/plugins/apm/common/ml_job_constants.test.ts b/x-pack/plugins/apm/common/ml_job_constants.test.ts index cea66f31303be..2aa50a305f7c8 100644 --- a/x-pack/plugins/apm/common/ml_job_constants.test.ts +++ b/x-pack/plugins/apm/common/ml_job_constants.test.ts @@ -21,6 +21,12 @@ describe('ml_job_constants', () => { expect(getMlJobId('myServiceName', 'myTransactionType')).toBe( 'myservicename-mytransactiontype-high_mean_response_time' ); + expect(getMlJobId('my service name')).toBe( + 'my_service_name-high_mean_response_time' + ); + expect(getMlJobId('my service name', 'my transaction type')).toBe( + 'my_service_name-my_transaction_type-high_mean_response_time' + ); }); it('getMlIndex', () => { diff --git a/x-pack/plugins/apm/common/ml_job_constants.ts b/x-pack/plugins/apm/common/ml_job_constants.ts index 37487d09e4f4c..01f5762e2dc4b 100644 --- a/x-pack/plugins/apm/common/ml_job_constants.ts +++ b/x-pack/plugins/apm/common/ml_job_constants.ts @@ -6,7 +6,7 @@ export function getMlPrefix(serviceName: string, transactionType?: string) { const maybeTransactionType = transactionType ? `${transactionType}-` : ''; - return `${serviceName}-${maybeTransactionType}`.toLowerCase(); + return encodeForMlApi(`${serviceName}-${maybeTransactionType}`); } export function getMlJobId(serviceName: string, transactionType?: string) { @@ -16,3 +16,7 @@ export function getMlJobId(serviceName: string, transactionType?: string) { export function getMlIndex(serviceName: string, transactionType?: string) { return `.ml-anomalies-${getMlJobId(serviceName, transactionType)}`; } + +export function encodeForMlApi(value: string) { + return value.replace(/\s+/g, '_').toLowerCase(); +} diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts index a78b2b93a250d..3eb61bb130725 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts @@ -87,7 +87,8 @@ export async function createApmTelemetry({ return { run: async () => { await collectAndStore(); - } + }, + cancel: async () => {} }; } } diff --git a/x-pack/plugins/apm/typings/es_schemas/raw/span_raw.ts b/x-pack/plugins/apm/typings/es_schemas/raw/span_raw.ts index 4d5d2c5c4a12e..e98b2f52089b3 100644 --- a/x-pack/plugins/apm/typings/es_schemas/raw/span_raw.ts +++ b/x-pack/plugins/apm/typings/es_schemas/raw/span_raw.ts @@ -52,4 +52,5 @@ export interface SpanRaw extends APMBaseDoc { id: string; }; observer?: Observer; + child_ids?: string[]; } diff --git a/x-pack/plugins/canvas/server/saved_objects/custom_element.ts b/x-pack/plugins/canvas/server/saved_objects/custom_element.ts index dadead0263be1..14223455cbc21 100644 --- a/x-pack/plugins/canvas/server/saved_objects/custom_element.ts +++ b/x-pack/plugins/canvas/server/saved_objects/custom_element.ts @@ -10,7 +10,7 @@ import { CUSTOM_ELEMENT_TYPE } from '../../../../legacy/plugins/canvas/common/li export const customElementType: SavedObjectsType = { name: CUSTOM_ELEMENT_TYPE, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { dynamic: false, properties: { diff --git a/x-pack/plugins/canvas/server/saved_objects/workpad.ts b/x-pack/plugins/canvas/server/saved_objects/workpad.ts index e83ba9720b43a..918f4bf991076 100644 --- a/x-pack/plugins/canvas/server/saved_objects/workpad.ts +++ b/x-pack/plugins/canvas/server/saved_objects/workpad.ts @@ -11,7 +11,7 @@ import { removeAttributesId } from './migrations/remove_attributes_id'; export const workpadType: SavedObjectsType = { name: CANVAS_TYPE, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { dynamic: false, properties: { diff --git a/x-pack/plugins/case/common/api/helpers.ts b/x-pack/plugins/case/common/api/helpers.ts new file mode 100644 index 0000000000000..0efdcd3819659 --- /dev/null +++ b/x-pack/plugins/case/common/api/helpers.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { + CASE_DETAILS_URL, + CASE_COMMENTS_URL, + CASE_USER_ACTIONS_URL, + CASE_COMMENT_DETAILS_URL, +} from '../constants'; + +export const getCaseDetailsUrl = (id: string): string => { + return CASE_DETAILS_URL.replace('{case_id}', id); +}; + +export const getCaseCommentsUrl = (id: string): string => { + return CASE_COMMENTS_URL.replace('{case_id}', id); +}; + +export const getCaseCommentDetailsUrl = (caseId: string, commentId: string): string => { + return CASE_COMMENT_DETAILS_URL.replace('{case_id}', caseId).replace('{comment_id}', commentId); +}; + +export const getCaseUserActionUrl = (id: string): string => { + return CASE_USER_ACTIONS_URL.replace('{case_id}', id); +}; diff --git a/x-pack/plugins/case/common/constants.ts b/x-pack/plugins/case/common/constants.ts new file mode 100644 index 0000000000000..dcfa46bfa6019 --- /dev/null +++ b/x-pack/plugins/case/common/constants.ts @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const APP_ID = 'case'; + +/** + * Case routes + */ + +export const CASES_URL = '/api/cases'; +export const CASE_DETAILS_URL = `${CASES_URL}/{case_id}`; +export const CASE_CONFIGURE_URL = `${CASES_URL}/configure`; +export const CASE_CONFIGURE_CONNECTORS_URL = `${CASE_CONFIGURE_URL}/connectors`; +export const CASE_COMMENTS_URL = `${CASE_DETAILS_URL}/comments`; +export const CASE_COMMENT_DETAILS_URL = `${CASE_DETAILS_URL}/comments/{comment_id}`; +export const CASE_REPORTERS_URL = `${CASES_URL}/reporters`; +export const CASE_STATUS_URL = `${CASES_URL}/status`; +export const CASE_TAGS_URL = `${CASES_URL}/tags`; +export const CASE_USER_ACTIONS_URL = `${CASE_DETAILS_URL}/user_actions`; + +/** + * Action routes + */ + +export const ACTION_URL = '/api/action'; +export const ACTION_TYPES_URL = '/api/action/types'; diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/delete_all_comments.ts b/x-pack/plugins/case/server/routes/api/cases/comments/delete_all_comments.ts index 1dfab165eccd7..e9bcb9690ebd8 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/delete_all_comments.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/delete_all_comments.ts @@ -9,11 +9,12 @@ import { schema } from '@kbn/config-schema'; import { buildCommentUserActionItem } from '../../../../services/user_actions/helpers'; import { RouteDeps } from '../../types'; import { wrapError } from '../../utils'; +import { CASE_COMMENTS_URL } from '../../../../../common/constants'; export function initDeleteAllCommentsApi({ caseService, router, userActionService }: RouteDeps) { router.delete( { - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, validate: { params: schema.object({ case_id: schema.string(), diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/delete_comment.test.ts b/x-pack/plugins/case/server/routes/api/cases/comments/delete_comment.test.ts index b2022e6dec26d..67cb998409570 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/delete_comment.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/delete_comment.test.ts @@ -15,6 +15,7 @@ import { mockCaseComments, } from '../../__fixtures__'; import { initDeleteCommentApi } from './delete_comment'; +import { CASE_COMMENT_DETAILS_URL } from '../../../../../common/constants'; describe('DELETE comment', () => { let routeHandler: RequestHandler; @@ -23,7 +24,7 @@ describe('DELETE comment', () => { }); it(`deletes the comment. responds with 204`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments/{comment_id}', + path: CASE_COMMENT_DETAILS_URL, method: 'delete', params: { case_id: 'mock-id-1', @@ -43,7 +44,7 @@ describe('DELETE comment', () => { }); it(`returns an error when thrown from deleteComment service`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments/{comment_id}', + path: CASE_COMMENT_DETAILS_URL, method: 'delete', params: { case_id: 'mock-id-1', diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/delete_comment.ts b/x-pack/plugins/case/server/routes/api/cases/comments/delete_comment.ts index ff0729afed96a..72ef400415d0f 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/delete_comment.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/delete_comment.ts @@ -11,11 +11,12 @@ import { CASE_SAVED_OBJECT } from '../../../../saved_object_types'; import { buildCommentUserActionItem } from '../../../../services/user_actions/helpers'; import { RouteDeps } from '../../types'; import { wrapError } from '../../utils'; +import { CASE_COMMENT_DETAILS_URL } from '../../../../../common/constants'; export function initDeleteCommentApi({ caseService, router, userActionService }: RouteDeps) { router.delete( { - path: '/api/cases/{case_id}/comments/{comment_id}', + path: CASE_COMMENT_DETAILS_URL, validate: { params: schema.object({ case_id: schema.string(), diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/find_comments.ts b/x-pack/plugins/case/server/routes/api/cases/comments/find_comments.ts index 92da64cebee74..3df9fdb80ba8a 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/find_comments.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/find_comments.ts @@ -18,11 +18,12 @@ import { } from '../../../../../common/api'; import { RouteDeps } from '../../types'; import { escapeHatch, transformComments, wrapError } from '../../utils'; +import { CASE_COMMENTS_URL } from '../../../../../common/constants'; export function initFindCaseCommentsApi({ caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/{case_id}/comments/_find', + path: `${CASE_COMMENTS_URL}/_find`, validate: { params: schema.object({ case_id: schema.string(), diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/get_all_comment.ts b/x-pack/plugins/case/server/routes/api/cases/comments/get_all_comment.ts index 1500039eb2cc2..8d7820d4e8fec 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/get_all_comment.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/get_all_comment.ts @@ -9,11 +9,12 @@ import { schema } from '@kbn/config-schema'; import { AllCommentsResponseRt } from '../../../../../common/api'; import { RouteDeps } from '../../types'; import { flattenCommentSavedObjects, wrapError } from '../../utils'; +import { CASE_COMMENTS_URL } from '../../../../../common/constants'; export function initGetAllCommentsApi({ caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, validate: { params: schema.object({ case_id: schema.string(), diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/get_comment.test.ts b/x-pack/plugins/case/server/routes/api/cases/comments/get_comment.test.ts index 9c8d0e5254df0..b5a7d6367ea4b 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/get_comment.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/get_comment.test.ts @@ -15,6 +15,7 @@ import { } from '../../__fixtures__'; import { flattenCommentSavedObject } from '../../utils'; import { initGetCommentApi } from './get_comment'; +import { CASE_COMMENT_DETAILS_URL } from '../../../../../common/constants'; describe('GET comment', () => { let routeHandler: RequestHandler; @@ -23,7 +24,7 @@ describe('GET comment', () => { }); it(`returns the comment`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments/{comment_id}', + path: CASE_COMMENT_DETAILS_URL, method: 'get', params: { case_id: 'mock-id-1', @@ -48,7 +49,7 @@ describe('GET comment', () => { }); it(`returns an error when getComment throws`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments/{comment_id}', + path: CASE_COMMENT_DETAILS_URL, method: 'get', params: { case_id: 'mock-id-1', diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/get_comment.ts b/x-pack/plugins/case/server/routes/api/cases/comments/get_comment.ts index 24f44a5f5129b..5fa668f6ae5de 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/get_comment.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/get_comment.ts @@ -9,11 +9,12 @@ import { schema } from '@kbn/config-schema'; import { CommentResponseRt } from '../../../../../common/api'; import { RouteDeps } from '../../types'; import { flattenCommentSavedObject, wrapError } from '../../utils'; +import { CASE_COMMENT_DETAILS_URL } from '../../../../../common/constants'; export function initGetCommentApi({ caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/{case_id}/comments/{comment_id}', + path: CASE_COMMENT_DETAILS_URL, validate: { params: schema.object({ case_id: schema.string(), diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/patch_comment.test.ts b/x-pack/plugins/case/server/routes/api/cases/comments/patch_comment.test.ts index 8d9906c2abe7f..04473e302e468 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/patch_comment.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/patch_comment.test.ts @@ -14,6 +14,7 @@ import { mockCases, } from '../../__fixtures__'; import { initPatchCommentApi } from './patch_comment'; +import { CASE_COMMENTS_URL } from '../../../../../common/constants'; describe('PATCH comment', () => { let routeHandler: RequestHandler; @@ -22,7 +23,7 @@ describe('PATCH comment', () => { }); it(`Patch a comment`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, method: 'patch', params: { case_id: 'mock-id-1', @@ -50,7 +51,7 @@ describe('PATCH comment', () => { it(`Fails with 409 if version does not match`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, method: 'patch', params: { case_id: 'mock-id-1', @@ -74,7 +75,7 @@ describe('PATCH comment', () => { }); it(`Returns an error if updateComment throws`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, method: 'patch', params: { case_id: 'mock-id-1', diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/patch_comment.ts b/x-pack/plugins/case/server/routes/api/cases/comments/patch_comment.ts index 3b38afc02ed81..dd9b124ff1b79 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/patch_comment.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/patch_comment.ts @@ -15,11 +15,12 @@ import { CASE_SAVED_OBJECT } from '../../../../saved_object_types'; import { buildCommentUserActionItem } from '../../../../services/user_actions/helpers'; import { RouteDeps } from '../../types'; import { escapeHatch, wrapError, flattenCaseSavedObject } from '../../utils'; +import { CASE_COMMENTS_URL } from '../../../../../common/constants'; export function initPatchCommentApi({ caseService, router, userActionService }: RouteDeps) { router.patch( { - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, validate: { params: schema.object({ case_id: schema.string(), diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/post_comment.test.ts b/x-pack/plugins/case/server/routes/api/cases/comments/post_comment.test.ts index 23039da681ec6..9006470f36f36 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/post_comment.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/post_comment.test.ts @@ -15,6 +15,7 @@ import { mockCaseComments, } from '../../__fixtures__'; import { initPostCommentApi } from './post_comment'; +import { CASE_COMMENTS_URL } from '../../../../../common/constants'; describe('POST comment', () => { let routeHandler: RequestHandler; @@ -27,7 +28,7 @@ describe('POST comment', () => { }); it(`Posts a new comment`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, method: 'post', params: { case_id: 'mock-id-1', @@ -52,7 +53,7 @@ describe('POST comment', () => { }); it(`Returns an error if the case does not exist`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, method: 'post', params: { case_id: 'this-is-not-real', @@ -75,7 +76,7 @@ describe('POST comment', () => { }); it(`Returns an error if postNewCase throws`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, method: 'post', params: { case_id: 'mock-id-1', @@ -100,7 +101,7 @@ describe('POST comment', () => { routeHandler = await createRoute(initPostCommentApi, 'post', true); const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, method: 'post', params: { case_id: 'mock-id-1', diff --git a/x-pack/plugins/case/server/routes/api/cases/comments/post_comment.ts b/x-pack/plugins/case/server/routes/api/cases/comments/post_comment.ts index 70405af26f576..a296d9815f251 100644 --- a/x-pack/plugins/case/server/routes/api/cases/comments/post_comment.ts +++ b/x-pack/plugins/case/server/routes/api/cases/comments/post_comment.ts @@ -15,11 +15,12 @@ import { CASE_SAVED_OBJECT } from '../../../../saved_object_types'; import { buildCommentUserActionItem } from '../../../../services/user_actions/helpers'; import { escapeHatch, transformNewComment, wrapError, flattenCaseSavedObject } from '../../utils'; import { RouteDeps } from '../../types'; +import { CASE_COMMENTS_URL } from '../../../../../common/constants'; export function initPostCommentApi({ caseService, router, userActionService }: RouteDeps) { router.post( { - path: '/api/cases/{case_id}/comments', + path: CASE_COMMENTS_URL, validate: { params: schema.object({ case_id: schema.string(), diff --git a/x-pack/plugins/case/server/routes/api/cases/configure/get_configure.test.ts b/x-pack/plugins/case/server/routes/api/cases/configure/get_configure.test.ts index 66d39c3f11d28..5b3b6e77b9403 100644 --- a/x-pack/plugins/case/server/routes/api/cases/configure/get_configure.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/configure/get_configure.test.ts @@ -15,6 +15,7 @@ import { import { mockCaseConfigure } from '../../__fixtures__/mock_saved_objects'; import { initGetCaseConfigure } from './get_configure'; +import { CASE_CONFIGURE_URL } from '../../../../../common/constants'; describe('GET configuration', () => { let routeHandler: RequestHandler; @@ -24,7 +25,7 @@ describe('GET configuration', () => { it('returns the configuration', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'get', }); @@ -44,7 +45,7 @@ describe('GET configuration', () => { it('handles undefined version correctly', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'get', }); @@ -78,7 +79,7 @@ describe('GET configuration', () => { it('returns an empty object when there is no configuration', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'get', }); @@ -95,7 +96,7 @@ describe('GET configuration', () => { it('returns an error if find throws an error', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'get', }); diff --git a/x-pack/plugins/case/server/routes/api/cases/configure/get_configure.ts b/x-pack/plugins/case/server/routes/api/cases/configure/get_configure.ts index 2832edaa892d5..03bec1fe72d39 100644 --- a/x-pack/plugins/case/server/routes/api/cases/configure/get_configure.ts +++ b/x-pack/plugins/case/server/routes/api/cases/configure/get_configure.ts @@ -7,11 +7,12 @@ import { CaseConfigureResponseRt } from '../../../../../common/api'; import { RouteDeps } from '../../types'; import { wrapError } from '../../utils'; +import { CASE_CONFIGURE_URL } from '../../../../../common/constants'; export function initGetCaseConfigure({ caseConfigureService, caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, validate: false, }, async (context, request, response) => { diff --git a/x-pack/plugins/case/server/routes/api/cases/configure/get_connectors.test.ts b/x-pack/plugins/case/server/routes/api/cases/configure/get_connectors.test.ts index 62edaa0a4792a..09692ff73b94b 100644 --- a/x-pack/plugins/case/server/routes/api/cases/configure/get_connectors.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/configure/get_connectors.test.ts @@ -16,6 +16,7 @@ import { import { mockCaseConfigure } from '../../__fixtures__/mock_saved_objects'; import { initCaseConfigureGetActionConnector } from './get_connectors'; import { getActions } from '../../__mocks__/request_responses'; +import { CASE_CONFIGURE_CONNECTORS_URL } from '../../../../../common/constants'; describe('GET connectors', () => { let routeHandler: RequestHandler; @@ -25,7 +26,7 @@ describe('GET connectors', () => { it('returns the connectors', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure/connectors/_find', + path: `${CASE_CONFIGURE_CONNECTORS_URL}/_find`, method: 'get', }); @@ -44,7 +45,7 @@ describe('GET connectors', () => { it('it throws an error when actions client is null', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure/connectors/_find', + path: `${CASE_CONFIGURE_CONNECTORS_URL}/_find`, method: 'get', }); diff --git a/x-pack/plugins/case/server/routes/api/cases/configure/get_connectors.ts b/x-pack/plugins/case/server/routes/api/cases/configure/get_connectors.ts index 3e9a1c96d55ed..00575655d4c42 100644 --- a/x-pack/plugins/case/server/routes/api/cases/configure/get_connectors.ts +++ b/x-pack/plugins/case/server/routes/api/cases/configure/get_connectors.ts @@ -8,6 +8,8 @@ import Boom from 'boom'; import { RouteDeps } from '../../types'; import { wrapError } from '../../utils'; +import { CASE_CONFIGURE_CONNECTORS_URL } from '../../../../../common/constants'; + /* * Be aware that this api will only return 20 connectors */ @@ -17,7 +19,7 @@ const CASE_SERVICE_NOW_ACTION = '.servicenow'; export function initCaseConfigureGetActionConnector({ caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/configure/connectors/_find', + path: `${CASE_CONFIGURE_CONNECTORS_URL}/_find`, validate: false, }, async (context, request, response) => { diff --git a/x-pack/plugins/case/server/routes/api/cases/configure/patch_configure.test.ts b/x-pack/plugins/case/server/routes/api/cases/configure/patch_configure.test.ts index 5b3d68a258664..9b71f777b95ab 100644 --- a/x-pack/plugins/case/server/routes/api/cases/configure/patch_configure.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/configure/patch_configure.test.ts @@ -15,6 +15,7 @@ import { import { mockCaseConfigure } from '../../__fixtures__/mock_saved_objects'; import { initPatchCaseConfigure } from './patch_configure'; +import { CASE_CONFIGURE_URL } from '../../../../../common/constants'; describe('PATCH configuration', () => { let routeHandler: RequestHandler; @@ -29,7 +30,7 @@ describe('PATCH configuration', () => { it('patch configuration', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'patch', body: { closure_type: 'close-by-pushing', @@ -61,7 +62,7 @@ describe('PATCH configuration', () => { routeHandler = await createRoute(initPatchCaseConfigure, 'patch', true); const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'patch', body: { closure_type: 'close-by-pushing', @@ -91,7 +92,7 @@ describe('PATCH configuration', () => { it('throw error when configuration have not being created', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'patch', body: { closure_type: 'close-by-pushing', @@ -113,7 +114,7 @@ describe('PATCH configuration', () => { it('throw error when the versions are different', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'patch', body: { closure_type: 'close-by-pushing', @@ -135,7 +136,7 @@ describe('PATCH configuration', () => { it('handles undefined version correctly', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'patch', body: { connector_id: 'no-version', version: mockCaseConfigure[0].version }, }); diff --git a/x-pack/plugins/case/server/routes/api/cases/configure/patch_configure.ts b/x-pack/plugins/case/server/routes/api/cases/configure/patch_configure.ts index 3a1b9d5059cbc..47f7d503e32b8 100644 --- a/x-pack/plugins/case/server/routes/api/cases/configure/patch_configure.ts +++ b/x-pack/plugins/case/server/routes/api/cases/configure/patch_configure.ts @@ -16,11 +16,12 @@ import { } from '../../../../../common/api'; import { RouteDeps } from '../../types'; import { wrapError, escapeHatch } from '../../utils'; +import { CASE_CONFIGURE_URL } from '../../../../../common/constants'; export function initPatchCaseConfigure({ caseConfigureService, caseService, router }: RouteDeps) { router.patch( { - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, validate: { body: escapeHatch, }, diff --git a/x-pack/plugins/case/server/routes/api/cases/configure/post_configure.test.ts b/x-pack/plugins/case/server/routes/api/cases/configure/post_configure.test.ts index 7e40cad5b1298..fb95cc53a1710 100644 --- a/x-pack/plugins/case/server/routes/api/cases/configure/post_configure.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/configure/post_configure.test.ts @@ -16,6 +16,7 @@ import { import { mockCaseConfigure } from '../../__fixtures__/mock_saved_objects'; import { initPostCaseConfigure } from './post_configure'; import { newConfiguration } from '../../__mocks__/request_responses'; +import { CASE_CONFIGURE_URL } from '../../../../../common/constants'; describe('POST configuration', () => { let routeHandler: RequestHandler; @@ -30,7 +31,7 @@ describe('POST configuration', () => { it('create configuration', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: newConfiguration, }); @@ -61,7 +62,7 @@ describe('POST configuration', () => { routeHandler = await createRoute(initPostCaseConfigure, 'post', true); const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: newConfiguration, }); @@ -90,7 +91,7 @@ describe('POST configuration', () => { it('throws when missing connector_id', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: { connector_name: 'My connector 2', @@ -111,7 +112,7 @@ describe('POST configuration', () => { it('throws when missing connector_name', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: { connector_id: '456', @@ -132,7 +133,7 @@ describe('POST configuration', () => { it('throws when missing closure_type', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: { connector_id: '456', @@ -153,7 +154,7 @@ describe('POST configuration', () => { it('it deletes the previous configuration', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: newConfiguration, }); @@ -172,7 +173,7 @@ describe('POST configuration', () => { it('it does NOT delete when not found', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: newConfiguration, }); @@ -191,7 +192,7 @@ describe('POST configuration', () => { it('it deletes all configuration', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: newConfiguration, }); @@ -214,7 +215,7 @@ describe('POST configuration', () => { it('returns an error if find throws an error', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: newConfiguration, }); @@ -232,7 +233,7 @@ describe('POST configuration', () => { it('returns an error if delete throws an error', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: newConfiguration, }); @@ -250,7 +251,7 @@ describe('POST configuration', () => { it('returns an error if post throws an error', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: { connector_id: 'throw-error-create', @@ -272,7 +273,7 @@ describe('POST configuration', () => { it('handles undefined version correctly', async () => { const req = httpServerMock.createKibanaRequest({ - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, method: 'post', body: { ...newConfiguration, connector_id: 'no-version' }, }); diff --git a/x-pack/plugins/case/server/routes/api/cases/configure/post_configure.ts b/x-pack/plugins/case/server/routes/api/cases/configure/post_configure.ts index 2a23abf0cbf21..5c1693e728c37 100644 --- a/x-pack/plugins/case/server/routes/api/cases/configure/post_configure.ts +++ b/x-pack/plugins/case/server/routes/api/cases/configure/post_configure.ts @@ -16,11 +16,12 @@ import { } from '../../../../../common/api'; import { RouteDeps } from '../../types'; import { wrapError, escapeHatch } from '../../utils'; +import { CASE_CONFIGURE_URL } from '../../../../../common/constants'; export function initPostCaseConfigure({ caseConfigureService, caseService, router }: RouteDeps) { router.post( { - path: '/api/cases/configure', + path: CASE_CONFIGURE_URL, validate: { body: escapeHatch, }, diff --git a/x-pack/plugins/case/server/routes/api/cases/delete_cases.test.ts b/x-pack/plugins/case/server/routes/api/cases/delete_cases.test.ts index c5be6f78a1570..e655339e05eb1 100644 --- a/x-pack/plugins/case/server/routes/api/cases/delete_cases.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/delete_cases.test.ts @@ -16,6 +16,7 @@ import { mockCaseComments, } from '../__fixtures__'; import { initDeleteCasesApi } from './delete_cases'; +import { CASES_URL } from '../../../../common/constants'; describe('DELETE case', () => { let routeHandler: RequestHandler; @@ -24,7 +25,7 @@ describe('DELETE case', () => { }); it(`deletes the case. responds with 204`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases', + path: CASES_URL, method: 'delete', query: { ids: ['mock-id-1'], @@ -43,7 +44,7 @@ describe('DELETE case', () => { }); it(`returns an error when thrown from deleteCase service`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases', + path: CASES_URL, method: 'delete', query: { ids: ['not-real'], @@ -62,7 +63,7 @@ describe('DELETE case', () => { }); it(`returns an error when thrown from getAllCaseComments service`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases', + path: CASES_URL, method: 'delete', query: { ids: ['bad-guy'], @@ -81,7 +82,7 @@ describe('DELETE case', () => { }); it(`returns an error when thrown from deleteComment service`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases', + path: CASES_URL, method: 'delete', query: { ids: ['valid-id'], diff --git a/x-pack/plugins/case/server/routes/api/cases/delete_cases.ts b/x-pack/plugins/case/server/routes/api/cases/delete_cases.ts index 0214017ae5c29..20591637a6c23 100644 --- a/x-pack/plugins/case/server/routes/api/cases/delete_cases.ts +++ b/x-pack/plugins/case/server/routes/api/cases/delete_cases.ts @@ -9,11 +9,12 @@ import { schema } from '@kbn/config-schema'; import { buildCaseUserActionItem } from '../../../services/user_actions/helpers'; import { RouteDeps } from '../types'; import { wrapError } from '../utils'; +import { CASES_URL } from '../../../../common/constants'; export function initDeleteCasesApi({ caseService, router, userActionService }: RouteDeps) { router.delete( { - path: '/api/cases', + path: CASES_URL, validate: { query: schema.object({ ids: schema.arrayOf(schema.string()), diff --git a/x-pack/plugins/case/server/routes/api/cases/find_cases.test.ts b/x-pack/plugins/case/server/routes/api/cases/find_cases.test.ts index 8fafb1af0eb82..7af1cee494457 100644 --- a/x-pack/plugins/case/server/routes/api/cases/find_cases.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/find_cases.test.ts @@ -14,6 +14,7 @@ import { mockCases, } from '../__fixtures__'; import { initFindCasesApi } from './find_cases'; +import { CASES_URL } from '../../../../common/constants'; describe('GET all cases', () => { let routeHandler: RequestHandler; @@ -22,7 +23,7 @@ describe('GET all cases', () => { }); it(`gets all the cases`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases', + path: `${CASES_URL}/_find`, method: 'get', }); diff --git a/x-pack/plugins/case/server/routes/api/cases/find_cases.ts b/x-pack/plugins/case/server/routes/api/cases/find_cases.ts index b2716749e9749..40fc0301b058a 100644 --- a/x-pack/plugins/case/server/routes/api/cases/find_cases.ts +++ b/x-pack/plugins/case/server/routes/api/cases/find_cases.ts @@ -15,6 +15,7 @@ import { CasesFindResponseRt, CasesFindRequestRt, throwErrors } from '../../../. import { transformCases, sortToSnake, wrapError, escapeHatch } from '../utils'; import { RouteDeps, TotalCommentByCase } from '../types'; import { CASE_SAVED_OBJECT } from '../../../saved_object_types'; +import { CASES_URL } from '../../../../common/constants'; const combineFilters = (filters: string[], operator: 'OR' | 'AND'): string => filters?.filter(i => i !== '').join(` ${operator} `); @@ -41,7 +42,7 @@ const buildFilter = ( export function initFindCasesApi({ caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/_find', + path: `${CASES_URL}/_find`, validate: { query: escapeHatch, }, diff --git a/x-pack/plugins/case/server/routes/api/cases/get_case.test.ts b/x-pack/plugins/case/server/routes/api/cases/get_case.test.ts index 5912df2c40aa3..a8c12d4734b53 100644 --- a/x-pack/plugins/case/server/routes/api/cases/get_case.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/get_case.test.ts @@ -18,6 +18,7 @@ import { } from '../__fixtures__'; import { flattenCaseSavedObject } from '../utils'; import { initGetCaseApi } from './get_case'; +import { CASE_DETAILS_URL } from '../../../../common/constants'; describe('GET case', () => { let routeHandler: RequestHandler; @@ -26,7 +27,7 @@ describe('GET case', () => { }); it(`returns the case with empty case comments when includeComments is false`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}', + path: CASE_DETAILS_URL, method: 'get', params: { case_id: 'mock-id-1', @@ -55,7 +56,7 @@ describe('GET case', () => { }); it(`returns an error when thrown from getCase`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}', + path: CASE_DETAILS_URL, method: 'get', params: { case_id: 'abcdefg', @@ -78,7 +79,7 @@ describe('GET case', () => { }); it(`returns the case with case comments when includeComments is true`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}', + path: CASE_DETAILS_URL, method: 'get', params: { case_id: 'mock-id-1', @@ -102,7 +103,7 @@ describe('GET case', () => { }); it(`returns an error when thrown from getAllCaseComments`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases/{case_id}', + path: CASE_DETAILS_URL, method: 'get', params: { case_id: 'bad-guy', diff --git a/x-pack/plugins/case/server/routes/api/cases/get_case.ts b/x-pack/plugins/case/server/routes/api/cases/get_case.ts index e947118a39e8e..1e836d38c285c 100644 --- a/x-pack/plugins/case/server/routes/api/cases/get_case.ts +++ b/x-pack/plugins/case/server/routes/api/cases/get_case.ts @@ -9,11 +9,12 @@ import { schema } from '@kbn/config-schema'; import { CaseResponseRt } from '../../../../common/api'; import { RouteDeps } from '../types'; import { flattenCaseSavedObject, wrapError } from '../utils'; +import { CASE_DETAILS_URL } from '../../../../common/constants'; export function initGetCaseApi({ caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/{case_id}', + path: CASE_DETAILS_URL, validate: { params: schema.object({ case_id: schema.string(), @@ -40,6 +41,10 @@ export function initGetCaseApi({ caseService, router }: RouteDeps) { const theComments = await caseService.getAllCaseComments({ client, caseId: request.params.case_id, + options: { + sortField: 'created_at', + sortOrder: 'asc', + }, }); return response.ok({ diff --git a/x-pack/plugins/case/server/routes/api/cases/patch_cases.ts b/x-pack/plugins/case/server/routes/api/cases/patch_cases.ts index c36ea8964dc80..57f9fc20dbf34 100644 --- a/x-pack/plugins/case/server/routes/api/cases/patch_cases.ts +++ b/x-pack/plugins/case/server/routes/api/cases/patch_cases.ts @@ -20,11 +20,12 @@ import { escapeHatch, wrapError, flattenCaseSavedObject } from '../utils'; import { RouteDeps } from '../types'; import { getCaseToUpdate } from './helpers'; import { buildCaseUserActions } from '../../../services/user_actions/helpers'; +import { CASES_URL } from '../../../../common/constants'; export function initPatchCasesApi({ caseService, router, userActionService }: RouteDeps) { router.patch( { - path: '/api/cases', + path: CASES_URL, validate: { body: escapeHatch, }, diff --git a/x-pack/plugins/case/server/routes/api/cases/post_case.test.ts b/x-pack/plugins/case/server/routes/api/cases/post_case.test.ts index 5899102224774..0bbceb5214046 100644 --- a/x-pack/plugins/case/server/routes/api/cases/post_case.test.ts +++ b/x-pack/plugins/case/server/routes/api/cases/post_case.test.ts @@ -14,6 +14,7 @@ import { mockCases, } from '../__fixtures__'; import { initPostCaseApi } from './post_case'; +import { CASES_URL } from '../../../../common/constants'; describe('POST cases', () => { let routeHandler: RequestHandler; @@ -26,7 +27,7 @@ describe('POST cases', () => { }); it(`Posts a new case`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases', + path: CASES_URL, method: 'post', body: { description: 'This is a brand new case of a bad meanie defacing data', @@ -49,7 +50,7 @@ describe('POST cases', () => { it(`Error if you passing status for a new case`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases', + path: CASES_URL, method: 'post', body: { description: 'This is a brand new case of a bad meanie defacing data', @@ -70,7 +71,7 @@ describe('POST cases', () => { }); it(`Returns an error if postNewCase throws`, async () => { const request = httpServerMock.createKibanaRequest({ - path: '/api/cases', + path: CASES_URL, method: 'post', body: { description: 'Throw an error', @@ -93,7 +94,7 @@ describe('POST cases', () => { routeHandler = await createRoute(initPostCaseApi, 'post', true); const request = httpServerMock.createKibanaRequest({ - path: '/api/cases', + path: CASES_URL, method: 'post', body: { description: 'This is a brand new case of a bad meanie defacing data', diff --git a/x-pack/plugins/case/server/routes/api/cases/post_case.ts b/x-pack/plugins/case/server/routes/api/cases/post_case.ts index 239b8bfdf9b29..059a8b1affd54 100644 --- a/x-pack/plugins/case/server/routes/api/cases/post_case.ts +++ b/x-pack/plugins/case/server/routes/api/cases/post_case.ts @@ -14,11 +14,12 @@ import { flattenCaseSavedObject, transformNewCase, wrapError, escapeHatch } from import { CasePostRequestRt, throwErrors, excess, CaseResponseRt } from '../../../../common/api'; import { buildCaseUserActionItem } from '../../../services/user_actions/helpers'; import { RouteDeps } from '../types'; +import { CASES_URL } from '../../../../common/constants'; export function initPostCaseApi({ caseService, router, userActionService }: RouteDeps) { router.post( { - path: '/api/cases', + path: CASES_URL, validate: { body: escapeHatch, }, diff --git a/x-pack/plugins/case/server/routes/api/cases/push_case.ts b/x-pack/plugins/case/server/routes/api/cases/push_case.ts index aff057adea37f..94ebe24c3d2ae 100644 --- a/x-pack/plugins/case/server/routes/api/cases/push_case.ts +++ b/x-pack/plugins/case/server/routes/api/cases/push_case.ts @@ -15,6 +15,7 @@ import { flattenCaseSavedObject, wrapError, escapeHatch } from '../utils'; import { CaseExternalServiceRequestRt, CaseResponseRt, throwErrors } from '../../../../common/api'; import { buildCaseUserActionItem } from '../../../services/user_actions/helpers'; import { RouteDeps } from '../types'; +import { CASE_DETAILS_URL } from '../../../../common/constants'; export function initPushCaseUserActionApi({ caseConfigureService, @@ -24,7 +25,7 @@ export function initPushCaseUserActionApi({ }: RouteDeps) { router.post( { - path: '/api/cases/{case_id}/_push', + path: `${CASE_DETAILS_URL}/_push`, validate: { params: schema.object({ case_id: schema.string(), diff --git a/x-pack/plugins/case/server/routes/api/cases/reporters/get_reporters.ts b/x-pack/plugins/case/server/routes/api/cases/reporters/get_reporters.ts index 56862a96e0563..3fc96f506d175 100644 --- a/x-pack/plugins/case/server/routes/api/cases/reporters/get_reporters.ts +++ b/x-pack/plugins/case/server/routes/api/cases/reporters/get_reporters.ts @@ -7,11 +7,12 @@ import { UsersRt } from '../../../../../common/api'; import { RouteDeps } from '../../types'; import { wrapError } from '../../utils'; +import { CASE_REPORTERS_URL } from '../../../../../common/constants'; export function initGetReportersApi({ caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/reporters', + path: CASE_REPORTERS_URL, validate: {}, }, async (context, request, response) => { diff --git a/x-pack/plugins/case/server/routes/api/cases/status/get_status.ts b/x-pack/plugins/case/server/routes/api/cases/status/get_status.ts index f7431729d398c..8f86dbc91f315 100644 --- a/x-pack/plugins/case/server/routes/api/cases/status/get_status.ts +++ b/x-pack/plugins/case/server/routes/api/cases/status/get_status.ts @@ -9,11 +9,12 @@ import { wrapError } from '../../utils'; import { CasesStatusResponseRt } from '../../../../../common/api'; import { CASE_SAVED_OBJECT } from '../../../../saved_object_types'; +import { CASE_STATUS_URL } from '../../../../../common/constants'; export function initGetCasesStatusApi({ caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/status', + path: CASE_STATUS_URL, validate: {}, }, async (context, request, response) => { diff --git a/x-pack/plugins/case/server/routes/api/cases/tags/get_tags.ts b/x-pack/plugins/case/server/routes/api/cases/tags/get_tags.ts index 55e8fe2af128c..1a3da659c58c4 100644 --- a/x-pack/plugins/case/server/routes/api/cases/tags/get_tags.ts +++ b/x-pack/plugins/case/server/routes/api/cases/tags/get_tags.ts @@ -6,11 +6,12 @@ import { RouteDeps } from '../../types'; import { wrapError } from '../../utils'; +import { CASE_TAGS_URL } from '../../../../../common/constants'; export function initGetTagsApi({ caseService, router }: RouteDeps) { router.get( { - path: '/api/cases/tags', + path: CASE_TAGS_URL, validate: {}, }, async (context, request, response) => { diff --git a/x-pack/plugins/case/server/routes/api/cases/user_actions/get_all_user_actions.ts b/x-pack/plugins/case/server/routes/api/cases/user_actions/get_all_user_actions.ts index 2d4f16e46d561..c90979f60d23f 100644 --- a/x-pack/plugins/case/server/routes/api/cases/user_actions/get_all_user_actions.ts +++ b/x-pack/plugins/case/server/routes/api/cases/user_actions/get_all_user_actions.ts @@ -10,11 +10,12 @@ import { CaseUserActionsResponseRt } from '../../../../../common/api'; import { CASE_SAVED_OBJECT, CASE_COMMENT_SAVED_OBJECT } from '../../../../saved_object_types'; import { RouteDeps } from '../../types'; import { wrapError } from '../../utils'; +import { CASE_USER_ACTIONS_URL } from '../../../../../common/constants'; export function initGetAllUserActionsApi({ userActionService, router }: RouteDeps) { router.get( { - path: '/api/cases/{case_id}/user_actions', + path: CASE_USER_ACTIONS_URL, validate: { params: schema.object({ case_id: schema.string(), diff --git a/x-pack/plugins/case/server/saved_object_types/cases.ts b/x-pack/plugins/case/server/saved_object_types/cases.ts index a4c5dab0feeb7..cc2b1e74b38c4 100644 --- a/x-pack/plugins/case/server/saved_object_types/cases.ts +++ b/x-pack/plugins/case/server/saved_object_types/cases.ts @@ -11,7 +11,7 @@ export const CASE_SAVED_OBJECT = 'cases'; export const caseSavedObjectType: SavedObjectsType = { name: CASE_SAVED_OBJECT, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { closed_at: { diff --git a/x-pack/plugins/case/server/saved_object_types/comments.ts b/x-pack/plugins/case/server/saved_object_types/comments.ts index 73b1852bafe58..8b69f272d5b0d 100644 --- a/x-pack/plugins/case/server/saved_object_types/comments.ts +++ b/x-pack/plugins/case/server/saved_object_types/comments.ts @@ -11,7 +11,7 @@ export const CASE_COMMENT_SAVED_OBJECT = 'cases-comments'; export const caseCommentSavedObjectType: SavedObjectsType = { name: CASE_COMMENT_SAVED_OBJECT, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { comment: { diff --git a/x-pack/plugins/case/server/saved_object_types/configure.ts b/x-pack/plugins/case/server/saved_object_types/configure.ts index d66c38b6ea8ff..d6bc3c9f2e227 100644 --- a/x-pack/plugins/case/server/saved_object_types/configure.ts +++ b/x-pack/plugins/case/server/saved_object_types/configure.ts @@ -11,7 +11,7 @@ export const CASE_CONFIGURE_SAVED_OBJECT = 'cases-configure'; export const caseConfigureSavedObjectType: SavedObjectsType = { name: CASE_CONFIGURE_SAVED_OBJECT, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { created_at: { diff --git a/x-pack/plugins/case/server/saved_object_types/user_actions.ts b/x-pack/plugins/case/server/saved_object_types/user_actions.ts index b61bfafc3b33c..826c6907efea6 100644 --- a/x-pack/plugins/case/server/saved_object_types/user_actions.ts +++ b/x-pack/plugins/case/server/saved_object_types/user_actions.ts @@ -11,7 +11,7 @@ export const CASE_USER_ACTION_SAVED_OBJECT = 'cases-user-actions'; export const caseUserActionSavedObjectType: SavedObjectsType = { name: CASE_USER_ACTION_SAVED_OBJECT, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { action_field: { diff --git a/x-pack/legacy/plugins/logstash/common/lib/get_moment.js b/x-pack/plugins/endpoint/common/schema/index_pattern.ts old mode 100755 new mode 100644 similarity index 64% rename from x-pack/legacy/plugins/logstash/common/lib/get_moment.js rename to x-pack/plugins/endpoint/common/schema/index_pattern.ts index 7a808ec9a0336..2809004f88c6e --- a/x-pack/legacy/plugins/logstash/common/lib/get_moment.js +++ b/x-pack/plugins/endpoint/common/schema/index_pattern.ts @@ -4,12 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import moment from 'moment'; +import { schema } from '@kbn/config-schema'; -export function getMoment(date) { - if (!date) { - return null; - } - - return moment(date); -} +export const indexPatternGetParamsSchema = schema.object({ datasetPath: schema.string() }); diff --git a/x-pack/plugins/endpoint/common/types.ts b/x-pack/plugins/endpoint/common/types.ts index 7143f07d8c702..49f8ebbd580d8 100644 --- a/x-pack/plugins/endpoint/common/types.ts +++ b/x-pack/plugins/endpoint/common/types.ts @@ -7,6 +7,7 @@ import { SearchResponse } from 'elasticsearch'; import { TypeOf } from '@kbn/config-schema'; import { alertingIndexGetQuerySchema } from './schema/alert_index'; +import { indexPatternGetParamsSchema } from './schema/index_pattern'; import { Datasource, NewDatasource } from '../../ingest_manager/common'; /** @@ -33,9 +34,9 @@ export type Direction = 'asc' | 'desc'; export class EndpointAppConstants { static BASE_API_URL = '/api/endpoint'; - static ENDPOINT_INDEX_NAME = 'endpoint-agent*'; + static INDEX_PATTERN_ROUTE = `${EndpointAppConstants.BASE_API_URL}/index_pattern`; static ALERT_INDEX_NAME = 'events-endpoint-1'; - static EVENT_INDEX_NAME = 'events-endpoint-*'; + static EVENT_DATASET = 'events'; static DEFAULT_TOTAL_HITS = 10000; /** * Legacy events are stored in indices with endgame-* prefix @@ -446,6 +447,11 @@ export type AlertingIndexGetQueryInput = KbnConfigSchemaInputTypeOf< */ export type AlertingIndexGetQueryResult = TypeOf; +/** + * Result of the validated params when handling an index pattern request. + */ +export type IndexPatternGetParamsResult = TypeOf; + /** * Endpoint Policy configuration */ diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/mocks/app_context_render.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/mocks/app_context_render.tsx index 7cb1031ef9a09..639b1f7252d7f 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/mocks/app_context_render.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/mocks/app_context_render.tsx @@ -12,6 +12,7 @@ import { coreMock } from '../../../../../../../src/core/public/mocks'; import { EndpointPluginStartDependencies } from '../../../plugin'; import { depsStartMock } from './dependencies_start_mock'; import { AppRootProvider } from '../view/app_root_provider'; +import { createSpyMiddleware, MiddlewareActionSpyHelper } from '../store/test_utils'; type UiRender = (ui: React.ReactElement, options?: RenderOptions) => RenderResult; @@ -23,6 +24,7 @@ export interface AppContextTestRender { history: ReturnType; coreStart: ReturnType; depsStart: EndpointPluginStartDependencies; + middlewareSpy: MiddlewareActionSpyHelper; /** * A wrapper around `AppRootContext` component. Uses the mocked modules as input to the * `AppRootContext` @@ -45,7 +47,12 @@ export const createAppRootMockRenderer = (): AppContextTestRender => { const history = createMemoryHistory(); const coreStart = coreMock.createStart({ basePath: '/mock' }); const depsStart = depsStartMock(); - const store = appStoreFactory({ coreStart, depsStart }); + const middlewareSpy = createSpyMiddleware(); + const store = appStoreFactory({ + coreStart, + depsStart, + additionalMiddleware: [middlewareSpy.actionSpyMiddleware], + }); const AppWrapper: React.FunctionComponent<{ children: React.ReactElement }> = ({ children }) => ( {children} @@ -64,6 +71,7 @@ export const createAppRootMockRenderer = (): AppContextTestRender => { history, coreStart, depsStart, + middlewareSpy, AppWrapper, render, }; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/action.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/action.ts index 2dce8ead38584..a32ecb4b45561 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/action.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/action.ts @@ -10,6 +10,9 @@ import { RoutingAction } from './routing'; import { PolicyListAction } from './policy_list'; import { PolicyDetailsAction } from './policy_details'; +/** + * The entire set of redux actions recognized by our reducer. + */ export type AppAction = | HostAction | AlertAction diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/middleware.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/middleware.ts index 2c6ebf52189f5..90d6b8b82198a 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/middleware.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/middleware.ts @@ -6,26 +6,32 @@ import { IIndexPattern } from 'src/plugins/data/public'; import { AlertResultList, AlertDetails } from '../../../../../common/types'; -import { AppAction } from '../action'; -import { MiddlewareFactory, AlertListState } from '../../types'; +import { ImmutableMiddlewareFactory, AlertListState } from '../../types'; import { isOnAlertPage, apiQueryParams, hasSelectedAlert, uiQueryParams } from './selectors'; import { cloneHttpFetchQuery } from '../../../../common/clone_http_fetch_query'; import { EndpointAppConstants } from '../../../../../common/types'; -export const alertMiddlewareFactory: MiddlewareFactory = (coreStart, depsStart) => { +export const alertMiddlewareFactory: ImmutableMiddlewareFactory = ( + coreStart, + depsStart +) => { async function fetchIndexPatterns(): Promise { const { indexPatterns } = depsStart.data; - const indexName = EndpointAppConstants.ALERT_INDEX_NAME; - const fields = await indexPatterns.getFieldsForWildcard({ pattern: indexName }); + const eventsPattern: { indexPattern: string } = await coreStart.http.get( + `${EndpointAppConstants.INDEX_PATTERN_ROUTE}/${EndpointAppConstants.EVENT_DATASET}` + ); + const fields = await indexPatterns.getFieldsForWildcard({ + pattern: eventsPattern.indexPattern, + }); const indexPattern: IIndexPattern = { - title: indexName, + title: eventsPattern.indexPattern, fields, }; return [indexPattern]; } - return api => next => async (action: AppAction) => { + return api => next => async action => { next(action); const state = api.getState(); if (action.type === 'userChangedUrl' && isOnAlertPage(state)) { diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/middleware.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/middleware.ts index 9481b6633f12e..83e11f5408bcd 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/middleware.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/middleware.ts @@ -4,13 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { MiddlewareFactory } from '../../types'; +import { ImmutableMiddlewareFactory } from '../../types'; import { pageIndex, pageSize, isOnHostPage, hasSelectedHost, uiQueryParams } from './selectors'; import { HostListState } from '../../types'; -import { AppAction } from '../action'; -export const hostMiddlewareFactory: MiddlewareFactory = coreStart => { - return ({ getState, dispatch }) => next => async (action: AppAction) => { +export const hostMiddlewareFactory: ImmutableMiddlewareFactory = coreStart => { + return ({ getState, dispatch }) => next => async action => { next(action); const state = getState(); if ( diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/selectors.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/selectors.ts index 35bf5d0616878..03cdba8505800 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/selectors.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/hosts/selectors.ts @@ -37,7 +37,7 @@ export const uiQueryParams: ( // Removes the `?` from the beginning of query string if it exists const query = querystring.parse(location.search.slice(1)); - const keys: Array = ['selected_host']; + const keys: Array = ['selected_host', 'show']; for (const key of keys) { const value = query[key]; @@ -58,3 +58,11 @@ export const hasSelectedHost: (state: Immutable) => boolean = cre return selectedHost !== undefined; } ); + +/** What policy details panel view to show */ +export const showView: (state: HostListState) => 'policy_response' | 'details' = createSelector( + uiQueryParams, + searchParams => { + return searchParams.show === 'policy_response' ? 'policy_response' : 'details'; + } +); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/index.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/index.ts index efa79b163d3b6..a4d0b3a8b9815 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/index.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/index.ts @@ -4,44 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ -import { - createStore, - compose, - applyMiddleware, - Store, - MiddlewareAPI, - Dispatch, - Middleware, -} from 'redux'; +import { createStore, compose, applyMiddleware, Store } from 'redux'; import { CoreStart } from 'kibana/public'; import { appReducer } from './reducer'; import { alertMiddlewareFactory } from './alerts/middleware'; import { hostMiddlewareFactory } from './hosts'; import { policyListMiddlewareFactory } from './policy_list'; import { policyDetailsMiddlewareFactory } from './policy_details'; -import { GlobalState } from '../types'; -import { AppAction } from './action'; +import { ImmutableMiddlewareFactory, SubstateMiddlewareFactory } from '../types'; import { EndpointPluginStartDependencies } from '../../../plugin'; const composeWithReduxDevTools = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ name: 'EndpointApp' }) : compose; -export type Selector = (state: S) => R; - -/** - * Wrap Redux Middleware and adjust 'getState()' to return the namespace from 'GlobalState that applies to the given Middleware concern. - * - * @param selector - * @param middleware - */ -export const substateMiddlewareFactory = ( - selector: Selector, - middleware: Middleware<{}, Substate, Dispatch> -): Middleware<{}, GlobalState, Dispatch> => { +export const substateMiddlewareFactory: SubstateMiddlewareFactory = (selector, middleware) => { return api => { - const substateAPI: MiddlewareAPI, Substate> = { + const substateAPI = { ...api, + // Return just the substate instead of global state. getState() { return selector(api.getState()); }, @@ -62,10 +43,15 @@ export const appStoreFactory: (middlewareDeps?: { * Give middleware access to plugin start dependencies. */ depsStart: EndpointPluginStartDependencies; + /** + * Any additional Redux Middlewares + * (should only be used for testing - example: to inject the action spy middleware) + */ + additionalMiddleware?: Array>; }) => Store = middlewareDeps => { let middleware; if (middlewareDeps) { - const { coreStart, depsStart } = middlewareDeps; + const { coreStart, depsStart, additionalMiddleware = [] } = middlewareDeps; middleware = composeWithReduxDevTools( applyMiddleware( substateMiddlewareFactory( @@ -83,7 +69,9 @@ export const appStoreFactory: (middlewareDeps?: { substateMiddlewareFactory( globalState => globalState.alertList, alertMiddlewareFactory(coreStart, depsStart) - ) + ), + // Additional Middleware should go last + ...additionalMiddleware ) ); } else { diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts index 7a3fbe7f23b9b..7f17f5381fbda 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/middleware.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { MiddlewareFactory, PolicyDetailsState, UpdatePolicyResponse } from '../../types'; +import { ImmutableMiddlewareFactory, PolicyDetailsState, UpdatePolicyResponse } from '../../types'; import { policyIdFromParams, isOnPolicyDetailsPage, policyDetails } from './selectors'; import { sendGetDatasource, @@ -14,7 +14,7 @@ import { import { PolicyData } from '../../../../../common/types'; import { factory as policyConfigFactory } from '../../../../../common/models/policy_config'; -export const policyDetailsMiddlewareFactory: MiddlewareFactory = coreStart => { +export const policyDetailsMiddlewareFactory: ImmutableMiddlewareFactory = coreStart => { const http = coreStart.http; return ({ getState, dispatch }) => next => async action => { diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/selectors.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/selectors.ts index 98e129132e1cb..4fd36d8d0a33f 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/selectors.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_details/selectors.ts @@ -23,8 +23,8 @@ export const isOnPolicyDetailsPage = (state: Immutable) => { }; /** Returns the policyId from the url */ -export const policyIdFromParams: (state: PolicyDetailsState) => string = createSelector( - (state: PolicyDetailsState) => state.location, +export const policyIdFromParams: (state: Immutable) => string = createSelector( + state => state.location, (location: PolicyDetailsState['location']) => { if (location) { return location.pathname.split('/')[2]; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/index.test.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/index.test.ts index 97a2b65fb65f8..69b11fb3c1f0e 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/index.test.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/index.test.ts @@ -12,13 +12,10 @@ import { policyListMiddlewareFactory } from './middleware'; import { coreMock } from '../../../../../../../../src/core/public/mocks'; import { isOnPolicyListPage, selectIsLoading, urlSearchParams } from './selectors'; import { DepsStartMock, depsStartMock } from '../../mocks'; -import { - createSpyMiddleware, - MiddlewareActionSpyHelper, - setPolicyListApiMockImplementation, -} from './test_mock_utils'; +import { setPolicyListApiMockImplementation } from './test_mock_utils'; import { INGEST_API_DATASOURCES } from './services/ingest'; import { Immutable } from '../../../../../common/types'; +import { createSpyMiddleware, MiddlewareActionSpyHelper } from '../test_utils'; describe('policy list store concerns', () => { let fakeCoreStart: ReturnType; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/middleware.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/middleware.ts index cc771a4619e78..78ebacd971840 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/middleware.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/middleware.ts @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { GetPolicyListResponse, MiddlewareFactory, PolicyListState } from '../../types'; +import { GetPolicyListResponse, ImmutableMiddlewareFactory, PolicyListState } from '../../types'; import { sendGetEndpointSpecificDatasources } from './services/ingest'; import { isOnPolicyListPage, urlSearchParams } from './selectors'; -export const policyListMiddlewareFactory: MiddlewareFactory = coreStart => { +export const policyListMiddlewareFactory: ImmutableMiddlewareFactory = coreStart => { const http = coreStart.http; return ({ getState, dispatch }) => next => async action => { diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/test_mock_utils.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/test_mock_utils.ts index 20d5a637182d2..a1788b8f8021d 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/test_mock_utils.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/test_mock_utils.ts @@ -5,10 +5,9 @@ */ import { HttpStart } from 'kibana/public'; -import { Dispatch } from 'redux'; import { INGEST_API_DATASOURCES } from './services/ingest'; import { EndpointDocGenerator } from '../../../../../common/generate_data'; -import { AppAction, GetPolicyListResponse, GlobalState, MiddlewareFactory } from '../../types'; +import { GetPolicyListResponse } from '../../types'; const generator = new EndpointDocGenerator('policy-list'); @@ -37,115 +36,3 @@ export const setPolicyListApiMockImplementation = ( return Promise.reject(new Error(`MOCK: unknown policy list api: ${path}`)); }); }; - -/** - * Utilities for testing Redux middleware - */ -export interface MiddlewareActionSpyHelper { - /** - * Returns a promise that is fulfilled when the given action is dispatched or a timeout occurs. - * The use of this method instead of a `sleep()` type of delay should avoid test case instability - * especially when run in a CI environment. - * - * @param actionType - */ - waitForAction: (actionType: AppAction['type']) => Promise; - /** - * A property holding the information around the calls that were processed by the internal - * `actionSpyMiddlware`. This property holds the information typically found in Jets's mocked - * function `mock` property - [see here for more information](https://jestjs.io/docs/en/mock-functions#mock-property) - * - * **Note**: this property will only be set **after* the `actionSpyMiddlware` has been - * initialized (ex. via `createStore()`. Attempting to reference this property before that time - * will throw an error. - * Also - do not hold on to references to this property value if `jest.clearAllMocks()` or - * `jest.resetAllMocks()` is called between usages of the value. - */ - dispatchSpy: jest.Mock>['mock']; - /** - * Redux middleware that enables spying on the action that are dispatched through the store - */ - actionSpyMiddleware: ReturnType>; -} - -/** - * Creates a new instance of middleware action helpers - * Note: in most cases (testing concern specific middleware) this function should be given - * the state type definition, else, the global state will be used. - * - * @example - * // Use in Policy List middleware testing - * const middlewareSpyUtils = createSpyMiddleware(); - * store = createStore( - * policyListReducer, - * applyMiddleware( - * policyListMiddlewareFactory(fakeCoreStart, depsStart), - * middlewareSpyUtils.actionSpyMiddleware - * ) - * ); - * // Reference `dispatchSpy` ONLY after creating the store that includes `actionSpyMiddleware` - * const { waitForAction, dispatchSpy } = middlewareSpyUtils; - * // - * // later in test - * // - * it('...', async () => { - * //... - * await waitForAction('serverReturnedPolicyListData'); - * // do assertions - * // or check how action was called - * expect(dispatchSpy.calls.length).toBe(2) - * }); - */ -export const createSpyMiddleware = (): MiddlewareActionSpyHelper => { - type ActionWatcher = (action: AppAction) => void; - - const watchers = new Set(); - let spyDispatch: jest.Mock>; - - return { - waitForAction: async (actionType: string) => { - // Error is defined here so that we get a better stack trace that points to the test from where it was used - const err = new Error(`action '${actionType}' was not dispatched within the allocated time`); - - await new Promise((resolve, reject) => { - const watch: ActionWatcher = action => { - if (action.type === actionType) { - watchers.delete(watch); - clearTimeout(timeout); - resolve(); - } - }; - - // We timeout before jest's default 5s, so that a better error stack is returned - const timeout = setTimeout(() => { - watchers.delete(watch); - reject(err); - }, 4500); - watchers.add(watch); - }); - }, - - get dispatchSpy() { - if (!spyDispatch) { - throw new Error( - 'Spy Middleware has not been initialized. Access this property only after using `actionSpyMiddleware` in a redux store' - ); - } - return spyDispatch.mock; - }, - - actionSpyMiddleware: api => { - return next => { - spyDispatch = jest.fn(action => { - next(action); - // loop through the list of watcher (if any) and call them with this action - for (const watch of watchers) { - watch(action); - } - return action; - }); - return spyDispatch; - }; - }, - }; -}; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/test_utils.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/test_utils.ts new file mode 100644 index 0000000000000..df17cf8cf6638 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/test_utils.ts @@ -0,0 +1,126 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { Dispatch } from 'redux'; +import { AppAction, GlobalState, ImmutableMiddlewareFactory } from '../types'; + +/** + * Utilities for testing Redux middleware + */ +export interface MiddlewareActionSpyHelper { + /** + * Returns a promise that is fulfilled when the given action is dispatched or a timeout occurs. + * The `action` will given to the promise `resolve` thus allowing for checks to be done. + * The use of this method instead of a `sleep()` type of delay should avoid test case instability + * especially when run in a CI environment. + * + * @param actionType + */ + waitForAction: (actionType: T) => Promise; + /** + * A property holding the information around the calls that were processed by the internal + * `actionSpyMiddelware`. This property holds the information typically found in Jets's mocked + * function `mock` property - [see here for more information](https://jestjs.io/docs/en/mock-functions#mock-property) + * + * **Note**: this property will only be set **after* the `actionSpyMiddlware` has been + * initialized (ex. via `createStore()`. Attempting to reference this property before that time + * will throw an error. + * Also - do not hold on to references to this property value if `jest.clearAllMocks()` or + * `jest.resetAllMocks()` is called between usages of the value. + */ + dispatchSpy: jest.Mock>['mock']; + /** + * Redux middleware that enables spying on the action that are dispatched through the store + */ + actionSpyMiddleware: ReturnType>; +} + +/** + * Creates a new instance of middleware action helpers + * Note: in most cases (testing concern specific middleware) this function should be given + * the state type definition, else, the global state will be used. + * + * @example + * // Use in Policy List middleware testing + * const middlewareSpyUtils = createSpyMiddleware(); + * store = createStore( + * policyListReducer, + * applyMiddleware( + * policyListMiddlewareFactory(fakeCoreStart, depsStart), + * middlewareSpyUtils.actionSpyMiddleware + * ) + * ); + * // Reference `dispatchSpy` ONLY after creating the store that includes `actionSpyMiddleware` + * const { waitForAction, dispatchSpy } = middlewareSpyUtils; + * // + * // later in test + * // + * it('...', async () => { + * //... + * await waitForAction('serverReturnedPolicyListData'); + * // do assertions + * // or check how action was called + * expect(dispatchSpy.calls.length).toBe(2) + * }); + */ +export const createSpyMiddleware = < + S = GlobalState, + A extends AppAction = AppAction +>(): MiddlewareActionSpyHelper => { + type ActionWatcher = (action: A) => void; + + const watchers = new Set(); + let spyDispatch: jest.Mock>; + + return { + waitForAction: async actionType => { + type ResolvedAction = A extends { type: typeof actionType } ? A : never; + + // Error is defined here so that we get a better stack trace that points to the test from where it was used + const err = new Error(`action '${actionType}' was not dispatched within the allocated time`); + + return new Promise((resolve, reject) => { + const watch: ActionWatcher = action => { + if (action.type === actionType) { + watchers.delete(watch); + clearTimeout(timeout); + resolve(action as ResolvedAction); + } + }; + + // We timeout before jest's default 5s, so that a better error stack is returned + const timeout = setTimeout(() => { + watchers.delete(watch); + reject(err); + }, 4500); + watchers.add(watch); + }); + }, + + get dispatchSpy() { + if (!spyDispatch) { + throw new Error( + 'Spy Middleware has not been initialized. Access this property only after using `actionSpyMiddleware` in a redux store' + ); + } + return spyDispatch.mock; + }, + + actionSpyMiddleware: () => { + return next => { + spyDispatch = jest.fn(action => { + next(action); + // loop through the list of watcher (if any) and call them with this action + for (const watch of watchers) { + watch(action); + } + return action; + }); + return spyDispatch; + }; + }, + }; +}; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/types.ts b/x-pack/plugins/endpoint/public/applications/endpoint/types.ts index 7aca94d3e9c7c..f407d32cb3b42 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/types.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/types.ts @@ -4,7 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Dispatch, MiddlewareAPI, Action as ReduxAction, AnyAction as ReduxAnyAction } from 'redux'; +import { + Dispatch, + Action as ReduxAction, + AnyAction as ReduxAnyAction, + Action, + Middleware, +} from 'redux'; import { IIndexPattern } from 'src/plugins/data/public'; import { HostMetadata, @@ -28,12 +34,59 @@ import { } from '../../../../ingest_manager/common'; export { AppAction }; -export type MiddlewareFactory = ( + +/** + * like redux's `MiddlewareAPI` but `getState` returns an `Immutable` version of + * state and `dispatch` accepts `Immutable` versions of actions. + */ +export interface ImmutableMiddlewareAPI { + dispatch: Dispatch>; + getState(): Immutable; +} + +/** + * Like redux's `Middleware` but without the ability to mutate actions or state. + * Differences: + * * `getState` returns an `Immutable` version of state + * * `dispatch` accepts `Immutable` versions of actions + * * `action`s received will be `Immutable` + */ +export type ImmutableMiddleware = ( + api: ImmutableMiddlewareAPI +) => (next: Dispatch>) => (action: Immutable) => unknown; + +/** + * Takes application-standard middleware dependencies + * and returns a redux middleware. + * Middleware will be of the `ImmutableMiddleware` variety. Not able to directly + * change actions or state. + */ +export type ImmutableMiddlewareFactory = ( coreStart: CoreStart, depsStart: EndpointPluginStartDependencies -) => ( - api: MiddlewareAPI, S> -) => (next: Dispatch) => (action: AppAction) => unknown; +) => ImmutableMiddleware; + +/** + * Simple type for a redux selector. + */ +type Selector = (state: S) => R; + +/** + * Takes a selector and an `ImmutableMiddleware`. The + * middleware's version of `getState` will receive + * the result of the selector instead of the global state. + * + * This allows middleware to have knowledge of only a subsection of state. + * + * `selector` returns an `Immutable` version of the substate. + * `middleware` must be an `ImmutableMiddleware`. + * + * Returns a regular middleware, meant to be used with `applyMiddleware`. + */ +export type SubstateMiddlewareFactory = ( + selector: Selector>, + middleware: ImmutableMiddleware +) => Middleware<{}, GlobalState, Dispatch>>; export interface HostListState { hosts: HostMetadata[]; @@ -52,6 +105,7 @@ export interface HostListPagination { } export interface HostIndexUIQueryParams { selected_host?: string; + show?: string; } export interface ServerApiError { diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/components/__snapshots__/page_view.test.tsx.snap b/x-pack/plugins/endpoint/public/applications/endpoint/view/components/__snapshots__/page_view.test.tsx.snap index dfc69fc46ebdc..36b602a1e6784 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/components/__snapshots__/page_view.test.tsx.snap +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/components/__snapshots__/page_view.test.tsx.snap @@ -7,6 +7,7 @@ exports[`PageView component should display body header custom element 1`] = ` .c0.endpoint--isListView .endpoint-header { padding: 24px; + margin-bottom: 0; } .c0.endpoint--isListView .endpoint-page-content { @@ -97,6 +98,7 @@ exports[`PageView component should display body header wrapped in EuiTitle 1`] = .c0.endpoint--isListView .endpoint-header { padding: 24px; + margin-bottom: 0; } .c0.endpoint--isListView .endpoint-page-content { @@ -190,6 +192,7 @@ exports[`PageView component should display header left and right 1`] = ` .c0.endpoint--isListView .endpoint-header { padding: 24px; + margin-bottom: 0; } .c0.endpoint--isListView .endpoint-page-content { @@ -298,6 +301,7 @@ exports[`PageView component should display only body if not header props used 1` .c0.endpoint--isListView .endpoint-header { padding: 24px; + margin-bottom: 0; } .c0.endpoint--isListView .endpoint-page-content { @@ -365,6 +369,7 @@ exports[`PageView component should display only header left 1`] = ` .c0.endpoint--isListView .endpoint-header { padding: 24px; + margin-bottom: 0; } .c0.endpoint--isListView .endpoint-page-content { @@ -462,6 +467,7 @@ exports[`PageView component should display only header right but include an empt .c0.endpoint--isListView .endpoint-header { padding: 24px; + margin-bottom: 0; } .c0.endpoint--isListView .endpoint-page-content { @@ -556,6 +562,7 @@ exports[`PageView component should pass through EuiPage props 1`] = ` .c0.endpoint--isListView .endpoint-header { padding: 24px; + margin-bottom: 0; } .c0.endpoint--isListView .endpoint-page-content { @@ -640,6 +647,7 @@ exports[`PageView component should use custom element for header left and not wr .c0.endpoint--isListView .endpoint-header { padding: 24px; + margin-bottom: 0; } .c0.endpoint--isListView .endpoint-page-content { diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/components/page_view.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/components/page_view.tsx index 561d671e18e07..6da352b68f890 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/components/page_view.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/components/page_view.tsx @@ -25,6 +25,7 @@ const StyledEuiPage = styled(EuiPage)` .endpoint-header { padding: ${props => props.theme.eui.euiSizeL}; + margin-bottom: 0; } .endpoint-page-content { border-left: none; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/components/flyout_sub_header.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/components/flyout_sub_header.tsx new file mode 100644 index 0000000000000..26f2203790a9e --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/components/flyout_sub_header.tsx @@ -0,0 +1,72 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { memo } from 'react'; +import { EuiFlyoutHeader, CommonProps, EuiButtonEmpty } from '@elastic/eui'; +import styled from 'styled-components'; + +export type FlyoutSubHeaderProps = CommonProps & { + children: React.ReactNode; + backButton?: { + title: string; + onClick: (event: React.MouseEvent) => void; + href?: string; + }; +}; + +const StyledEuiFlyoutHeader = styled(EuiFlyoutHeader)` + padding: ${props => props.theme.eui.paddingSizes.s}; + + &.hasButtons { + .buttons { + padding-bottom: ${props => props.theme.eui.paddingSizes.s}; + } + + .back-button-content { + padding-left: 0; + &-text { + margin-left: 0; + } + } + } + + .flyout-content { + padding-left: ${props => props.theme.eui.paddingSizes.m}; + } +`; + +const BUTTON_CONTENT_PROPS = Object.freeze({ className: 'back-button-content' }); +const BUTTON_TEXT_PROPS = Object.freeze({ className: 'back-button-content-text' }); + +/** + * A Eui Flyout Header component that has its styles adjusted to display a panel sub-header. + * Component also provides a way to display a "back" button above the header title. + */ +export const FlyoutSubHeader = memo( + ({ children, backButton, ...otherProps }) => { + return ( + + {backButton && ( +
+ {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} + + {backButton?.title} + +
+ )} +
{children}
+
+ ); + } +); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/host_details.tsx similarity index 53% rename from x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details.tsx rename to x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/host_details.tsx index f51349b24933a..32c69426b03f3 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/host_details.tsx @@ -4,31 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useCallback, useMemo, memo, useEffect } from 'react'; +import styled from 'styled-components'; import { - EuiFlyout, - EuiFlyoutBody, - EuiFlyoutHeader, - EuiTitle, EuiDescriptionList, - EuiLoadingContent, - EuiHorizontalRule, EuiHealth, - EuiSpacer, + EuiHorizontalRule, + EuiLink, EuiListGroup, EuiListGroupItem, } from '@elastic/eui'; -import { useHistory } from 'react-router-dom'; -import styled from 'styled-components'; -import { i18n } from '@kbn/i18n'; +import React, { memo, useMemo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; -import { HostMetadata } from '../../../../../common/types'; -import { useHostListSelector } from './hooks'; -import { urlFromQueryParams } from './url_from_query_params'; -import { FormattedDateAndTime } from '../formatted_date_time'; -import { uiQueryParams, detailsData, detailsError } from './../../store/hosts/selectors'; -import { LinkToApp } from '../components/link_to_app'; +import { i18n } from '@kbn/i18n'; +import { useHistory } from 'react-router-dom'; +import { HostMetadata } from '../../../../../../common/types'; +import { FormattedDateAndTime } from '../../formatted_date_time'; +import { LinkToApp } from '../../components/link_to_app'; +import { useHostListSelector, useHostLogsUrl } from '../hooks'; +import { urlFromQueryParams } from '../url_from_query_params'; +import { uiQueryParams } from '../../../store/hosts/selectors'; const HostIds = styled(EuiListGroupItem)` margin-top: 0; @@ -37,8 +31,10 @@ const HostIds = styled(EuiListGroupItem)` } `; -const HostDetails = memo(({ details }: { details: HostMetadata }) => { +export const HostDetails = memo(({ details }: { details: HostMetadata }) => { const { appId, appPath, url } = useHostLogsUrl(details.host.id); + const queryParams = useHostListSelector(uiQueryParams); + const history = useHistory(); const detailsResultsUpper = useMemo(() => { return [ { @@ -62,6 +58,14 @@ const HostDetails = memo(({ details }: { details: HostMetadata }) => { ]; }, [details]); + const policyResponseUri = useMemo(() => { + return urlFromQueryParams({ + ...queryParams, + selected_host: details.host.id, + show: 'policy_response', + }); + }, [details.host.id, queryParams]); + const detailsResultsLower = useMemo(() => { return [ { @@ -74,7 +78,24 @@ const HostDetails = memo(({ details }: { details: HostMetadata }) => { title: i18n.translate('xpack.endpoint.host.details.policyStatus', { defaultMessage: 'Policy Status', }), - description: active, + description: ( + + {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} + { + ev.preventDefault(); + history.push(policyResponseUri); + }} + > + + + + ), }, { title: i18n.translate('xpack.endpoint.host.details.ipAddress', { @@ -101,7 +122,15 @@ const HostDetails = memo(({ details }: { details: HostMetadata }) => { description: details.agent.version, }, ]; - }, [details.agent.version, details.endpoint.policy.id, details.host.hostname, details.host.ip]); + }, [ + details.agent.version, + details.endpoint.policy.id, + details.host.hostname, + details.host.ip, + history, + policyResponseUri, + ]); + return ( <> { ); }); - -export const HostDetailsFlyout = () => { - const history = useHistory(); - const { notifications } = useKibana(); - const queryParams = useHostListSelector(uiQueryParams); - const { selected_host: selectedHost, ...queryParamsWithoutSelectedHost } = queryParams; - const details = useHostListSelector(detailsData); - const error = useHostListSelector(detailsError); - - const handleFlyoutClose = useCallback(() => { - history.push(urlFromQueryParams(queryParamsWithoutSelectedHost)); - }, [history, queryParamsWithoutSelectedHost]); - - useEffect(() => { - if (error !== undefined) { - notifications.toasts.danger({ - title: ( - - ), - body: ( - - ), - toastLifeTimeMs: 10000, - }); - } - }, [error, notifications.toasts]); - - return ( - - - -

- {details === undefined ? : details.host.hostname} -

-
-
- - {details === undefined ? ( - <> - - - ) : ( - - )} - -
- ); -}; - -const useHostLogsUrl = (hostId: string): { url: string; appId: string; appPath: string } => { - const { services } = useKibana(); - return useMemo(() => { - const appPath = `/stream?logFilter=(expression:'host.id:${hostId}',kind:kuery)`; - return { - url: `${services.application.getUrlForApp('logs')}${appPath}`, - appId: 'logs', - appPath, - }; - }, [hostId, services.application]); -}; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/index.tsx new file mode 100644 index 0000000000000..a41d4a968f177 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/index.tsx @@ -0,0 +1,134 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useCallback, useEffect, memo, useMemo } from 'react'; +import { + EuiFlyout, + EuiFlyoutBody, + EuiFlyoutHeader, + EuiTitle, + EuiLoadingContent, + EuiSpacer, +} from '@elastic/eui'; +import { useHistory } from 'react-router-dom'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import { useKibana } from '../../../../../../../../../src/plugins/kibana_react/public'; +import { useHostListSelector } from '../hooks'; +import { urlFromQueryParams } from '../url_from_query_params'; +import { uiQueryParams, detailsData, detailsError, showView } from '../../../store/hosts/selectors'; +import { HostDetails } from './host_details'; +import { PolicyResponse } from './policy_response'; +import { HostMetadata } from '../../../../../../common/types'; +import { FlyoutSubHeader, FlyoutSubHeaderProps } from './components/flyout_sub_header'; + +export const HostDetailsFlyout = memo(() => { + const history = useHistory(); + const { notifications } = useKibana(); + const queryParams = useHostListSelector(uiQueryParams); + const { selected_host: selectedHost, ...queryParamsWithoutSelectedHost } = queryParams; + const details = useHostListSelector(detailsData); + const error = useHostListSelector(detailsError); + const show = useHostListSelector(showView); + + const handleFlyoutClose = useCallback(() => { + history.push(urlFromQueryParams(queryParamsWithoutSelectedHost)); + }, [history, queryParamsWithoutSelectedHost]); + + useEffect(() => { + if (error !== undefined) { + notifications.toasts.danger({ + title: ( + + ), + body: ( + + ), + toastLifeTimeMs: 10000, + }); + } + }, [error, notifications.toasts]); + + return ( + + + +

+ {details === undefined ? : details.host.hostname} +

+
+
+ {details === undefined ? ( + <> + + + + + ) : ( + <> + {show === 'details' && ( + <> + + + + + )} + {show === 'policy_response' && } + + )} +
+ ); +}); + +const PolicyResponseFlyoutPanel = memo<{ + hostMeta: HostMetadata; +}>(({ hostMeta }) => { + const history = useHistory(); + const { show, ...queryParams } = useHostListSelector(uiQueryParams); + const backButtonProp = useMemo((): FlyoutSubHeaderProps['backButton'] => { + const detailsUri = urlFromQueryParams({ + ...queryParams, + selected_host: hostMeta.host.id, + }); + return { + title: i18n.translate('xpack.endpoint.host.policyResponse.backLinkTitle', { + defaultMessage: 'Endpoint Details', + }), + href: '?' + detailsUri.search, + onClick: ev => { + ev.preventDefault(); + history.push(detailsUri); + }, + }; + }, [history, hostMeta.host.id, queryParams]); + + return ( + <> + + +

+ +

+
+
+ + + + + ); +}); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/policy_response.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/policy_response.tsx new file mode 100644 index 0000000000000..eacb6a52d3184 --- /dev/null +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/details/policy_response.tsx @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import React, { memo } from 'react'; + +export const PolicyResponse = memo(() => { + return
Policy Status to be displayed here soon.
; +}); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/hooks.ts b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/hooks.ts index 99a0073f46c74..7eb51f3a7b294 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/hooks.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/hooks.ts @@ -5,10 +5,28 @@ */ import { useSelector } from 'react-redux'; +import { useMemo } from 'react'; import { GlobalState, HostListState } from '../../types'; +import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; export function useHostListSelector(selector: (state: HostListState) => TSelected) { return useSelector(function(state: GlobalState) { return selector(state.hostList); }); } + +/** + * Returns an object that contains Kibana Logs app and URL information for a given host id + * @param hostId + */ +export const useHostLogsUrl = (hostId: string): { url: string; appId: string; appPath: string } => { + const { services } = useKibana(); + return useMemo(() => { + const appPath = `/stream?logFilter=(expression:'host.id:${hostId}',kind:kuery)`; + return { + url: `${services.application.getUrlForApp('logs')}${appPath}`, + appId: 'logs', + appPath, + }; + }, [hostId, services.application]); +}; diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/index.test.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/index.test.tsx index d2d0ad40b025f..88416b577ed0c 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/index.test.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/hosts/index.test.tsx @@ -21,10 +21,11 @@ describe('when on the hosts page', () => { let history: AppContextTestRender['history']; let store: AppContextTestRender['store']; let coreStart: AppContextTestRender['coreStart']; + let middlewareSpy: AppContextTestRender['middlewareSpy']; beforeEach(async () => { const mockedContext = createAppRootMockRenderer(); - ({ history, store, coreStart } = mockedContext); + ({ history, store, coreStart, middlewareSpy } = mockedContext); render = () => mockedContext.render(); }); @@ -132,6 +133,25 @@ describe('when on the hosts page', () => { expect(flyout).not.toBeNull(); }); }); + it('should display policy status value as a link', async () => { + const renderResult = render(); + const policyStatusLink = await renderResult.findByTestId('policyStatusValue'); + expect(policyStatusLink).not.toBeNull(); + expect(policyStatusLink.textContent).toEqual('Successful'); + expect(policyStatusLink.getAttribute('href')).toEqual( + '?selected_host=1&show=policy_response' + ); + }); + it('should update the URL when policy status link is clicked', async () => { + const renderResult = render(); + const policyStatusLink = await renderResult.findByTestId('policyStatusValue'); + const userChangedUrlChecker = middlewareSpy.waitForAction('userChangedUrl'); + reactTestingLibrary.act(() => { + fireEvent.click(policyStatusLink); + }); + const changedUrlAction = await userChangedUrlChecker; + expect(changedUrlAction.payload.search).toEqual('?selected_host=1&show=policy_response'); + }); it('should include the link to logs', async () => { const renderResult = render(); const linkToLogs = await renderResult.findByTestId('hostDetailsLinkToLogs'); @@ -154,5 +174,48 @@ describe('when on the hosts page', () => { expect(coreStart.application.navigateToApp.mock.calls).toHaveLength(1); }); }); + describe('when showing host Policy Response', () => { + let renderResult: ReturnType; + beforeEach(async () => { + renderResult = render(); + const policyStatusLink = await renderResult.findByTestId('policyStatusValue'); + const userChangedUrlChecker = middlewareSpy.waitForAction('userChangedUrl'); + reactTestingLibrary.act(() => { + fireEvent.click(policyStatusLink); + }); + await userChangedUrlChecker; + }); + it('should hide the host details panel', async () => { + const hostDetailsFlyout = await renderResult.queryByTestId('hostDetailsFlyoutBody'); + expect(hostDetailsFlyout).toBeNull(); + }); + it('should display policy response sub-panel', async () => { + expect( + await renderResult.findByTestId('hostDetailsPolicyResponseFlyoutHeader') + ).not.toBeNull(); + expect( + await renderResult.findByTestId('hostDetailsPolicyResponseFlyoutBody') + ).not.toBeNull(); + }); + it('should include the sub-panel title', async () => { + expect( + (await renderResult.findByTestId('hostDetailsPolicyResponseFlyoutTitle')).textContent + ).toBe('Policy Response'); + }); + it('should include the back to details link', async () => { + const subHeaderBackLink = await renderResult.findByTestId('flyoutSubHeaderBackButton'); + expect(subHeaderBackLink.textContent).toBe('Endpoint Details'); + expect(subHeaderBackLink.getAttribute('href')).toBe('?selected_host=1'); + }); + it('should update URL when back to details link is clicked', async () => { + const subHeaderBackLink = await renderResult.findByTestId('flyoutSubHeaderBackButton'); + const userChangedUrlChecker = middlewareSpy.waitForAction('userChangedUrl'); + reactTestingLibrary.act(() => { + fireEvent.click(subHeaderBackLink); + }); + const changedUrlAction = await userChangedUrlChecker; + expect(changedUrlAction.payload.search).toEqual('?selected_host=1'); + }); + }); }); }); diff --git a/x-pack/plugins/endpoint/public/embeddables/resolver/view/defs.tsx b/x-pack/plugins/endpoint/public/embeddables/resolver/view/defs.tsx index de9c3c7e8f8f3..064645019ca34 100644 --- a/x-pack/plugins/endpoint/public/embeddables/resolver/view/defs.tsx +++ b/x-pack/plugins/endpoint/public/embeddables/resolver/view/defs.tsx @@ -54,7 +54,11 @@ type ResolverColorNames = | 'activeNoWarning' | 'activeWarning' | 'fullLabelBackground' - | 'inertDescription'; + | 'inertDescription' + | 'labelBackgroundTerminatedProcess' + | 'labelBackgroundTerminatedTrigger' + | 'labelBackgroundRunningProcess' + | 'labelBackgroundRunningTrigger'; export const NamedColors: Record = { ok: saturate(0.5, resolverPalette.temperatures[0]), @@ -70,6 +74,10 @@ export const NamedColors: Record = { activeNoWarning: '#0078FF', activeWarning: '#C61F38', fullLabelBackground: '#3B3C41', + labelBackgroundTerminatedProcess: '#8A96A8', + labelBackgroundTerminatedTrigger: '#8A96A8', + labelBackgroundRunningProcess: '#8A96A8', + labelBackgroundRunningTrigger: '#8A96A8', inertDescription: '#747474', }; diff --git a/x-pack/plugins/endpoint/public/embeddables/resolver/view/process_event_dot.tsx b/x-pack/plugins/endpoint/public/embeddables/resolver/view/process_event_dot.tsx index 10e331ffff02d..3201e83164dba 100644 --- a/x-pack/plugins/endpoint/public/embeddables/resolver/view/process_event_dot.tsx +++ b/x-pack/plugins/endpoint/public/embeddables/resolver/view/process_event_dot.tsx @@ -7,7 +7,13 @@ import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; import { i18n } from '@kbn/i18n'; -import { htmlIdGenerator, EuiKeyboardAccessible } from '@elastic/eui'; +import { + htmlIdGenerator, + EuiKeyboardAccessible, + EuiButton, + EuiFlexGroup, + EuiFlexItem, +} from '@elastic/eui'; import { useSelector } from 'react-redux'; import { applyMatrix3 } from '../lib/vector2'; import { Vector2, Matrix3, AdjacentProcessMap, ResolverProcessType } from '../types'; @@ -21,7 +27,7 @@ import * as selectors from '../store/selectors'; const nodeAssets = { runningProcessCube: { cubeSymbol: `#${SymbolIds.runningProcessCube}`, - labelBackground: NamedColors.fullLabelBackground, + labelBackground: NamedColors.labelBackgroundRunningProcess, descriptionFill: NamedColors.empty, descriptionText: i18n.translate('xpack.endpoint.resolver.runningProcess', { defaultMessage: 'Running Process', @@ -29,7 +35,7 @@ const nodeAssets = { }, runningTriggerCube: { cubeSymbol: `#${SymbolIds.runningTriggerCube}`, - labelBackground: NamedColors.fullLabelBackground, + labelBackground: NamedColors.labelBackgroundRunningTrigger, descriptionFill: NamedColors.empty, descriptionText: i18n.translate('xpack.endpoint.resolver.runningTrigger', { defaultMessage: 'Running Trigger', @@ -37,7 +43,7 @@ const nodeAssets = { }, terminatedProcessCube: { cubeSymbol: `#${SymbolIds.terminatedProcessCube}`, - labelBackground: NamedColors.fullLabelBackground, + labelBackground: NamedColors.labelBackgroundTerminatedProcess, descriptionFill: NamedColors.empty, descriptionText: i18n.translate('xpack.endpoint.resolver.terminatedProcess', { defaultMessage: 'Terminated Process', @@ -45,7 +51,7 @@ const nodeAssets = { }, terminatedTriggerCube: { cubeSymbol: `#${SymbolIds.terminatedTriggerCube}`, - labelBackground: NamedColors.fullLabelBackground, + labelBackground: NamedColors.labelBackgroundTerminatedTrigger, descriptionFill: NamedColors.empty, descriptionText: i18n.translate('xpack.endpoint.resolver.terminatedTrigger', { defaultMessage: 'Terminated Trigger', @@ -53,8 +59,46 @@ const nodeAssets = { }, }; +const ChildEventsButton = React.memo(() => { + return ( + ) => { + clickEvent.preventDefault(); + clickEvent.stopPropagation(); + }, [])} + color="ghost" + size="s" + iconType="arrowDown" + iconSide="right" + tabIndex={-1} + > + {i18n.translate('xpack.endpoint.resolver.relatedEvents', { + defaultMessage: 'Events', + })} + + ); +}); + +const RelatedAlertsButton = React.memo(() => { + return ( + ) => { + clickEvent.preventDefault(); + clickEvent.stopPropagation(); + }, [])} + color="ghost" + size="s" + tabIndex={-1} + > + {i18n.translate('xpack.endpoint.resolver.relatedAlerts', { + defaultMessage: 'Related Alerts', + })} + + ); +}); + /** - * A placeholder view for a process node. + * An artefact that represents a process node. */ export const ProcessEventDot = styled( React.memo( @@ -184,6 +228,7 @@ export const ProcessEventDot = styled( }, [animationTarget, dispatch, nodeId] ); + /* eslint-disable jsx-a11y/click-events-have-key-events */ /** * Key event handling (e.g. 'Enter'/'Space') is provisioned by the `EuiKeyboardAccessible` component @@ -256,13 +301,17 @@ export const ProcessEventDot = styled(
{descriptionText}
= 2 ? 'euiButton' : 'euiButton euiButton--small'} data-test-subject="nodeLabel" id={labelId} style={{ backgroundColor: labelBackground, - padding: '.15em 0', + padding: '.15rem 0', textAlign: 'center', - maxWidth: '100%', + maxWidth: '20rem', + minWidth: '12rem', + width: '60%', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis', contain: 'content', + margin: '.25rem 0 .35rem 0', }} > - {eventModel.eventName(event)} + + {eventModel.eventName(event)} +
+ {magFactorX >= 2 && ( + + + + + + + + + )}
@@ -317,6 +383,8 @@ export const ProcessEventDot = styled( white-space: nowrap; will-change: left, top, width, height; contain: strict; + min-width: 280px; + min-height: 90px; //dasharray & dashoffset should be equal to "pull" the stroke back //when it is transitioned. diff --git a/x-pack/plugins/endpoint/scripts/resolver_generator.ts b/x-pack/plugins/endpoint/scripts/resolver_generator.ts index 333846bde6ce4..2129bef0624b8 100644 --- a/x-pack/plugins/endpoint/scripts/resolver_generator.ts +++ b/x-pack/plugins/endpoint/scripts/resolver_generator.ts @@ -29,7 +29,7 @@ async function main() { alertIndex: { alias: 'ai', describe: 'index to store alerts in', - default: '.alerts-endpoint-000001', + default: 'events-endpoint-1', type: 'string', }, eventIndex: { @@ -41,7 +41,7 @@ async function main() { metadataIndex: { alias: 'mi', describe: 'index to store host metadata in', - default: 'endpoint-agent-1', + default: 'metrics-endpoint-default-1', type: 'string', }, auth: { diff --git a/x-pack/plugins/endpoint/server/index_pattern.ts b/x-pack/plugins/endpoint/server/index_pattern.ts new file mode 100644 index 0000000000000..ea612bfd75441 --- /dev/null +++ b/x-pack/plugins/endpoint/server/index_pattern.ts @@ -0,0 +1,77 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { Logger, LoggerFactory, RequestHandlerContext } from 'kibana/server'; +import { ESIndexPatternService } from '../../ingest_manager/server'; +import { EndpointAppConstants } from '../common/types'; + +export interface IndexPatternRetriever { + getIndexPattern(ctx: RequestHandlerContext, datasetPath: string): Promise; + getEventIndexPattern(ctx: RequestHandlerContext): Promise; + getMetadataIndexPattern(ctx: RequestHandlerContext): Promise; +} + +/** + * This class is used to retrieve an index pattern. It should be used in the server side code whenever + * an index pattern is needed to query data within ES. The index pattern is constructed by the Ingest Manager + * based on the contents of the Endpoint Package in the Package Registry. + */ +export class IngestIndexPatternRetriever implements IndexPatternRetriever { + private static endpointPackageName = 'endpoint'; + private static metadataDataset = 'metadata'; + private readonly log: Logger; + constructor(private readonly service: ESIndexPatternService, loggerFactory: LoggerFactory) { + this.log = loggerFactory.get('index-pattern-retriever'); + } + + /** + * Retrieves the index pattern for querying events within elasticsearch. + * + * @param ctx a RequestHandlerContext from a route handler + * @returns a string representing the index pattern (e.g. `events-endpoint-*`) + */ + async getEventIndexPattern(ctx: RequestHandlerContext) { + return await this.getIndexPattern(ctx, EndpointAppConstants.EVENT_DATASET); + } + + /** + * Retrieves the index pattern for querying endpoint metadata within elasticsearch. + * + * @param ctx a RequestHandlerContext from a route handler + * @returns a string representing the index pattern (e.g. `metrics-endpoint-*`) + */ + async getMetadataIndexPattern(ctx: RequestHandlerContext) { + return await this.getIndexPattern(ctx, IngestIndexPatternRetriever.metadataDataset); + } + + /** + * Retrieves the index pattern for a specific dataset for querying endpoint data. + * + * @param ctx a RequestHandlerContext from a route handler + * @param datasetPath a string of the path being used for a dataset within the Endpoint Package + * (e.g. `events`, `metadata`) + * @returns a string representing the index pattern (e.g. `metrics-endpoint-*`) + */ + async getIndexPattern(ctx: RequestHandlerContext, datasetPath: string) { + try { + const pattern = await this.service.getESIndexPattern( + ctx.core.savedObjects.client, + IngestIndexPatternRetriever.endpointPackageName, + datasetPath + ); + + if (!pattern) { + const msg = `Unable to retrieve the index pattern for dataset: ${datasetPath}`; + this.log.warn(msg); + throw new Error(msg); + } + return pattern; + } catch (error) { + const errMsg = `Error occurred while retrieving pattern for: ${datasetPath} error: ${error}`; + this.log.warn(errMsg); + throw new Error(errMsg); + } + } +} diff --git a/x-pack/plugins/endpoint/server/mocks.ts b/x-pack/plugins/endpoint/server/mocks.ts new file mode 100644 index 0000000000000..903aa19cd8843 --- /dev/null +++ b/x-pack/plugins/endpoint/server/mocks.ts @@ -0,0 +1,44 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +/** + * Creates a mock IndexPatternRetriever for use in tests. + * + * @param indexPattern a string index pattern to return when any of the mock's public methods are called. + * @returns the same string passed in via `indexPattern` + */ +export const createMockIndexPatternRetriever = (indexPattern: string) => { + const mockGetFunc = jest.fn().mockResolvedValue(indexPattern); + return { + getIndexPattern: mockGetFunc, + getEventIndexPattern: mockGetFunc, + getMetadataIndexPattern: mockGetFunc, + }; +}; + +export const MetadataIndexPattern = 'metrics-endpoint-*'; + +/** + * Creates a mock IndexPatternRetriever for use in tests that returns `metrics-endpoint-*` + */ +export const createMockMetadataIndexPatternRetriever = () => { + return createMockIndexPatternRetriever(MetadataIndexPattern); +}; + +/** + * Creates a mock IndexPatternService for use in tests that need to interact with the Ingest Manager's + * ESIndexPatternService. + * + * @param indexPattern a string index pattern to return when called by a test + * @returns the same value as `indexPattern` parameter + */ +export const createMockIndexPatternService = (indexPattern: string) => { + return { + esIndexPatternService: { + getESIndexPattern: jest.fn().mockResolvedValue(indexPattern), + }, + }; +}; diff --git a/x-pack/plugins/endpoint/server/plugin.test.ts b/x-pack/plugins/endpoint/server/plugin.test.ts index 7dd878d579043..8d55e64f16dcf 100644 --- a/x-pack/plugins/endpoint/server/plugin.test.ts +++ b/x-pack/plugins/endpoint/server/plugin.test.ts @@ -7,6 +7,7 @@ import { EndpointPlugin, EndpointPluginSetupDependencies } from './plugin'; import { coreMock } from '../../../../src/core/server/mocks'; import { PluginSetupContract } from '../../features/server'; +import { createMockIndexPatternService } from './mocks'; describe('test endpoint plugin', () => { let plugin: EndpointPlugin; @@ -28,7 +29,10 @@ describe('test endpoint plugin', () => { getFeaturesUICapabilities: jest.fn(), registerLegacyAPI: jest.fn(), }; - mockedEndpointPluginSetupDependencies = { features: mockedPluginSetupContract }; + mockedEndpointPluginSetupDependencies = { + features: mockedPluginSetupContract, + ingestManager: createMockIndexPatternService(''), + }; }); it('test properly setup plugin', async () => { diff --git a/x-pack/plugins/endpoint/server/plugin.ts b/x-pack/plugins/endpoint/server/plugin.ts index d3a399124124f..6a42014e91130 100644 --- a/x-pack/plugins/endpoint/server/plugin.ts +++ b/x-pack/plugins/endpoint/server/plugin.ts @@ -6,12 +6,15 @@ import { Plugin, CoreSetup, PluginInitializerContext, Logger } from 'kibana/server'; import { first } from 'rxjs/operators'; import { PluginSetupContract as FeaturesPluginSetupContract } from '../../features/server'; +import { IngestManagerSetupContract } from '../../ingest_manager/server'; import { createConfig$, EndpointConfigType } from './config'; import { EndpointAppContext } from './types'; import { registerAlertRoutes } from './routes/alerts'; import { registerResolverRoutes } from './routes/resolver'; +import { registerIndexPatternRoute } from './routes/index_pattern'; import { registerEndpointRoutes } from './routes/metadata'; +import { IngestIndexPatternRetriever } from './index_pattern'; export type EndpointPluginStart = void; export type EndpointPluginSetup = void; @@ -19,6 +22,7 @@ export interface EndpointPluginStartDependencies {} // eslint-disable-line @type export interface EndpointPluginSetupDependencies { features: FeaturesPluginSetupContract; + ingestManager: IngestManagerSetupContract; } export class EndpointPlugin @@ -62,6 +66,10 @@ export class EndpointPlugin }, }); const endpointContext = { + indexPatternRetriever: new IngestIndexPatternRetriever( + plugins.ingestManager.esIndexPatternService, + this.initializerContext.logger + ), logFactory: this.initializerContext.logger, config: (): Promise => { return createConfig$(this.initializerContext) @@ -73,6 +81,7 @@ export class EndpointPlugin registerEndpointRoutes(router, endpointContext); registerResolverRoutes(router, endpointContext); registerAlertRoutes(router, endpointContext); + registerIndexPatternRoute(router, endpointContext); } public start() { diff --git a/x-pack/plugins/endpoint/server/routes/alerts/alerts.test.ts b/x-pack/plugins/endpoint/server/routes/alerts/alerts.test.ts index 5f5e4be4ecd0a..6be7b26898206 100644 --- a/x-pack/plugins/endpoint/server/routes/alerts/alerts.test.ts +++ b/x-pack/plugins/endpoint/server/routes/alerts/alerts.test.ts @@ -12,6 +12,7 @@ import { import { registerAlertRoutes } from './index'; import { EndpointConfigSchema } from '../../config'; import { alertingIndexGetQuerySchema } from '../../../common/schema/alert_index'; +import { createMockIndexPatternRetriever } from '../../mocks'; describe('test alerts route', () => { let routerMock: jest.Mocked; @@ -24,6 +25,7 @@ describe('test alerts route', () => { mockClusterClient.asScoped.mockReturnValue(mockScopedClient); routerMock = httpServiceMock.createRouter(); registerAlertRoutes(routerMock, { + indexPatternRetriever: createMockIndexPatternRetriever('events-endpoint-*'), logFactory: loggingServiceMock.create(), config: () => Promise.resolve(EndpointConfigSchema.validate({})), }); diff --git a/x-pack/plugins/endpoint/server/routes/alerts/details/handlers.ts b/x-pack/plugins/endpoint/server/routes/alerts/details/handlers.ts index 0f32deb4fad9b..86e9f55da5697 100644 --- a/x-pack/plugins/endpoint/server/routes/alerts/details/handlers.ts +++ b/x-pack/plugins/endpoint/server/routes/alerts/details/handlers.ts @@ -26,15 +26,18 @@ export const alertDetailsHandlerWrapper = function( id: alertId, })) as GetResponse; + const indexPattern = await endpointAppContext.indexPatternRetriever.getEventIndexPattern(ctx); + const config = await endpointAppContext.config(); const pagination: AlertDetailsPagination = new AlertDetailsPagination( config, ctx, req.params, - response + response, + indexPattern ); - const currentHostInfo = await getHostData(ctx, response._source.host.id); + const currentHostInfo = await getHostData(ctx, response._source.host.id, indexPattern); return res.ok({ body: { diff --git a/x-pack/plugins/endpoint/server/routes/alerts/details/lib/pagination.ts b/x-pack/plugins/endpoint/server/routes/alerts/details/lib/pagination.ts index 446d61080e650..d482da03872c6 100644 --- a/x-pack/plugins/endpoint/server/routes/alerts/details/lib/pagination.ts +++ b/x-pack/plugins/endpoint/server/routes/alerts/details/lib/pagination.ts @@ -29,7 +29,8 @@ export class AlertDetailsPagination extends Pagination< config: EndpointConfigType, requestContext: RequestHandlerContext, state: AlertDetailsRequestParams, - data: GetResponse + data: GetResponse, + private readonly indexPattern: string ) { super(config, requestContext, state, data); } @@ -54,7 +55,8 @@ export class AlertDetailsPagination extends Pagination< const response = await searchESForAlerts( this.requestContext.core.elasticsearch.dataClient, - reqData + reqData, + this.indexPattern ); return response; } diff --git a/x-pack/plugins/endpoint/server/routes/alerts/lib/index.ts b/x-pack/plugins/endpoint/server/routes/alerts/lib/index.ts index dc1ce767a715b..74db24c85eab5 100644 --- a/x-pack/plugins/endpoint/server/routes/alerts/lib/index.ts +++ b/x-pack/plugins/endpoint/server/routes/alerts/lib/index.ts @@ -97,7 +97,8 @@ function buildSort(query: AlertSearchQuery): AlertSort { * Builds a request body for Elasticsearch, given a set of query params. **/ const buildAlertSearchQuery = async ( - query: AlertSearchQuery + query: AlertSearchQuery, + indexPattern: string ): Promise => { let totalHitsMin: number = EndpointAppConstants.DEFAULT_TOTAL_HITS; @@ -125,7 +126,7 @@ const buildAlertSearchQuery = async ( const reqWrapper: AlertSearchRequestWrapper = { size: query.pageSize, - index: EndpointAppConstants.ALERT_INDEX_NAME, + index: indexPattern, body: reqBody, }; @@ -141,9 +142,10 @@ const buildAlertSearchQuery = async ( **/ export const searchESForAlerts = async ( dataClient: IScopedClusterClient, - query: AlertSearchQuery + query: AlertSearchQuery, + indexPattern: string ): Promise> => { - const reqWrapper = await buildAlertSearchQuery(query); + const reqWrapper = await buildAlertSearchQuery(query, indexPattern); const response = (await dataClient.callAsCurrentUser('search', reqWrapper)) as SearchResponse< AlertEvent >; diff --git a/x-pack/plugins/endpoint/server/routes/alerts/list/handlers.ts b/x-pack/plugins/endpoint/server/routes/alerts/list/handlers.ts index 93ec8d7aa3e67..f23dffd13db4f 100644 --- a/x-pack/plugins/endpoint/server/routes/alerts/list/handlers.ts +++ b/x-pack/plugins/endpoint/server/routes/alerts/list/handlers.ts @@ -18,8 +18,13 @@ export const alertListHandlerWrapper = function( res ) => { try { + const indexPattern = await endpointAppContext.indexPatternRetriever.getEventIndexPattern(ctx); const reqData = await getRequestData(req, endpointAppContext); - const response = await searchESForAlerts(ctx.core.elasticsearch.dataClient, reqData); + const response = await searchESForAlerts( + ctx.core.elasticsearch.dataClient, + reqData, + indexPattern + ); const mappedBody = await mapToAlertResultList(ctx, endpointAppContext, reqData, response); return res.ok({ body: mappedBody }); } catch (err) { diff --git a/x-pack/plugins/endpoint/server/routes/index_pattern.ts b/x-pack/plugins/endpoint/server/routes/index_pattern.ts new file mode 100644 index 0000000000000..3b71f6a6957ba --- /dev/null +++ b/x-pack/plugins/endpoint/server/routes/index_pattern.ts @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { IRouter, Logger, RequestHandler } from 'kibana/server'; +import { EndpointAppContext } from '../types'; +import { IndexPatternGetParamsResult, EndpointAppConstants } from '../../common/types'; +import { indexPatternGetParamsSchema } from '../../common/schema/index_pattern'; +import { IndexPatternRetriever } from '../index_pattern'; + +function handleIndexPattern( + log: Logger, + indexRetriever: IndexPatternRetriever +): RequestHandler { + return async (context, req, res) => { + try { + return res.ok({ + body: { + indexPattern: await indexRetriever.getIndexPattern(context, req.params.datasetPath), + }, + }); + } catch (error) { + log.warn(error); + return res.notFound({ body: error }); + } + }; +} + +export function registerIndexPatternRoute(router: IRouter, endpointAppContext: EndpointAppContext) { + const log = endpointAppContext.logFactory.get('index_pattern'); + + router.get( + { + path: `${EndpointAppConstants.INDEX_PATTERN_ROUTE}/{datasetPath}`, + validate: { params: indexPatternGetParamsSchema }, + options: { authRequired: true }, + }, + handleIndexPattern(log, endpointAppContext.indexPatternRetriever) + ); +} diff --git a/x-pack/plugins/endpoint/server/routes/metadata/index.ts b/x-pack/plugins/endpoint/server/routes/metadata/index.ts index 450469914bc50..883bb88204fd4 100644 --- a/x-pack/plugins/endpoint/server/routes/metadata/index.ts +++ b/x-pack/plugins/endpoint/server/routes/metadata/index.ts @@ -8,9 +8,9 @@ import { IRouter, RequestHandlerContext } from 'kibana/server'; import { SearchResponse } from 'elasticsearch'; import { schema } from '@kbn/config-schema'; +import { kibanaRequestToMetadataListESQuery, getESQueryHostMetadataByID } from './query_builders'; import { HostInfo, HostMetadata, HostResultList, HostStatus } from '../../../common/types'; import { EndpointAppContext } from '../../types'; -import { getESQueryHostMetadataByID, kibanaRequestToMetadataListESQuery } from './query_builders'; interface HitSource { _source: HostMetadata; @@ -50,7 +50,14 @@ export function registerEndpointRoutes(router: IRouter, endpointAppContext: Endp }, async (context, req, res) => { try { - const queryParams = await kibanaRequestToMetadataListESQuery(req, endpointAppContext); + const index = await endpointAppContext.indexPatternRetriever.getMetadataIndexPattern( + context + ); + const queryParams = await kibanaRequestToMetadataListESQuery( + req, + endpointAppContext, + index + ); const response = (await context.core.elasticsearch.dataClient.callAsCurrentUser( 'search', queryParams @@ -72,7 +79,11 @@ export function registerEndpointRoutes(router: IRouter, endpointAppContext: Endp }, async (context, req, res) => { try { - const doc = await getHostData(context, req.params.id); + const index = await endpointAppContext.indexPatternRetriever.getMetadataIndexPattern( + context + ); + + const doc = await getHostData(context, req.params.id, index); if (doc) { return res.ok({ body: doc }); } @@ -86,9 +97,10 @@ export function registerEndpointRoutes(router: IRouter, endpointAppContext: Endp export async function getHostData( context: RequestHandlerContext, - id: string + id: string, + index: string ): Promise { - const query = getESQueryHostMetadataByID(id); + const query = getESQueryHostMetadataByID(id, index); const response = (await context.core.elasticsearch.dataClient.callAsCurrentUser( 'search', query diff --git a/x-pack/plugins/endpoint/server/routes/metadata/metadata.test.ts b/x-pack/plugins/endpoint/server/routes/metadata/metadata.test.ts index 9bd251735cc04..9a7d3fb3188a6 100644 --- a/x-pack/plugins/endpoint/server/routes/metadata/metadata.test.ts +++ b/x-pack/plugins/endpoint/server/routes/metadata/metadata.test.ts @@ -11,24 +11,28 @@ import { RequestHandler, RequestHandlerContext, RouteConfig, + SavedObjectsClientContract, } from 'kibana/server'; import { elasticsearchServiceMock, httpServerMock, httpServiceMock, loggingServiceMock, + savedObjectsClientMock, } from '../../../../../../src/core/server/mocks'; import { HostInfo, HostMetadata, HostResultList, HostStatus } from '../../../common/types'; import { SearchResponse } from 'elasticsearch'; +import { registerEndpointRoutes } from './index'; import { EndpointConfigSchema } from '../../config'; import * as data from '../../test_data/all_metadata_data.json'; -import { registerEndpointRoutes } from './index'; +import { createMockMetadataIndexPatternRetriever } from '../../mocks'; describe('test endpoint route', () => { let routerMock: jest.Mocked; let mockResponse: jest.Mocked; let mockClusterClient: jest.Mocked; let mockScopedClient: jest.Mocked; + let mockSavedObjectClient: jest.Mocked; let routeHandler: RequestHandler; let routeConfig: RouteConfig; @@ -37,15 +41,38 @@ describe('test endpoint route', () => { IClusterClient >; mockScopedClient = elasticsearchServiceMock.createScopedClusterClient(); + mockSavedObjectClient = savedObjectsClientMock.create(); mockClusterClient.asScoped.mockReturnValue(mockScopedClient); routerMock = httpServiceMock.createRouter(); mockResponse = httpServerMock.createResponseFactory(); registerEndpointRoutes(routerMock, { + indexPatternRetriever: createMockMetadataIndexPatternRetriever(), logFactory: loggingServiceMock.create(), config: () => Promise.resolve(EndpointConfigSchema.validate({})), }); }); + function createRouteHandlerContext( + dataClient: jest.Mocked, + savedObjectsClient: jest.Mocked + ) { + return ({ + core: { + elasticsearch: { + dataClient, + }, + savedObjects: { + client: savedObjectsClient, + }, + }, + /** + * Using unknown here because the object defined is not a full `RequestHandlerContext`. We don't + * need all of the fields required to run the tests, but the `routeHandler` function requires a + * `RequestHandlerContext`. + */ + } as unknown) as RequestHandlerContext; + } + it('test find the latest of all endpoints', async () => { const mockRequest = httpServerMock.createKibanaRequest({}); @@ -58,13 +85,7 @@ describe('test endpoint route', () => { )!; await routeHandler( - ({ - core: { - elasticsearch: { - dataClient: mockScopedClient, - }, - }, - } as unknown) as RequestHandlerContext, + createRouteHandlerContext(mockScopedClient, mockSavedObjectClient), mockRequest, mockResponse ); @@ -100,13 +121,7 @@ describe('test endpoint route', () => { )!; await routeHandler( - ({ - core: { - elasticsearch: { - dataClient: mockScopedClient, - }, - }, - } as unknown) as RequestHandlerContext, + createRouteHandlerContext(mockScopedClient, mockSavedObjectClient), mockRequest, mockResponse ); @@ -147,13 +162,7 @@ describe('test endpoint route', () => { )!; await routeHandler( - ({ - core: { - elasticsearch: { - dataClient: mockScopedClient, - }, - }, - } as unknown) as RequestHandlerContext, + createRouteHandlerContext(mockScopedClient, mockSavedObjectClient), mockRequest, mockResponse ); @@ -212,13 +221,7 @@ describe('test endpoint route', () => { )!; await routeHandler( - ({ - core: { - elasticsearch: { - dataClient: mockScopedClient, - }, - }, - } as unknown) as RequestHandlerContext, + createRouteHandlerContext(mockScopedClient, mockSavedObjectClient), mockRequest, mockResponse ); @@ -243,13 +246,7 @@ describe('test endpoint route', () => { )!; await routeHandler( - ({ - core: { - elasticsearch: { - dataClient: mockScopedClient, - }, - }, - } as unknown) as RequestHandlerContext, + createRouteHandlerContext(mockScopedClient, mockSavedObjectClient), mockRequest, mockResponse ); diff --git a/x-pack/plugins/endpoint/server/routes/metadata/query_builders.test.ts b/x-pack/plugins/endpoint/server/routes/metadata/query_builders.test.ts index 2514d5aa85811..c8143fbdda1ea 100644 --- a/x-pack/plugins/endpoint/server/routes/metadata/query_builders.test.ts +++ b/x-pack/plugins/endpoint/server/routes/metadata/query_builders.test.ts @@ -6,7 +6,7 @@ import { httpServerMock, loggingServiceMock } from '../../../../../../src/core/server/mocks'; import { EndpointConfigSchema } from '../../config'; import { kibanaRequestToMetadataListESQuery, getESQueryHostMetadataByID } from './query_builders'; -import { EndpointAppConstants } from '../../../common/types'; +import { createMockMetadataIndexPatternRetriever, MetadataIndexPattern } from '../../mocks'; describe('query builder', () => { describe('MetadataListESQuery', () => { @@ -14,17 +14,22 @@ describe('query builder', () => { const mockRequest = httpServerMock.createKibanaRequest({ body: {}, }); - const query = await kibanaRequestToMetadataListESQuery(mockRequest, { - logFactory: loggingServiceMock.create(), - config: () => Promise.resolve(EndpointConfigSchema.validate({})), - }); + const query = await kibanaRequestToMetadataListESQuery( + mockRequest, + { + indexPatternRetriever: createMockMetadataIndexPatternRetriever(), + logFactory: loggingServiceMock.create(), + config: () => Promise.resolve(EndpointConfigSchema.validate({})), + }, + MetadataIndexPattern + ); expect(query).toEqual({ body: { query: { match_all: {}, }, collapse: { - field: 'host.id.keyword', + field: 'host.id', inner_hits: { name: 'most_recent', size: 1, @@ -34,7 +39,7 @@ describe('query builder', () => { aggs: { total: { cardinality: { - field: 'host.id.keyword', + field: 'host.id', }, }, }, @@ -48,7 +53,7 @@ describe('query builder', () => { }, from: 0, size: 10, - index: EndpointAppConstants.ENDPOINT_INDEX_NAME, + index: MetadataIndexPattern, } as Record); }); }); @@ -60,10 +65,15 @@ describe('query builder', () => { filter: 'not host.ip:10.140.73.246', }, }); - const query = await kibanaRequestToMetadataListESQuery(mockRequest, { - logFactory: loggingServiceMock.create(), - config: () => Promise.resolve(EndpointConfigSchema.validate({})), - }); + const query = await kibanaRequestToMetadataListESQuery( + mockRequest, + { + indexPatternRetriever: createMockMetadataIndexPatternRetriever(), + logFactory: loggingServiceMock.create(), + config: () => Promise.resolve(EndpointConfigSchema.validate({})), + }, + MetadataIndexPattern + ); expect(query).toEqual({ body: { query: { @@ -83,7 +93,7 @@ describe('query builder', () => { }, }, collapse: { - field: 'host.id.keyword', + field: 'host.id', inner_hits: { name: 'most_recent', size: 1, @@ -93,7 +103,7 @@ describe('query builder', () => { aggs: { total: { cardinality: { - field: 'host.id.keyword', + field: 'host.id', }, }, }, @@ -107,7 +117,7 @@ describe('query builder', () => { }, from: 0, size: 10, - index: EndpointAppConstants.ENDPOINT_INDEX_NAME, + index: MetadataIndexPattern, } as Record); }); }); @@ -115,14 +125,15 @@ describe('query builder', () => { describe('MetadataGetQuery', () => { it('searches for the correct ID', () => { const mockID = 'AABBCCDD-0011-2233-AA44-DEADBEEF8899'; - const query = getESQueryHostMetadataByID(mockID); + const query = getESQueryHostMetadataByID(mockID, MetadataIndexPattern); + expect(query).toEqual({ body: { - query: { match: { 'host.id.keyword': mockID } }, + query: { match: { 'host.id': mockID } }, sort: [{ 'event.created': { order: 'desc' } }], size: 1, }, - index: EndpointAppConstants.ENDPOINT_INDEX_NAME, + index: MetadataIndexPattern, }); }); }); diff --git a/x-pack/plugins/endpoint/server/routes/metadata/query_builders.ts b/x-pack/plugins/endpoint/server/routes/metadata/query_builders.ts index bd07604fe9ad2..abcc293985f9f 100644 --- a/x-pack/plugins/endpoint/server/routes/metadata/query_builders.ts +++ b/x-pack/plugins/endpoint/server/routes/metadata/query_builders.ts @@ -6,18 +6,18 @@ import { KibanaRequest } from 'kibana/server'; import { esKuery } from '../../../../../../src/plugins/data/server'; import { EndpointAppContext } from '../../types'; -import { EndpointAppConstants } from '../../../common/types'; export const kibanaRequestToMetadataListESQuery = async ( request: KibanaRequest, - endpointAppContext: EndpointAppContext + endpointAppContext: EndpointAppContext, + index: string ): Promise> => { const pagingProperties = await getPagingProperties(request, endpointAppContext); return { body: { query: buildQueryBody(request), collapse: { - field: 'host.id.keyword', + field: 'host.id', inner_hits: { name: 'most_recent', size: 1, @@ -27,7 +27,7 @@ export const kibanaRequestToMetadataListESQuery = async ( aggs: { total: { cardinality: { - field: 'host.id.keyword', + field: 'host.id', }, }, }, @@ -41,7 +41,7 @@ export const kibanaRequestToMetadataListESQuery = async ( }, from: pagingProperties.pageIndex * pagingProperties.pageSize, size: pagingProperties.pageSize, - index: EndpointAppConstants.ENDPOINT_INDEX_NAME, + index, }; }; @@ -74,12 +74,12 @@ function buildQueryBody(request: KibanaRequest): Record { return async (context, req, res) => { const { @@ -54,10 +56,11 @@ export function handleChildren( } = req; try { const pagination = getPaginationParams(limit, after); + const indexPattern = await indexRetriever.getEventIndexPattern(context); const client = context.core.elasticsearch.dataClient; - const childrenQuery = new ChildrenQuery(legacyEndpointID, pagination); - const lifecycleQuery = new LifecycleQuery(legacyEndpointID); + const childrenQuery = new ChildrenQuery(indexPattern, legacyEndpointID, pagination); + const lifecycleQuery = new LifecycleQuery(indexPattern, legacyEndpointID); // Retrieve the related child process events for a given process const { total, results: events, nextCursor } = await childrenQuery.search(client, id); diff --git a/x-pack/plugins/endpoint/server/routes/resolver/lifecycle.ts b/x-pack/plugins/endpoint/server/routes/resolver/lifecycle.ts index 9895344174014..6d155b79651a7 100644 --- a/x-pack/plugins/endpoint/server/routes/resolver/lifecycle.ts +++ b/x-pack/plugins/endpoint/server/routes/resolver/lifecycle.ts @@ -10,6 +10,7 @@ import { RequestHandler, Logger } from 'kibana/server'; import { extractParentEntityID } from './utils/normalize'; import { LifecycleQuery } from './queries/lifecycle'; import { ResolverEvent } from '../../../common/types'; +import { IndexPatternRetriever } from '../../index_pattern'; interface LifecycleQueryParams { ancestors: number; @@ -46,7 +47,8 @@ function getParentEntityID(results: ResolverEvent[]) { } export function handleLifecycle( - log: Logger + log: Logger, + indexRetriever: IndexPatternRetriever ): RequestHandler { return async (context, req, res) => { const { @@ -56,8 +58,8 @@ export function handleLifecycle( try { const ancestorLifecycles = []; const client = context.core.elasticsearch.dataClient; - - const lifecycleQuery = new LifecycleQuery(legacyEndpointID); + const indexPattern = await indexRetriever.getEventIndexPattern(context); + const lifecycleQuery = new LifecycleQuery(indexPattern, legacyEndpointID); const { results: processLifecycle } = await lifecycleQuery.search(client, id); let nextParentID = getParentEntityID(processLifecycle); diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/base.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/base.ts index be83efc39ca4c..b049439207e50 100644 --- a/x-pack/plugins/endpoint/server/routes/resolver/queries/base.ts +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/base.ts @@ -11,6 +11,7 @@ import { JsonObject } from '../../../../../../../src/plugins/kibana_utils/public export abstract class ResolverQuery { constructor( + private readonly indexPattern: string, private readonly endpointID?: string, private readonly pagination?: PaginationParams ) {} @@ -26,7 +27,7 @@ export abstract class ResolverQuery { if (this.endpointID) { return this.legacyQuery(this.endpointID, ids, EndpointAppConstants.LEGACY_EVENT_INDEX_NAME); } - return this.query(ids, EndpointAppConstants.EVENT_INDEX_NAME); + return this.query(ids, this.indexPattern); } async search(client: IScopedClusterClient, ...ids: string[]) { diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/children.test.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/children.test.ts index 08a906e2884d6..e73053d53dee0 100644 --- a/x-pack/plugins/endpoint/server/routes/resolver/queries/children.test.ts +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/children.test.ts @@ -6,11 +6,17 @@ import { ChildrenQuery } from './children'; import { EndpointAppConstants } from '../../../../common/types'; +export const fakeEventIndexPattern = 'events-endpoint-*'; + describe('children events query', () => { it('generates the correct legacy queries', () => { const timestamp = new Date().getTime(); expect( - new ChildrenQuery('awesome-id', { size: 1, timestamp, eventID: 'foo' }).build('5') + new ChildrenQuery(EndpointAppConstants.LEGACY_EVENT_INDEX_NAME, 'awesome-id', { + size: 1, + timestamp, + eventID: 'foo', + }).build('5') ).toStrictEqual({ body: { query: { @@ -50,7 +56,11 @@ describe('children events query', () => { const timestamp = new Date().getTime(); expect( - new ChildrenQuery(undefined, { size: 1, timestamp, eventID: 'bar' }).build('baz') + new ChildrenQuery(fakeEventIndexPattern, undefined, { + size: 1, + timestamp, + eventID: 'bar', + }).build('baz') ).toStrictEqual({ body: { query: { @@ -88,7 +98,7 @@ describe('children events query', () => { size: 1, sort: [{ '@timestamp': 'asc' }, { 'event.id': 'asc' }], }, - index: EndpointAppConstants.EVENT_INDEX_NAME, + index: fakeEventIndexPattern, }); }); }); diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.test.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.test.ts index b1b47bfb9de7f..8a3955706b278 100644 --- a/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.test.ts +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/lifecycle.test.ts @@ -5,10 +5,13 @@ */ import { EndpointAppConstants } from '../../../../common/types'; import { LifecycleQuery } from './lifecycle'; +import { fakeEventIndexPattern } from './children.test'; describe('lifecycle query', () => { it('generates the correct legacy queries', () => { - expect(new LifecycleQuery('awesome-id').build('5')).toStrictEqual({ + expect( + new LifecycleQuery(EndpointAppConstants.LEGACY_EVENT_INDEX_NAME, 'awesome-id').build('5') + ).toStrictEqual({ body: { query: { bool: { @@ -32,7 +35,7 @@ describe('lifecycle query', () => { }); it('generates the correct non-legacy queries', () => { - expect(new LifecycleQuery().build('baz')).toStrictEqual({ + expect(new LifecycleQuery(fakeEventIndexPattern).build('baz')).toStrictEqual({ body: { query: { bool: { @@ -57,7 +60,7 @@ describe('lifecycle query', () => { }, sort: [{ '@timestamp': 'asc' }], }, - index: EndpointAppConstants.EVENT_INDEX_NAME, + index: fakeEventIndexPattern, }); }); }); diff --git a/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.test.ts b/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.test.ts index a91c87274b8dd..5caef935ce621 100644 --- a/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.test.ts +++ b/x-pack/plugins/endpoint/server/routes/resolver/queries/related_events.test.ts @@ -5,12 +5,17 @@ */ import { RelatedEventsQuery } from './related_events'; import { EndpointAppConstants } from '../../../../common/types'; +import { fakeEventIndexPattern } from './children.test'; describe('related events query', () => { it('generates the correct legacy queries', () => { const timestamp = new Date().getTime(); expect( - new RelatedEventsQuery('awesome-id', { size: 1, timestamp, eventID: 'foo' }).build('5') + new RelatedEventsQuery(EndpointAppConstants.LEGACY_EVENT_INDEX_NAME, 'awesome-id', { + size: 1, + timestamp, + eventID: 'foo', + }).build('5') ).toStrictEqual({ body: { query: { @@ -51,7 +56,11 @@ describe('related events query', () => { const timestamp = new Date().getTime(); expect( - new RelatedEventsQuery(undefined, { size: 1, timestamp, eventID: 'bar' }).build('baz') + new RelatedEventsQuery(fakeEventIndexPattern, undefined, { + size: 1, + timestamp, + eventID: 'bar', + }).build('baz') ).toStrictEqual({ body: { query: { @@ -90,7 +99,7 @@ describe('related events query', () => { size: 1, sort: [{ '@timestamp': 'asc' }, { 'event.id': 'asc' }], }, - index: EndpointAppConstants.EVENT_INDEX_NAME, + index: fakeEventIndexPattern, }); }); }); diff --git a/x-pack/plugins/endpoint/server/routes/resolver/related_events.ts b/x-pack/plugins/endpoint/server/routes/resolver/related_events.ts index 804400522065c..46e205464f53c 100644 --- a/x-pack/plugins/endpoint/server/routes/resolver/related_events.ts +++ b/x-pack/plugins/endpoint/server/routes/resolver/related_events.ts @@ -8,6 +8,7 @@ import { schema } from '@kbn/config-schema'; import { RequestHandler, Logger } from 'kibana/server'; import { getPaginationParams } from './utils/pagination'; import { RelatedEventsQuery } from './queries/related_events'; +import { IndexPatternRetriever } from '../../index_pattern'; interface RelatedEventsQueryParams { after?: string; @@ -42,7 +43,8 @@ export const validateRelatedEvents = { }; export function handleRelatedEvents( - log: Logger + log: Logger, + indexRetriever: IndexPatternRetriever ): RequestHandler { return async (context, req, res) => { const { @@ -53,8 +55,9 @@ export function handleRelatedEvents( const pagination = getPaginationParams(limit, after); const client = context.core.elasticsearch.dataClient; + const indexPattern = await indexRetriever.getEventIndexPattern(context); // Retrieve the related non-process events for a given process - const relatedEventsQuery = new RelatedEventsQuery(legacyEndpointID, pagination); + const relatedEventsQuery = new RelatedEventsQuery(indexPattern, legacyEndpointID, pagination); const relatedEvents = await relatedEventsQuery.search(client, id); const { total, results: events, nextCursor } = relatedEvents; diff --git a/x-pack/plugins/endpoint/server/test_data/all_metadata_data.json b/x-pack/plugins/endpoint/server/test_data/all_metadata_data.json index 3c8486aa127ea..48952afb33f68 100644 --- a/x-pack/plugins/endpoint/server/test_data/all_metadata_data.json +++ b/x-pack/plugins/endpoint/server/test_data/all_metadata_data.json @@ -1,115 +1,109 @@ { - "took" : 343, - "timed_out" : false, - "_shards" : { - "total" : 1, - "successful" : 1, - "skipped" : 0, - "failed" : 0 + "took": 343, + "timed_out": false, + "_shards": { + "total": 1, + "successful": 1, + "skipped": 0, + "failed": 0 }, - "hits" : { - "total" : { - "value" : 4, - "relation" : "eq" + "hits": { + "total": { + "value": 4, + "relation": "eq" }, - "max_score" : null, - "hits" : [ + "max_score": null, + "hits": [ { - "_index" : "endpoint-agent", - "_id" : "WqVo1G8BYQH1gtPUgYkC", - "_score" : null, - "_source" : { - "@timestamp" : 1579816615336, - "event" : { - "created" : "2020-01-23T21:56:55.336Z" + "_index": "metadata-endpoint-default-1", + "_id": "WqVo1G8BYQH1gtPUgYkC", + "_score": null, + "_source": { + "@timestamp": 1579816615336, + "event": { + "created": "2020-01-23T21:56:55.336Z" }, "elastic": { "agent": { "id": "56a75650-3c8a-4e4f-ac17-6dd729c650e2" } }, - "endpoint" : { - "policy" : { - "id" : "C2A9093E-E289-4C0A-AA44-8C32A414FA7A" + "endpoint": { + "policy": { + "id": "C2A9093E-E289-4C0A-AA44-8C32A414FA7A" } }, - "agent" : { - "version" : "6.8.3", - "id" : "56a75650-3c8a-4e4f-ac17-6dd729c650e2", + "agent": { + "version": "6.8.3", + "id": "56a75650-3c8a-4e4f-ac17-6dd729c650e2", "name": "Elastic Endpoint" }, - "host" : { - "id" : "7141a48b-e19f-4ae3-89a0-6e7179a84265", - "hostname" : "larimer-0.example.com", - "ip" : "10.21.48.136", - "mac" : "77-be-30-f0-e8-d6", - "architecture" : "x86_64", - "os" : { - "name" : "windows 6.2", - "full" : "Windows Server 2012", - "version" : "6.2", - "variant" : "Windows Server" + "host": { + "id": "7141a48b-e19f-4ae3-89a0-6e7179a84265", + "hostname": "larimer-0.example.com", + "ip": "10.21.48.136", + "mac": "77-be-30-f0-e8-d6", + "architecture": "x86_64", + "os": { + "name": "windows 6.2", + "full": "Windows Server 2012", + "version": "6.2", + "variant": "Windows Server" } } }, - "fields" : { - "host.id.keyword" : [ - "7141a48b-e19f-4ae3-89a0-6e7179a84265" - ] + "fields": { + "host.id.keyword": ["7141a48b-e19f-4ae3-89a0-6e7179a84265"] }, - "sort" : [ - 1579816615336 - ], - "inner_hits" : { - "most_recent" : { - "hits" : { - "total" : { - "value" : 2, - "relation" : "eq" + "sort": [1579816615336], + "inner_hits": { + "most_recent": { + "hits": { + "total": { + "value": 2, + "relation": "eq" }, - "max_score" : null, - "hits" : [ + "max_score": null, + "hits": [ { - "_index" : "endpoint-agent", - "_id" : "WqVo1G8BYQH1gtPUgYkC", - "_score" : null, - "_source" : { - "@timestamp" : 1579816615336, - "event" : { - "created" : "2020-01-23T21:56:55.336Z" + "_index": "metadata-endpoint-default-1", + "_id": "WqVo1G8BYQH1gtPUgYkC", + "_score": null, + "_source": { + "@timestamp": 1579816615336, + "event": { + "created": "2020-01-23T21:56:55.336Z" }, "elastic": { "agent": { "id": "56a75650-3c8a-4e4f-ac17-6dd729c650e2" } }, - "endpoint" : { - "policy" : { - "id" : "C2A9093E-E289-4C0A-AA44-8C32A414FA7A" + "endpoint": { + "policy": { + "id": "C2A9093E-E289-4C0A-AA44-8C32A414FA7A" } }, - "agent" : { - "version" : "6.8.3", - "id" : "56a75650-3c8a-4e4f-ac17-6dd729c650e2", + "agent": { + "version": "6.8.3", + "id": "56a75650-3c8a-4e4f-ac17-6dd729c650e2", "name": "Elastic Endpoint" }, - "host" : { - "id" : "7141a48b-e19f-4ae3-89a0-6e7179a84265", - "hostname" : "larimer-0.example.com", - "ip" : "10.21.48.136", - "mac" : "77-be-30-f0-e8-d6", - "architecture" : "x86_64", - "os" : { - "name" : "windows 6.2", - "full" : "Windows Server 2012", - "version" : "6.2", - "variant" : "Windows Server" + "host": { + "id": "7141a48b-e19f-4ae3-89a0-6e7179a84265", + "hostname": "larimer-0.example.com", + "ip": "10.21.48.136", + "mac": "77-be-30-f0-e8-d6", + "architecture": "x86_64", + "os": { + "name": "windows 6.2", + "full": "Windows Server 2012", + "version": "6.2", + "variant": "Windows Server" } } }, - "sort" : [ - 1579816615336 - ] + "sort": [1579816615336] } ] } @@ -117,101 +111,95 @@ } }, { - "_index" : "endpoint-agent", - "_id" : "W6Vo1G8BYQH1gtPUgYkC", - "_score" : null, - "_source" : { - "@timestamp" : 1579816615336, - "event" : { - "created" : "2020-01-23T21:56:55.336Z" + "_index": "metadata-endpoint-default-1", + "_id": "W6Vo1G8BYQH1gtPUgYkC", + "_score": null, + "_source": { + "@timestamp": 1579816615336, + "event": { + "created": "2020-01-23T21:56:55.336Z" }, "elastic": { "agent": { "id": "c2d84d8f-d355-40de-8b54-5d318d4d1312" } }, - "endpoint" : { - "policy" : { - "id" : "C2A9093E-E289-4C0A-AA44-8C32A414FA7A" + "endpoint": { + "policy": { + "id": "C2A9093E-E289-4C0A-AA44-8C32A414FA7A" } }, - "agent" : { - "version" : "6.4.3", - "id" : "c2d84d8f-d355-40de-8b54-5d318d4d1312", + "agent": { + "version": "6.4.3", + "id": "c2d84d8f-d355-40de-8b54-5d318d4d1312", "name": "Elastic Endpoint" }, - "host" : { - "id" : "f35ec6c1-6562-45b1-818f-2f14c0854adf", - "hostname" : "hildebrandt-6.example.com", - "ip" : "10.53.92.84", - "mac" : "af-f1-8f-51-25-2a", - "architecture" : "x86_64", - "os" : { - "name" : "windows 10.0", - "full" : "Windows 10", - "version" : "10.0", - "variant" : "Windows Pro" + "host": { + "id": "f35ec6c1-6562-45b1-818f-2f14c0854adf", + "hostname": "hildebrandt-6.example.com", + "ip": "10.53.92.84", + "mac": "af-f1-8f-51-25-2a", + "architecture": "x86_64", + "os": { + "name": "windows 10.0", + "full": "Windows 10", + "version": "10.0", + "variant": "Windows Pro" } } }, - "fields" : { - "host.id.keyword" : [ - "f35ec6c1-6562-45b1-818f-2f14c0854adf" - ] + "fields": { + "host.id.keyword": ["f35ec6c1-6562-45b1-818f-2f14c0854adf"] }, - "sort" : [ - 1579816615336 - ], - "inner_hits" : { - "most_recent" : { - "hits" : { - "total" : { - "value" : 2, - "relation" : "eq" + "sort": [1579816615336], + "inner_hits": { + "most_recent": { + "hits": { + "total": { + "value": 2, + "relation": "eq" }, - "max_score" : null, - "hits" : [ + "max_score": null, + "hits": [ { - "_index" : "endpoint-agent", - "_id" : "W6Vo1G8BYQH1gtPUgYkC", - "_score" : null, - "_source" : { - "@timestamp" : 1579816615336, - "event" : { - "created" : "2020-01-23T21:56:55.336Z" + "_index": "metadata-endpoint-default-1", + "_id": "W6Vo1G8BYQH1gtPUgYkC", + "_score": null, + "_source": { + "@timestamp": 1579816615336, + "event": { + "created": "2020-01-23T21:56:55.336Z" }, "elastic": { "agent": { "id": "c2d84d8f-d355-40de-8b54-5d318d4d1312" } }, - "endpoint" : { - "policy" : { - "id" : "C2A9093E-E289-4C0A-AA44-8C32A414FA7A" + "endpoint": { + "policy": { + "id": "C2A9093E-E289-4C0A-AA44-8C32A414FA7A" } }, - "agent" : { - "version" : "6.4.3", - "id" : "c2d84d8f-d355-40de-8b54-5d318d4d1312", + "agent": { + "version": "6.4.3", + "id": "c2d84d8f-d355-40de-8b54-5d318d4d1312", "name": "Elastic Endpoint" }, - "host" : { - "id" : "f35ec6c1-6562-45b1-818f-2f14c0854adf", - "hostname" : "hildebrandt-6.example.com", - "ip" : "10.53.92.84", - "mac" : "af-f1-8f-51-25-2a", - "architecture" : "x86_64", - "os" : { - "name" : "windows 10.0", - "full" : "Windows 10", - "version" : "10.0", - "variant" : "Windows Pro" + "host": { + "id": "f35ec6c1-6562-45b1-818f-2f14c0854adf", + "hostname": "hildebrandt-6.example.com", + "ip": "10.53.92.84", + "mac": "af-f1-8f-51-25-2a", + "architecture": "x86_64", + "os": { + "name": "windows 10.0", + "full": "Windows 10", + "version": "10.0", + "variant": "Windows Pro" } } }, - "sort" : [ - 1579816615336 - ] + "sort": [1579816615336] } ] } @@ -220,9 +208,9 @@ } ] }, - "aggregations" : { - "total" : { - "value" : 2 + "aggregations": { + "total": { + "value": 2 } } } diff --git a/x-pack/plugins/endpoint/server/types.ts b/x-pack/plugins/endpoint/server/types.ts index 6dc128bd3d61e..46a23060339f4 100644 --- a/x-pack/plugins/endpoint/server/types.ts +++ b/x-pack/plugins/endpoint/server/types.ts @@ -5,11 +5,13 @@ */ import { LoggerFactory } from 'kibana/server'; import { EndpointConfigType } from './config'; +import { IndexPatternRetriever } from './index_pattern'; /** * The context for Endpoint apps. */ export interface EndpointAppContext { + indexPatternRetriever: IndexPatternRetriever; logFactory: LoggerFactory; config(): Promise; } diff --git a/x-pack/plugins/event_log/server/es/context.mock.ts b/x-pack/plugins/event_log/server/es/context.mock.ts index 6581cd689e43d..c15fee803fb71 100644 --- a/x-pack/plugins/event_log/server/es/context.mock.ts +++ b/x-pack/plugins/event_log/server/es/context.mock.ts @@ -19,6 +19,7 @@ const createContextMock = () => { initialize: jest.fn(), waitTillReady: jest.fn(), esAdapter: clusterClientAdapterMock.create(), + initialized: true, }; return mock; }; diff --git a/x-pack/plugins/event_log/server/es/context.test.ts b/x-pack/plugins/event_log/server/es/context.test.ts new file mode 100644 index 0000000000000..09fe676a5762e --- /dev/null +++ b/x-pack/plugins/event_log/server/es/context.test.ts @@ -0,0 +1,95 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { createEsContext } from './context'; +import { ClusterClient, Logger } from '../../../../../src/core/server'; +import { elasticsearchServiceMock, loggingServiceMock } from '../../../../../src/core/server/mocks'; +jest.mock('../lib/../../../../package.json', () => ({ + version: '1.2.3', +})); +type EsClusterClient = Pick, 'callAsInternalUser' | 'asScoped'>; + +let logger: Logger; +let clusterClient: EsClusterClient; + +beforeEach(() => { + logger = loggingServiceMock.createLogger(); + clusterClient = elasticsearchServiceMock.createClusterClient(); +}); + +describe('createEsContext', () => { + test('should return is ready state as falsy if not initialized', () => { + const context = createEsContext({ + logger, + clusterClientPromise: Promise.resolve(clusterClient), + indexNameRoot: 'test0', + }); + + expect(context.initialized).toBeFalsy(); + + context.initialize(); + expect(context.initialized).toBeTruthy(); + }); + + test('should return esNames', () => { + const context = createEsContext({ + logger, + clusterClientPromise: Promise.resolve(clusterClient), + indexNameRoot: 'test-index', + }); + + const esNames = context.esNames; + expect(esNames).toStrictEqual({ + base: 'test-index', + alias: 'test-index-event-log-1.2.3', + ilmPolicy: 'test-index-event-log-policy', + indexPattern: 'test-index-event-log-*', + indexPatternWithVersion: 'test-index-event-log-1.2.3-*', + indexTemplate: 'test-index-event-log-1.2.3-template', + initialIndex: 'test-index-event-log-1.2.3-000001', + }); + }); + + test('should return exist false for esAdapter ilm policy, index template and alias before initialize', async () => { + const context = createEsContext({ + logger, + clusterClientPromise: Promise.resolve(clusterClient), + indexNameRoot: 'test1', + }); + clusterClient.callAsInternalUser.mockResolvedValue(false); + + const doesAliasExist = await context.esAdapter.doesAliasExist(context.esNames.alias); + expect(doesAliasExist).toBeFalsy(); + + const doesIndexTemplateExist = await context.esAdapter.doesIndexTemplateExist( + context.esNames.indexTemplate + ); + expect(doesIndexTemplateExist).toBeFalsy(); + }); + + test('should return exist true for esAdapter ilm policy, index template and alias after initialize', async () => { + const context = createEsContext({ + logger, + clusterClientPromise: Promise.resolve(clusterClient), + indexNameRoot: 'test2', + }); + clusterClient.callAsInternalUser.mockResolvedValue(true); + context.initialize(); + + const doesIlmPolicyExist = await context.esAdapter.doesIlmPolicyExist( + context.esNames.ilmPolicy + ); + expect(doesIlmPolicyExist).toBeTruthy(); + + const doesAliasExist = await context.esAdapter.doesAliasExist(context.esNames.alias); + expect(doesAliasExist).toBeTruthy(); + + const doesIndexTemplateExist = await context.esAdapter.doesIndexTemplateExist( + context.esNames.indexTemplate + ); + expect(doesIndexTemplateExist).toBeTruthy(); + }); +}); diff --git a/x-pack/plugins/event_log/server/es/context.ts b/x-pack/plugins/event_log/server/es/context.ts index b8e351367b695..0b3f22c6eecc0 100644 --- a/x-pack/plugins/event_log/server/es/context.ts +++ b/x-pack/plugins/event_log/server/es/context.ts @@ -19,6 +19,7 @@ export interface EsContext { esAdapter: IClusterClientAdapter; initialize(): void; waitTillReady(): Promise; + initialized: boolean; } export interface EsError { @@ -41,7 +42,7 @@ class EsContextImpl implements EsContext { public readonly esNames: EsNames; public esAdapter: IClusterClientAdapter; private readonly readySignal: ReadySignal; - private initialized: boolean; + public initialized: boolean; constructor(params: EsContextCtorParams) { this.logger = params.logger; diff --git a/x-pack/plugins/features/kibana.json b/x-pack/plugins/features/kibana.json index 325e5a0407493..6e51f3b650710 100644 --- a/x-pack/plugins/features/kibana.json +++ b/x-pack/plugins/features/kibana.json @@ -2,7 +2,7 @@ "id": "features", "version": "8.0.0", "kibanaVersion": "kibana", - "optionalPlugins": ["timelion"], + "optionalPlugins": ["visTypeTimelion"], "configPath": ["xpack", "features"], "server": true, "ui": true diff --git a/x-pack/plugins/features/server/plugin.ts b/x-pack/plugins/features/server/plugin.ts index cebf67243fb28..83cc9e1eb7cc8 100644 --- a/x-pack/plugins/features/server/plugin.ts +++ b/x-pack/plugins/features/server/plugin.ts @@ -13,7 +13,7 @@ import { import { Capabilities as UICapabilities } from '../../../../src/core/server'; import { deepFreeze } from '../../../../src/core/utils'; import { XPackInfo } from '../../../legacy/plugins/xpack_main/server/lib/xpack_info'; -import { PluginSetupContract as TimelionSetupContract } from '../../../../src/plugins/timelion/server'; +import { PluginSetupContract as TimelionSetupContract } from '../../../../src/plugins/vis_type_timelion/server'; import { FeatureRegistry } from './feature_registry'; import { Feature, FeatureConfig } from '../common/feature'; import { uiCapabilitiesForFeatures } from './ui_capabilities_for_features'; @@ -65,7 +65,7 @@ export class Plugin { public async setup( core: CoreSetup, - { timelion }: { timelion?: TimelionSetupContract } + { visTypeTimelion }: { visTypeTimelion?: TimelionSetupContract } ): Promise> { defineRoutes({ router: core.http.createRouter(), @@ -84,7 +84,7 @@ export class Plugin { // Register OSS features. for (const feature of buildOSSFeatures({ savedObjectTypes: this.legacyAPI.savedObjectTypes, - includeTimelion: timelion !== undefined && timelion.uiEnabled, + includeTimelion: visTypeTimelion !== undefined && visTypeTimelion.uiEnabled, })) { this.featureRegistry.register(feature); } diff --git a/x-pack/plugins/features/server/ui_capabilities_for_features.test.ts b/x-pack/plugins/features/server/ui_capabilities_for_features.test.ts index 73c399878b17b..35dcc4cf42b37 100644 --- a/x-pack/plugins/features/server/ui_capabilities_for_features.test.ts +++ b/x-pack/plugins/features/server/ui_capabilities_for_features.test.ts @@ -135,6 +135,42 @@ describe('populateUICapabilities', () => { }); }); + it(`supports capabilities from reserved privileges`, () => { + expect( + uiCapabilitiesForFeatures([ + new Feature({ + id: 'newFeature', + name: 'my new feature', + navLinkId: 'newFeatureNavLink', + app: ['bar-app'], + privileges: null, + reserved: { + description: '', + privileges: [ + { + id: 'rp_1', + privilege: createFeaturePrivilege(['capability1', 'capability2']), + }, + { + id: 'rp_2', + privilege: createFeaturePrivilege(['capability3', 'capability4', 'capability5']), + }, + ], + }, + }), + ]) + ).toEqual({ + catalogue: {}, + newFeature: { + capability1: true, + capability2: true, + capability3: true, + capability4: true, + capability5: true, + }, + }); + }); + it(`supports merging features with sub privileges`, () => { expect( uiCapabilitiesForFeatures([ diff --git a/x-pack/plugins/features/server/ui_capabilities_for_features.ts b/x-pack/plugins/features/server/ui_capabilities_for_features.ts index d3d3230822749..e6ff3ad4383d2 100644 --- a/x-pack/plugins/features/server/ui_capabilities_for_features.ts +++ b/x-pack/plugins/features/server/ui_capabilities_for_features.ts @@ -45,6 +45,9 @@ function getCapabilitiesFromFeature(feature: Feature): FeatureCapabilities { ...feature.subFeatures.map(sf => sf.privilegeGroups.map(pg => pg.privileges)).flat(2) ); } + if (feature.reserved?.privileges) { + featurePrivileges.push(...feature.reserved.privileges.map(rp => rp.privilege)); + } featurePrivileges.forEach(privilege => { UIFeatureCapabilities[feature.id] = { diff --git a/x-pack/plugins/file_upload/server/telemetry/mappings.ts b/x-pack/plugins/file_upload/server/telemetry/mappings.ts index ca935fea3449a..97a5ed9eeef82 100644 --- a/x-pack/plugins/file_upload/server/telemetry/mappings.ts +++ b/x-pack/plugins/file_upload/server/telemetry/mappings.ts @@ -10,7 +10,7 @@ import { TELEMETRY_DOC_ID } from './telemetry'; export const fileUploadTelemetryMappingsType: SavedObjectsType = { name: TELEMETRY_DOC_ID, hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { filesUploadedTotalCount: { diff --git a/x-pack/plugins/infra/common/http_api/source_api.ts b/x-pack/plugins/infra/common/http_api/source_api.ts new file mode 100644 index 0000000000000..218f8cebc9869 --- /dev/null +++ b/x-pack/plugins/infra/common/http_api/source_api.ts @@ -0,0 +1,188 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +/* eslint-disable @typescript-eslint/no-empty-interface */ + +import * as rt from 'io-ts'; +import moment from 'moment'; +import { pipe } from 'fp-ts/lib/pipeable'; +import { chain } from 'fp-ts/lib/Either'; + +export const TimestampFromString = new rt.Type( + 'TimestampFromString', + (input): input is number => typeof input === 'number', + (input, context) => + pipe( + rt.string.validate(input, context), + chain(stringInput => { + const momentValue = moment(stringInput); + return momentValue.isValid() + ? rt.success(momentValue.valueOf()) + : rt.failure(stringInput, context); + }) + ), + output => new Date(output).toISOString() +); + +/** + * Stored source configuration as read from and written to saved objects + */ + +const SavedSourceConfigurationFieldsRuntimeType = rt.partial({ + container: rt.string, + host: rt.string, + pod: rt.string, + tiebreaker: rt.string, + timestamp: rt.string, +}); + +export const SavedSourceConfigurationTimestampColumnRuntimeType = rt.type({ + timestampColumn: rt.type({ + id: rt.string, + }), +}); + +export const SavedSourceConfigurationMessageColumnRuntimeType = rt.type({ + messageColumn: rt.type({ + id: rt.string, + }), +}); + +export const SavedSourceConfigurationFieldColumnRuntimeType = rt.type({ + fieldColumn: rt.type({ + id: rt.string, + field: rt.string, + }), +}); + +export const SavedSourceConfigurationColumnRuntimeType = rt.union([ + SavedSourceConfigurationTimestampColumnRuntimeType, + SavedSourceConfigurationMessageColumnRuntimeType, + SavedSourceConfigurationFieldColumnRuntimeType, +]); + +export const SavedSourceConfigurationRuntimeType = rt.partial({ + name: rt.string, + description: rt.string, + metricAlias: rt.string, + logAlias: rt.string, + fields: SavedSourceConfigurationFieldsRuntimeType, + logColumns: rt.array(SavedSourceConfigurationColumnRuntimeType), +}); + +export interface InfraSavedSourceConfiguration + extends rt.TypeOf {} + +export const pickSavedSourceConfiguration = ( + value: InfraSourceConfiguration +): InfraSavedSourceConfiguration => { + const { name, description, metricAlias, logAlias, fields, logColumns } = value; + const { container, host, pod, tiebreaker, timestamp } = fields; + + return { + name, + description, + metricAlias, + logAlias, + fields: { container, host, pod, tiebreaker, timestamp }, + logColumns, + }; +}; + +/** + * Static source configuration as read from the configuration file + */ + +const StaticSourceConfigurationFieldsRuntimeType = rt.partial({ + ...SavedSourceConfigurationFieldsRuntimeType.props, + message: rt.array(rt.string), +}); + +export const StaticSourceConfigurationRuntimeType = rt.partial({ + name: rt.string, + description: rt.string, + metricAlias: rt.string, + logAlias: rt.string, + fields: StaticSourceConfigurationFieldsRuntimeType, + logColumns: rt.array(SavedSourceConfigurationColumnRuntimeType), +}); + +export interface InfraStaticSourceConfiguration + extends rt.TypeOf {} + +/** + * Full source configuration type after all cleanup has been done at the edges + */ + +const SourceConfigurationFieldsRuntimeType = rt.type({ + ...StaticSourceConfigurationFieldsRuntimeType.props, +}); + +export const SourceConfigurationRuntimeType = rt.type({ + ...SavedSourceConfigurationRuntimeType.props, + fields: SourceConfigurationFieldsRuntimeType, + logColumns: rt.array(SavedSourceConfigurationColumnRuntimeType), +}); + +export const SourceRuntimeType = rt.intersection([ + rt.type({ + id: rt.string, + origin: rt.keyof({ + fallback: null, + internal: null, + stored: null, + }), + configuration: SourceConfigurationRuntimeType, + }), + rt.partial({ + version: rt.string, + updatedAt: rt.number, + }), +]); + +export interface InfraSourceConfiguration + extends rt.TypeOf {} + +export interface InfraSource extends rt.TypeOf {} + +const SourceStatusFieldRuntimeType = rt.type({ + name: rt.string, + type: rt.string, + searchable: rt.boolean, + aggregatable: rt.boolean, + displayable: rt.boolean, +}); + +const SourceStatusRuntimeType = rt.type({ + logIndicesExist: rt.boolean, + metricIndicesExist: rt.boolean, + indexFields: rt.array(SourceStatusFieldRuntimeType), +}); + +export const SourceResponseRuntimeType = rt.type({ + source: SourceRuntimeType, + status: SourceStatusRuntimeType, +}); + +export type SourceResponse = rt.TypeOf; + +/** + * Saved object type with metadata + */ + +export const SourceConfigurationSavedObjectRuntimeType = rt.intersection([ + rt.type({ + id: rt.string, + attributes: SavedSourceConfigurationRuntimeType, + }), + rt.partial({ + version: rt.string, + updated_at: TimestampFromString, + }), +]); + +export interface SourceConfigurationSavedObject + extends rt.TypeOf {} diff --git a/x-pack/plugins/infra/common/inventory_models/aws_ec2/layout.tsx b/x-pack/plugins/infra/common/inventory_models/aws_ec2/layout.tsx index 68bfe41fd538e..9494e4aa396a5 100644 --- a/x-pack/plugins/infra/common/inventory_models/aws_ec2/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_ec2/layout.tsx @@ -6,19 +6,19 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +import { LayoutPropsWithTheme } from '../../../public/pages/metrics/metric_detail/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Section } from '../../../public/pages/metrics/components/section'; +import { Section } from '../../../public/pages/metrics/metric_detail/components/section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +import { SubSection } from '../../../public/pages/metrics/metric_detail/components/sub_section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +import { LayoutContent } from '../../../public/pages/metrics/metric_detail/components/layout_content'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; +import { ChartSectionVis } from '../../../public/pages/metrics/metric_detail/components/chart_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { withTheme } from '../../../../observability/public'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; +import { MetadataDetails } from '../../../public/pages/metrics/metric_detail/components/metadata_details'; export const Layout = withTheme(({ metrics, theme, onChangeRangeTime }: LayoutPropsWithTheme) => ( diff --git a/x-pack/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx index 683851fec4d77..b2da7dec3f2e0 100644 --- a/x-pack/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_ec2/toolbar_items.tsx @@ -6,9 +6,9 @@ import React from 'react'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; -import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; -import { CloudToolbarItems } from '../shared/compontents/cloud_toolbar_items'; +import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; +import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items'; +import { CloudToolbarItems } from '../shared/components/cloud_toolbar_items'; import { SnapshotMetricType } from '../types'; export const AwsEC2ToolbarItems = (props: ToolbarProps) => { diff --git a/x-pack/plugins/infra/common/inventory_models/aws_rds/layout.tsx b/x-pack/plugins/infra/common/inventory_models/aws_rds/layout.tsx index 220c6c67f4aea..08b865f01b06c 100644 --- a/x-pack/plugins/infra/common/inventory_models/aws_rds/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_rds/layout.tsx @@ -6,17 +6,17 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +import { LayoutPropsWithTheme } from '../../../public/pages/metrics/metric_detail/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Section } from '../../../public/pages/metrics/components/section'; +import { Section } from '../../../public/pages/metrics/metric_detail/components/section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +import { SubSection } from '../../../public/pages/metrics/metric_detail/components/sub_section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; +import { ChartSectionVis } from '../../../public/pages/metrics/metric_detail/components/chart_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { withTheme } from '../../../../observability/public'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +import { LayoutContent } from '../../../public/pages/metrics/metric_detail/components/layout_content'; export const Layout = withTheme(({ metrics, onChangeRangeTime, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx index 24f05fd91589c..2a8394b9dd3a4 100644 --- a/x-pack/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_rds/toolbar_items.tsx @@ -6,9 +6,9 @@ import React from 'react'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; -import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; -import { CloudToolbarItems } from '../shared/compontents/cloud_toolbar_items'; +import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; +import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items'; +import { CloudToolbarItems } from '../shared/components/cloud_toolbar_items'; import { SnapshotMetricType } from '../types'; export const AwsRDSToolbarItems = (props: ToolbarProps) => { diff --git a/x-pack/plugins/infra/common/inventory_models/aws_s3/layout.tsx b/x-pack/plugins/infra/common/inventory_models/aws_s3/layout.tsx index 805236cf47082..e16f8ef6addde 100644 --- a/x-pack/plugins/infra/common/inventory_models/aws_s3/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_s3/layout.tsx @@ -6,17 +6,17 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +import { LayoutPropsWithTheme } from '../../../public/pages/metrics/metric_detail/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Section } from '../../../public/pages/metrics/components/section'; +import { Section } from '../../../public/pages/metrics/metric_detail/components/section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +import { SubSection } from '../../../public/pages/metrics/metric_detail/components/sub_section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; +import { ChartSectionVis } from '../../../public/pages/metrics/metric_detail/components/chart_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { withTheme } from '../../../../observability/public'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +import { LayoutContent } from '../../../public/pages/metrics/metric_detail/components/layout_content'; export const Layout = withTheme(({ metrics, onChangeRangeTime, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx index 54c3196ae2833..324bdd0586029 100644 --- a/x-pack/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_s3/toolbar_items.tsx @@ -6,9 +6,9 @@ import React from 'react'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; -import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; -import { CloudToolbarItems } from '../shared/compontents/cloud_toolbar_items'; +import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; +import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items'; +import { CloudToolbarItems } from '../shared/components/cloud_toolbar_items'; import { SnapshotMetricType } from '../types'; export const AwsS3ToolbarItems = (props: ToolbarProps) => { diff --git a/x-pack/plugins/infra/common/inventory_models/aws_sqs/layout.tsx b/x-pack/plugins/infra/common/inventory_models/aws_sqs/layout.tsx index d581ac751682d..ff13f2db104de 100644 --- a/x-pack/plugins/infra/common/inventory_models/aws_sqs/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_sqs/layout.tsx @@ -6,17 +6,17 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +import { LayoutPropsWithTheme } from '../../../public/pages/metrics/metric_detail/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Section } from '../../../public/pages/metrics/components/section'; +import { Section } from '../../../public/pages/metrics/metric_detail/components/section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +import { SubSection } from '../../../public/pages/metrics/metric_detail/components/sub_section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; +import { ChartSectionVis } from '../../../public/pages/metrics/metric_detail/components/chart_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { withTheme } from '../../../../observability/public'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +import { LayoutContent } from '../../../public/pages/metrics/metric_detail/components/layout_content'; export const Layout = withTheme(({ metrics, onChangeRangeTime, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx index 22cb2740a4a7f..3229c07034772 100644 --- a/x-pack/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/aws_sqs/toolbar_items.tsx @@ -6,9 +6,9 @@ import React from 'react'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; -import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; -import { CloudToolbarItems } from '../shared/compontents/cloud_toolbar_items'; +import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; +import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items'; +import { CloudToolbarItems } from '../shared/components/cloud_toolbar_items'; import { SnapshotMetricType } from '../types'; export const AwsSQSToolbarItems = (props: ToolbarProps) => { diff --git a/x-pack/plugins/infra/common/inventory_models/container/layout.tsx b/x-pack/plugins/infra/common/inventory_models/container/layout.tsx index 9956b2c9a2ce4..b9366a43e40c6 100644 --- a/x-pack/plugins/infra/common/inventory_models/container/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/container/layout.tsx @@ -6,21 +6,21 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +import { LayoutPropsWithTheme } from '../../../public/pages/metrics/metric_detail/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Section } from '../../../public/pages/metrics/components/section'; +import { Section } from '../../../public/pages/metrics/metric_detail/components/section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +import { SubSection } from '../../../public/pages/metrics/metric_detail/components/sub_section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauges_section_vis'; +import { GaugesSectionVis } from '../../../public/pages/metrics/metric_detail/components/gauges_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; +import { ChartSectionVis } from '../../../public/pages/metrics/metric_detail/components/chart_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { withTheme } from '../../../../observability/public'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +import { LayoutContent } from '../../../public/pages/metrics/metric_detail/components/layout_content'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; +import { MetadataDetails } from '../../../public/pages/metrics/metric_detail/components/metadata_details'; export const Layout = withTheme(({ metrics, onChangeRangeTime, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/plugins/infra/common/inventory_models/container/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/container/toolbar_items.tsx index dbb77cb3b677e..f6c707726d9ca 100644 --- a/x-pack/plugins/infra/common/inventory_models/container/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/container/toolbar_items.tsx @@ -6,8 +6,8 @@ import React from 'react'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; -import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; +import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; +import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items'; import { SnapshotMetricType } from '../types'; export const ContainerToolbarItems = (props: ToolbarProps) => { diff --git a/x-pack/plugins/infra/common/inventory_models/host/layout.tsx b/x-pack/plugins/infra/common/inventory_models/host/layout.tsx index 6d7d361254220..e23118c747a9b 100644 --- a/x-pack/plugins/infra/common/inventory_models/host/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/host/layout.tsx @@ -8,21 +8,21 @@ import { i18n } from '@kbn/i18n'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { withTheme } from '../../../../observability/public'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +import { LayoutPropsWithTheme } from '../../../public/pages/metrics/metric_detail/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Section } from '../../../public/pages/metrics/components/section'; +import { Section } from '../../../public/pages/metrics/metric_detail/components/section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +import { SubSection } from '../../../public/pages/metrics/metric_detail/components/sub_section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauges_section_vis'; +import { GaugesSectionVis } from '../../../public/pages/metrics/metric_detail/components/gauges_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; +import { ChartSectionVis } from '../../../public/pages/metrics/metric_detail/components/chart_section_vis'; import * as Aws from '../shared/layouts/aws'; import * as Ngnix from '../shared/layouts/nginx'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; +import { MetadataDetails } from '../../../public/pages/metrics/metric_detail/components/metadata_details'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +import { LayoutContent } from '../../../public/pages/metrics/metric_detail/components/layout_content'; export const Layout = withTheme(({ metrics, onChangeRangeTime, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/plugins/infra/common/inventory_models/host/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/host/toolbar_items.tsx index fc7696ee53c9d..136264c0e26f4 100644 --- a/x-pack/plugins/infra/common/inventory_models/host/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/host/toolbar_items.tsx @@ -6,8 +6,8 @@ import React from 'react'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; -import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; +import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; +import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items'; import { SnapshotMetricType } from '../types'; export const HostToolbarItems = (props: ToolbarProps) => { diff --git a/x-pack/plugins/infra/common/inventory_models/layouts.ts b/x-pack/plugins/infra/common/inventory_models/layouts.ts index b59ce010361ec..df82f154b47b3 100644 --- a/x-pack/plugins/infra/common/inventory_models/layouts.ts +++ b/x-pack/plugins/infra/common/inventory_models/layouts.ts @@ -23,7 +23,7 @@ import { Layout as AwsRDSLayout } from './aws_rds/layout'; import { Layout as AwsSQSLayout } from './aws_sqs/layout'; import { InventoryItemType } from './types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutProps } from '../../public/pages/metrics/types'; +import { LayoutProps } from '../../public/pages/metrics/metric_detail/types'; interface Layouts { [type: string]: ReactNode; diff --git a/x-pack/plugins/infra/common/inventory_models/pod/layout.tsx b/x-pack/plugins/infra/common/inventory_models/pod/layout.tsx index 8bc2f3ee8b4b3..271e32556ae28 100644 --- a/x-pack/plugins/infra/common/inventory_models/pod/layout.tsx +++ b/x-pack/plugins/infra/common/inventory_models/pod/layout.tsx @@ -6,22 +6,22 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutPropsWithTheme } from '../../../public/pages/metrics/types'; +import { LayoutPropsWithTheme } from '../../../public/pages/metrics/metric_detail/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Section } from '../../../public/pages/metrics/components/section'; +import { Section } from '../../../public/pages/metrics/metric_detail/components/section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SubSection } from '../../../public/pages/metrics/components/sub_section'; +import { SubSection } from '../../../public/pages/metrics/metric_detail/components/sub_section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { GaugesSectionVis } from '../../../public/pages/metrics/components/gauges_section_vis'; +import { GaugesSectionVis } from '../../../public/pages/metrics/metric_detail/components/gauges_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ChartSectionVis } from '../../../public/pages/metrics/components/chart_section_vis'; +import { ChartSectionVis } from '../../../public/pages/metrics/metric_detail/components/chart_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { withTheme } from '../../../../observability/public'; import * as Nginx from '../shared/layouts/nginx'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { MetadataDetails } from '../../../public/pages/metrics/components/metadata_details'; +import { MetadataDetails } from '../../../public/pages/metrics/metric_detail/components/metadata_details'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutContent } from '../../../public/pages/metrics/components/layout_content'; +import { LayoutContent } from '../../../public/pages/metrics/metric_detail/components/layout_content'; export const Layout = withTheme(({ metrics, onChangeRangeTime, theme }: LayoutPropsWithTheme) => ( diff --git a/x-pack/plugins/infra/common/inventory_models/pod/toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/pod/toolbar_items.tsx index d48c27efd88fd..c1cd375ff47bf 100644 --- a/x-pack/plugins/infra/common/inventory_models/pod/toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/pod/toolbar_items.tsx @@ -6,8 +6,8 @@ import React from 'react'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../../public/components/inventory/toolbars/toolbar'; -import { MetricsAndGroupByToolbarItems } from '../shared/compontents/metrics_and_groupby_toolbar_items'; +import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; +import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items'; import { SnapshotMetricType } from '../types'; export const PodToolbarItems = (props: ToolbarProps) => { diff --git a/x-pack/plugins/infra/common/inventory_models/shared/compontents/cloud_toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/shared/components/cloud_toolbar_items.tsx similarity index 75% rename from x-pack/plugins/infra/common/inventory_models/shared/compontents/cloud_toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/shared/components/cloud_toolbar_items.tsx index 766a8ae8142f5..da5017b0f3a36 100644 --- a/x-pack/plugins/infra/common/inventory_models/shared/compontents/cloud_toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/shared/components/cloud_toolbar_items.tsx @@ -7,11 +7,11 @@ import React from 'react'; import { EuiFlexItem } from '@elastic/eui'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../../../public/components/inventory/toolbars/toolbar'; +import { ToolbarProps } from '../../../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { WaffleAccountsControls } from '../../../../public/components/waffle/waffle_accounts_controls'; +import { WaffleAccountsControls } from '../../../../public/pages/metrics/inventory_view/components/waffle/waffle_accounts_controls'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { WaffleRegionControls } from '../../../../public/components/waffle/waffle_region_controls'; +import { WaffleRegionControls } from '../../../../public/pages/metrics/inventory_view/components/waffle/waffle_region_controls'; type Props = ToolbarProps; diff --git a/x-pack/plugins/infra/common/inventory_models/shared/compontents/metrics_and_groupby_toolbar_items.tsx b/x-pack/plugins/infra/common/inventory_models/shared/components/metrics_and_groupby_toolbar_items.tsx similarity index 81% rename from x-pack/plugins/infra/common/inventory_models/shared/compontents/metrics_and_groupby_toolbar_items.tsx rename to x-pack/plugins/infra/common/inventory_models/shared/components/metrics_and_groupby_toolbar_items.tsx index 738fce45ee99f..bf37828ed0856 100644 --- a/x-pack/plugins/infra/common/inventory_models/shared/compontents/metrics_and_groupby_toolbar_items.tsx +++ b/x-pack/plugins/infra/common/inventory_models/shared/components/metrics_and_groupby_toolbar_items.tsx @@ -7,16 +7,16 @@ import React, { useMemo } from 'react'; import { EuiFlexItem } from '@elastic/eui'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../../../public/components/inventory/toolbars/toolbar'; +import { ToolbarProps } from '../../../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { WaffleMetricControls } from '../../../../public/components/waffle/metric_control'; +import { WaffleMetricControls } from '../../../../public/pages/metrics/inventory_view/components/waffle/metric_control'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { WaffleGroupByControls } from '../../../../public/components/waffle/waffle_group_by_controls'; +import { WaffleGroupByControls } from '../../../../public/pages/metrics/inventory_view/components/waffle/waffle_group_by_controls'; import { toGroupByOpt, toMetricOpt, // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../public/components/inventory/toolbars/toolbar_wrapper'; +} from '../../../../public/pages/metrics/inventory_view/components/toolbars/toolbar_wrapper'; import { SnapshotMetricType } from '../../types'; interface Props extends ToolbarProps { diff --git a/x-pack/plugins/infra/common/inventory_models/shared/layouts/aws.tsx b/x-pack/plugins/infra/common/inventory_models/shared/layouts/aws.tsx index 7a0b898d406ce..6f2791534c17e 100644 --- a/x-pack/plugins/infra/common/inventory_models/shared/layouts/aws.tsx +++ b/x-pack/plugins/infra/common/inventory_models/shared/layouts/aws.tsx @@ -6,15 +6,15 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutPropsWithTheme } from '../../../../public/pages/metrics/types'; +import { LayoutPropsWithTheme } from '../../../../public/pages/metrics/metric_detail/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Section } from '../../../../public/pages/metrics/components/section'; +import { Section } from '../../../../public/pages/metrics/metric_detail/components/section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SubSection } from '../../../../public/pages/metrics/components/sub_section'; +import { SubSection } from '../../../../public/pages/metrics/metric_detail/components/sub_section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { GaugesSectionVis } from '../../../../public/pages/metrics/components/gauges_section_vis'; +import { GaugesSectionVis } from '../../../../public/pages/metrics/metric_detail/components/gauges_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ChartSectionVis } from '../../../../public/pages/metrics/components/chart_section_vis'; +import { ChartSectionVis } from '../../../../public/pages/metrics/metric_detail/components/chart_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { withTheme } from '../../../../../observability/public'; diff --git a/x-pack/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx b/x-pack/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx index 79cea5150d498..cf3a06994cc96 100644 --- a/x-pack/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx +++ b/x-pack/plugins/infra/common/inventory_models/shared/layouts/nginx.tsx @@ -6,13 +6,13 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { LayoutPropsWithTheme } from '../../../../public/pages/metrics/types'; +import { LayoutPropsWithTheme } from '../../../../public/pages/metrics/metric_detail/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { Section } from '../../../../public/pages/metrics/components/section'; +import { Section } from '../../../../public/pages/metrics/metric_detail/components/section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SubSection } from '../../../../public/pages/metrics/components/sub_section'; +import { SubSection } from '../../../../public/pages/metrics/metric_detail/components/sub_section'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ChartSectionVis } from '../../../../public/pages/metrics/components/chart_section_vis'; +import { ChartSectionVis } from '../../../../public/pages/metrics/metric_detail/components/chart_section_vis'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { withTheme } from '../../../../../observability/public'; diff --git a/x-pack/plugins/infra/common/inventory_models/toolbars.ts b/x-pack/plugins/infra/common/inventory_models/toolbars.ts index 39e9f5a260f7a..e00cb094d0455 100644 --- a/x-pack/plugins/infra/common/inventory_models/toolbars.ts +++ b/x-pack/plugins/infra/common/inventory_models/toolbars.ts @@ -11,7 +11,7 @@ import { HostToolbarItems } from './host/toolbar_items'; import { ContainerToolbarItems } from './container/toolbar_items'; import { PodToolbarItems } from './pod/toolbar_items'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ToolbarProps } from '../../public/components/inventory/toolbars/toolbar'; +import { ToolbarProps } from '../../public/pages/metrics/inventory_view/components/toolbars/toolbar'; import { AwsEC2ToolbarItems } from './aws_ec2/toolbar_items'; import { AwsS3ToolbarItems } from './aws_s3/toolbar_items'; import { AwsRDSToolbarItems } from './aws_rds/toolbar_items'; diff --git a/x-pack/plugins/infra/common/saved_objects/inventory_view.ts b/x-pack/plugins/infra/common/saved_objects/inventory_view.ts index 8ae765f379add..8933de57b0448 100644 --- a/x-pack/plugins/infra/common/saved_objects/inventory_view.ts +++ b/x-pack/plugins/infra/common/saved_objects/inventory_view.ts @@ -7,7 +7,7 @@ // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { ElasticsearchMappingOf } from '../../server/utils/typed_elasticsearch_mappings'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { WaffleViewState } from '../../public/pages/inventory_view/hooks/use_waffle_view_state'; +import { WaffleViewState } from '../../public/pages/metrics/inventory_view/hooks/use_waffle_view_state'; export const inventoryViewSavedObjectType = 'inventory-view'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths diff --git a/x-pack/plugins/infra/common/saved_objects/metrics_explorer_view.ts b/x-pack/plugins/infra/common/saved_objects/metrics_explorer_view.ts index a9f1194844640..6eb08eabc15b5 100644 --- a/x-pack/plugins/infra/common/saved_objects/metrics_explorer_view.ts +++ b/x-pack/plugins/infra/common/saved_objects/metrics_explorer_view.ts @@ -11,7 +11,7 @@ import { MetricsExplorerChartOptions, MetricsExplorerTimeOptions, // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../public/containers/metrics_explorer/use_metrics_explorer_options'; +} from '../../public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { SavedViewSavedObject } from '../../public/hooks/use_saved_view'; diff --git a/x-pack/plugins/infra/public/components/alerting/metrics/alert_flyout.tsx b/x-pack/plugins/infra/public/components/alerting/metrics/alert_flyout.tsx index 914054e1fd9b7..38709c117c817 100644 --- a/x-pack/plugins/infra/public/components/alerting/metrics/alert_flyout.tsx +++ b/x-pack/plugins/infra/public/components/alerting/metrics/alert_flyout.tsx @@ -10,8 +10,8 @@ import { TriggerActionsContext } from '../../../utils/triggers_actions_context'; import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { METRIC_THRESHOLD_ALERT_TYPE_ID } from '../../../../server/lib/alerting/metric_threshold/types'; -import { MetricsExplorerOptions } from '../../../containers/metrics_explorer/use_metrics_explorer_options'; import { MetricsExplorerSeries } from '../../../../common/http_api/metrics_explorer'; +import { MetricsExplorerOptions } from '../../../pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options'; interface Props { visible?: boolean; diff --git a/x-pack/plugins/infra/public/components/alerting/metrics/expression.tsx b/x-pack/plugins/infra/public/components/alerting/metrics/expression.tsx index 7de52840777f9..665da25dcbfff 100644 --- a/x-pack/plugins/infra/public/components/alerting/metrics/expression.tsx +++ b/x-pack/plugins/infra/public/components/alerting/metrics/expression.tsx @@ -17,9 +17,6 @@ import { import { IFieldType } from 'src/plugins/data/public'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { EuiExpression } from '@elastic/eui'; -import { EuiCallOut } from '@elastic/eui'; -import { EuiLink } from '@elastic/eui'; import { MetricExpressionParams, Comparator, @@ -38,11 +35,11 @@ import { IErrorObject } from '../../../../../triggers_actions_ui/public/types'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths import { AlertsContextValue } from '../../../../../triggers_actions_ui/public/application/context/alerts_context'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { MetricsExplorerOptions } from '../../../containers/metrics_explorer/use_metrics_explorer_options'; -import { MetricsExplorerKueryBar } from '../../metrics_explorer/kuery_bar'; import { MetricsExplorerSeries } from '../../../../common/http_api/metrics_explorer'; -import { useSource } from '../../../containers/source'; -import { MetricsExplorerGroupBy } from '../../metrics_explorer/group_by'; +import { MetricsExplorerKueryBar } from '../../../pages/metrics/metrics_explorer/components/kuery_bar'; +import { MetricsExplorerOptions } from '../../../pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options'; +import { MetricsExplorerGroupBy } from '../../../pages/metrics/metrics_explorer/components/group_by'; +import { useSourceViaHttp } from '../../../containers/source/use_source_via_http'; interface AlertContextMeta { currentOptions?: Partial; @@ -87,7 +84,12 @@ const defaultExpression = { export const Expressions: React.FC = props => { const { setAlertParams, alertParams, errors, alertsContext } = props; - const { source, createDerivedIndexPattern } = useSource({ sourceId: 'default' }); + const { source, createDerivedIndexPattern } = useSourceViaHttp({ + sourceId: 'default', + type: 'metrics', + fetch: alertsContext.http.fetch, + toastWarning: alertsContext.toastNotifications.addWarning, + }); const [timeSize, setTimeSize] = useState(1); const [timeUnit, setTimeUnit] = useState('m'); @@ -208,40 +210,11 @@ export const Expressions: React.FC = props => { setAlertParams('groupBy', md.currentOptions.groupBy); } setAlertParams('sourceId', source?.id); + } else { + setAlertParams('criteria', [defaultExpression]); } }, [alertsContext.metadata, defaultExpression, source]); // eslint-disable-line react-hooks/exhaustive-deps - // INFO: If there is metadata, you're in the metrics explorer context - const canAddConditions = !!alertsContext.metadata; - - if (!canAddConditions && !alertParams.criteria) { - return ( - <> - - - {' '} - - - - . - - } - color="warning" - iconType="help" - /> - - - ); - } - return ( <> @@ -258,7 +231,6 @@ export const Expressions: React.FC = props => { alertParams.criteria.map((e, idx) => { return ( 1} fields={derivedIndexPattern.fields} remove={removeExpression} @@ -281,20 +253,18 @@ export const Expressions: React.FC = props => { />
- {canAddConditions && ( - - - - )} + + +
@@ -347,7 +317,6 @@ export const Expressions: React.FC = props => { interface ExpressionRowProps { fields: IFieldType[]; - canEditAggField: boolean; expressionId: number; expression: MetricExpression; errors: IErrorObject; @@ -378,7 +347,11 @@ export const ExpressionRow: React.FC = props => { const updateAggType = useCallback( (at: string) => { - setAlertParams(expressionId, { ...expression, aggType: at as MetricExpression['aggType'] }); + setAlertParams(expressionId, { + ...expression, + aggType: at as MetricExpression['aggType'], + metric: at === 'count' ? undefined : expression.metric, + }); }, [expressionId, expression, setAlertParams] ); @@ -420,20 +393,17 @@ export const ExpressionRow: React.FC = props => { {aggType !== 'count' && ( - {!props.canEditAggField && } - {props.canEditAggField && ( - ({ - normalizedType: f.type, - name: f.name, - }))} - aggType={aggType} - errors={errors} - onChangeSelectedAggField={updateMetric} - /> - )} + ({ + normalizedType: f.type, + name: f.name, + }))} + aggType={aggType} + errors={errors} + onChangeSelectedAggField={updateMetric} + /> )} @@ -465,19 +435,6 @@ export const ExpressionRow: React.FC = props => { ); }; -export const DisabledAggField = ({ text }: { text: string }) => { - return ( - - ); -}; - export const aggregationType: { [key: string]: any } = { avg: { text: i18n.translate('xpack.infra.metrics.alertFlyout.aggregationText.avg', { diff --git a/x-pack/plugins/infra/public/components/waffle/lib/type_guards.ts b/x-pack/plugins/infra/public/components/waffle/lib/type_guards.ts deleted file mode 100644 index f793afee1b948..0000000000000 --- a/x-pack/plugins/infra/public/components/waffle/lib/type_guards.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { InfraWaffleMapGradientLegend, InfraWaffleMapStepLegend } from '../../../lib/lib'; - -export function isInfraWaffleMapStepLegend(subject: any): subject is InfraWaffleMapStepLegend { - return subject.type && subject.type === 'step'; -} - -export function isInfraWaffleMapGradientLegend( - subject: any -): subject is InfraWaffleMapGradientLegend { - return subject.type && subject.type === 'gradient'; -} diff --git a/x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx b/x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx index d2fa49e8d5d9f..04f518aa9080f 100644 --- a/x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx +++ b/x-pack/plugins/infra/public/containers/metrics_explorer/with_metrics_explorer_options_url_state.tsx @@ -17,7 +17,7 @@ import { MetricsExplorerYAxisMode, MetricsExplorerChartType, MetricsExplorerChartOptions, -} from './use_metrics_explorer_options'; +} from '../../pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options'; interface MetricsExplorerUrlState { timerange?: MetricsExplorerTimeOptions; diff --git a/x-pack/plugins/infra/public/containers/source/source.tsx b/x-pack/plugins/infra/public/containers/source/source.tsx index a1310b1f33614..c2206769ef0ef 100644 --- a/x-pack/plugins/infra/public/containers/source/source.tsx +++ b/x-pack/plugins/infra/public/containers/source/source.tsx @@ -21,7 +21,7 @@ import { updateSourceMutation } from './update_source.gql_query'; type Source = SourceQuery.Query['source']; -const pickIndexPattern = (source: Source | undefined, type: 'logs' | 'metrics' | 'both') => { +export const pickIndexPattern = (source: Source | undefined, type: 'logs' | 'metrics' | 'both') => { if (!source) { return 'unknown-index'; } diff --git a/x-pack/plugins/infra/public/containers/source/use_source_via_http.ts b/x-pack/plugins/infra/public/containers/source/use_source_via_http.ts new file mode 100644 index 0000000000000..bc6374a6538e3 --- /dev/null +++ b/x-pack/plugins/infra/public/containers/source/use_source_via_http.ts @@ -0,0 +1,92 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { useEffect, useMemo } from 'react'; +import { fold } from 'fp-ts/lib/Either'; +import { identity } from 'fp-ts/lib/function'; +import { pipe } from 'fp-ts/lib/pipeable'; +import createContainer from 'constate'; +import { HttpHandler } from 'target/types/core/public/http'; +import { ToastInput } from 'target/types/core/public/notifications/toasts/toasts_api'; +import { + SourceResponseRuntimeType, + SourceResponse, + InfraSource, +} from '../../../common/http_api/source_api'; +import { useHTTPRequest } from '../../hooks/use_http_request'; +import { throwErrors, createPlainError } from '../../../common/runtime_types'; + +export const pickIndexPattern = ( + source: InfraSource | undefined, + type: 'logs' | 'metrics' | 'both' +) => { + if (!source) { + return 'unknown-index'; + } + if (type === 'logs') { + return source.configuration.logAlias; + } + if (type === 'metrics') { + return source.configuration.metricAlias; + } + return `${source.configuration.logAlias},${source.configuration.metricAlias}`; +}; + +interface Props { + sourceId: string; + type: 'logs' | 'metrics' | 'both'; + fetch?: HttpHandler; + toastWarning?: (input: ToastInput) => void; +} + +export const useSourceViaHttp = ({ + sourceId = 'default', + type = 'both', + fetch, + toastWarning, +}: Props) => { + const decodeResponse = (response: any) => { + return pipe( + SourceResponseRuntimeType.decode(response), + fold(throwErrors(createPlainError), identity) + ); + }; + + const { error, loading, response, makeRequest } = useHTTPRequest( + `/api/metrics/source/${sourceId}/${type}`, + 'GET', + null, + decodeResponse, + fetch, + toastWarning + ); + + useEffect(() => { + (async () => { + await makeRequest(); + })(); + }, [makeRequest]); + + const createDerivedIndexPattern = (indexType: 'logs' | 'metrics' | 'both' = type) => { + return { + fields: response?.source ? response.status.indexFields : [], + title: pickIndexPattern(response?.source, indexType), + }; + }; + + const source = useMemo(() => { + return response ? { ...response.source, status: response.status } : null; + }, [response]); + + return { + createDerivedIndexPattern, + source, + loading, + error, + }; +}; + +export const SourceViaHttp = createContainer(useSourceViaHttp); +export const [SourceViaHttpProvider, useSourceViaHttpContext] = SourceViaHttp; diff --git a/x-pack/plugins/infra/public/containers/with_options.tsx b/x-pack/plugins/infra/public/containers/with_options.tsx deleted file mode 100644 index e18fc85a68d60..0000000000000 --- a/x-pack/plugins/infra/public/containers/with_options.tsx +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import moment from 'moment'; -import React from 'react'; - -import { euiPaletteColorBlind } from '@elastic/eui'; -import { InfraFormatterType, InfraOptions } from '../lib/lib'; -import { RendererFunction } from '../utils/typed_react'; - -const euiVisColorPalette = euiPaletteColorBlind(); - -const initialState = { - options: { - timerange: { - interval: '1m', - to: moment.utc().valueOf(), - from: moment - .utc() - .subtract(1, 'h') - .valueOf(), - }, - wafflemap: { - formatter: InfraFormatterType.percent, - formatTemplate: '{{value}}', - metric: { type: 'cpu' }, - groupBy: [], - legend: { - type: 'gradient', - rules: [ - { - value: 0, - color: '#D3DAE6', - }, - { - value: 1, - color: euiVisColorPalette[1], - }, - ], - }, - }, - } as InfraOptions, -}; - -interface WithOptionsProps { - children: RendererFunction; -} - -type State = Readonly; - -export const withOptions = (WrappedComponent: React.ComponentType) => ( - {args => } -); - -export class WithOptions extends React.Component { - public readonly state: State = initialState; - - public render() { - return this.props.children(this.state.options); - } -} diff --git a/x-pack/plugins/infra/public/hooks/use_http_request.tsx b/x-pack/plugins/infra/public/hooks/use_http_request.tsx index 50f4a636b48a3..e00abe6380498 100644 --- a/x-pack/plugins/infra/public/hooks/use_http_request.tsx +++ b/x-pack/plugins/infra/public/hooks/use_http_request.tsx @@ -7,28 +7,32 @@ import React, { useMemo, useState } from 'react'; import { IHttpFetchError } from 'src/core/public'; import { i18n } from '@kbn/i18n'; +import { HttpHandler } from 'target/types/core/public/http'; +import { ToastInput } from 'target/types/core/public/notifications/toasts/toasts_api'; import { useTrackedPromise } from '../utils/use_tracked_promise'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; export function useHTTPRequest( pathname: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD', - body?: string, - decode: (response: any) => Response = response => response + body?: string | null, + decode: (response: any) => Response = response => response, + fetch?: HttpHandler, + toastWarning?: (input: ToastInput) => void ) { const kibana = useKibana(); - const fetch = kibana.services.http?.fetch; - const toasts = kibana.notifications.toasts; + const fetchService = fetch ? fetch : kibana.services.http?.fetch; + const toast = toastWarning ? toastWarning : kibana.notifications.toasts.warning; const [response, setResponse] = useState(null); const [error, setError] = useState(null); const [request, makeRequest] = useTrackedPromise( { cancelPreviousOn: 'resolution', createPromise: () => { - if (!fetch) { + if (!fetchService) { throw new Error('HTTP service is unavailable'); } - return fetch(pathname, { + return fetchService(pathname, { method, body, }); @@ -37,7 +41,7 @@ export function useHTTPRequest( onReject: (e: unknown) => { const err = e as IHttpFetchError; setError(err); - toasts.warning({ + toast({ toastLifeTimeMs: 3000, title: i18n.translate('xpack.infra.useHTTPRequest.error.title', { defaultMessage: `Error while fetching resource`, @@ -67,7 +71,7 @@ export function useHTTPRequest( }); }, }, - [pathname, body, method, fetch, toasts] + [pathname, body, method, fetch, toast] ); const loading = useMemo(() => { diff --git a/x-pack/plugins/infra/public/pages/infrastructure/index.tsx b/x-pack/plugins/infra/public/pages/infrastructure/index.tsx deleted file mode 100644 index d592ae3480fc9..0000000000000 --- a/x-pack/plugins/infra/public/pages/infrastructure/index.tsx +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { i18n } from '@kbn/i18n'; - -import React from 'react'; -import { Route, RouteComponentProps, Switch } from 'react-router-dom'; - -import { EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; -import { DocumentTitle } from '../../components/document_title'; -import { HelpCenterContent } from '../../components/help_center_content'; -import { RoutedTabs } from '../../components/navigation/routed_tabs'; -import { ColumnarPage } from '../../components/page'; -import { Header } from '../../components/header'; -import { MetricsExplorerOptionsContainer } from '../../containers/metrics_explorer/use_metrics_explorer_options'; -import { WithMetricsExplorerOptionsUrlState } from '../../containers/metrics_explorer/with_metrics_explorer_options_url_state'; -import { WithSource } from '../../containers/with_source'; -import { Source } from '../../containers/source'; -import { MetricsExplorerPage } from './metrics_explorer'; -import { SnapshotPage } from './snapshot'; -import { MetricsSettingsPage } from './settings'; -import { AppNavigation } from '../../components/navigation/app_navigation'; -import { SourceLoadingPage } from '../../components/source_loading_page'; -import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; -import { WaffleOptionsProvider } from '../inventory_view/hooks/use_waffle_options'; -import { WaffleTimeProvider } from '../inventory_view/hooks/use_waffle_time'; -import { WaffleFiltersProvider } from '../inventory_view/hooks/use_waffle_filters'; -import { AlertDropdown } from '../../components/alerting/metrics/alert_dropdown'; - -export const InfrastructurePage = ({ match }: RouteComponentProps) => { - const uiCapabilities = useKibana().services.application?.capabilities; - - return ( - - - - - - - - - -
- - - - - - - - - - - - - - ( - - {({ configuration, createDerivedIndexPattern }) => ( - - - {configuration ? ( - - ) : ( - - )} - - )} - - )} - /> - - - - - - - - ); -}; diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx index b1dab3bd3f673..3ad242c77412d 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_host_detail_via_ip.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { Redirect, RouteComponentProps } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; -import { replaceMetricTimeInQueryString } from '../metrics/hooks/use_metrics_time'; +import { replaceMetricTimeInQueryString } from '../metrics/metric_detail/hooks/use_metrics_time'; import { useHostIpToName } from './use_host_ip_to_name'; import { getFromFromLocation, getToFromLocation } from './query_params'; import { LoadingPage } from '../../components/loading_page'; diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx index 72a41f5264244..3d25e4c6c258d 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { Redirect, RouteComponentProps } from 'react-router-dom'; -import { replaceMetricTimeInQueryString } from '../metrics/hooks/use_metrics_time'; +import { replaceMetricTimeInQueryString } from '../metrics/metric_detail/hooks/use_metrics_time'; import { getFromFromLocation, getToFromLocation } from './query_params'; import { InventoryItemType } from '../../../common/inventory_models/types'; import { LinkDescriptor } from '../../hooks/use_link_props'; diff --git a/x-pack/plugins/infra/public/pages/metrics/index.tsx b/x-pack/plugins/infra/public/pages/metrics/index.tsx index 531be40d2dc43..cc88dd9e0d0f8 100644 --- a/x-pack/plugins/infra/public/pages/metrics/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/index.tsx @@ -3,138 +3,133 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + import { i18n } from '@kbn/i18n'; -import React, { useContext, useState } from 'react'; -import { euiStyled, EuiTheme, withTheme } from '../../../../observability/public'; + +import React from 'react'; +import { Route, RouteComponentProps, Switch } from 'react-router-dom'; + +import { EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; import { DocumentTitle } from '../../components/document_title'; +import { HelpCenterContent } from '../../components/help_center_content'; +import { RoutedTabs } from '../../components/navigation/routed_tabs'; +import { ColumnarPage } from '../../components/page'; import { Header } from '../../components/header'; -import { ColumnarPage, PageContent } from '../../components/page'; -import { withMetricPageProviders } from './page_providers'; -import { useMetadata } from '../../containers/metadata/use_metadata'; +import { MetricsExplorerOptionsContainer } from './metrics_explorer/hooks/use_metrics_explorer_options'; +import { WithMetricsExplorerOptionsUrlState } from '../../containers/metrics_explorer/with_metrics_explorer_options_url_state'; +import { WithSource } from '../../containers/with_source'; import { Source } from '../../containers/source'; -import { InfraLoadingPanel } from '../../components/loading'; -import { findInventoryModel } from '../../../common/inventory_models'; -import { NavItem } from './lib/side_nav_context'; -import { NodeDetailsPage } from './components/node_details_page'; +import { MetricsExplorerPage } from './metrics_explorer'; +import { SnapshotPage } from './inventory_view'; +import { MetricsSettingsPage } from './settings'; +import { AppNavigation } from '../../components/navigation/app_navigation'; +import { SourceLoadingPage } from '../../components/source_loading_page'; import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; -import { InventoryItemType } from '../../../common/inventory_models/types'; -import { useMetricsTimeContext } from './hooks/use_metrics_time'; -import { useLinkProps } from '../../hooks/use_link_props'; - -const DetailPageContent = euiStyled(PageContent)` - overflow: auto; - background-color: ${props => props.theme.eui.euiColorLightestShade}; -`; - -interface Props { - theme: EuiTheme; - match: { - params: { - type: string; - node: string; - }; - }; -} - -export const MetricDetail = withMetricPageProviders( - withTheme(({ match }: Props) => { - const uiCapabilities = useKibana().services.application?.capabilities; - const nodeId = match.params.node; - const nodeType = match.params.type as InventoryItemType; - const inventoryModel = findInventoryModel(nodeType); - const { sourceId } = useContext(Source.Context); - const { - timeRange, - parsedTimeRange, - setTimeRange, - refreshInterval, - setRefreshInterval, - isAutoReloading, - setAutoReload, - triggerRefresh, - } = useMetricsTimeContext(); - const { - name, - filteredRequiredMetrics, - loading: metadataLoading, - cloudId, - metadata, - } = useMetadata(nodeId, nodeType, inventoryModel.requiredMetrics, sourceId, parsedTimeRange); - - const [sideNav, setSideNav] = useState([]); +import { WaffleOptionsProvider } from './inventory_view/hooks/use_waffle_options'; +import { WaffleTimeProvider } from './inventory_view/hooks/use_waffle_time'; +import { WaffleFiltersProvider } from './inventory_view/hooks/use_waffle_filters'; +import { AlertDropdown } from '../../components/alerting/metrics/alert_dropdown'; - const addNavItem = React.useCallback( - (item: NavItem) => { - if (!sideNav.some(n => n.id === item.id)) { - setSideNav([item, ...sideNav]); - } - }, - [sideNav] - ); +export const InfrastructurePage = ({ match }: RouteComponentProps) => { + const uiCapabilities = useKibana().services.application?.capabilities; - const metricsLinkProps = useLinkProps({ - app: 'metrics', - pathname: '/', - }); + return ( + + + + + + - const breadcrumbs = [ - { - ...metricsLinkProps, - text: i18n.translate('xpack.infra.header.infrastructureTitle', { - defaultMessage: 'Metrics', - }), - }, - { text: name }, - ]; + - if (metadataLoading && !filteredRequiredMetrics.length) { - return ( - - ); - } +
+ + + + + + + + + + - return ( - -
- - - {metadata ? ( - - ) : null} - - - ); - }) -); + + + ( + + {({ configuration, createDerivedIndexPattern }) => ( + + + {configuration ? ( + + ) : ( + + )} + + )} + + )} + /> + + + + + + + + ); +}; diff --git a/x-pack/plugins/infra/public/components/inventory/layout.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/layout.tsx similarity index 78% rename from x-pack/plugins/infra/public/components/inventory/layout.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/layout.tsx index 3c91f9fa5946f..bc8be9862fe63 100644 --- a/x-pack/plugins/infra/public/components/inventory/layout.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/layout.tsx @@ -8,16 +8,16 @@ import React from 'react'; import { useInterval } from 'react-use'; import { euiPaletteColorBlind } from '@elastic/eui'; -import { NodesOverview } from '../nodes_overview'; +import { NodesOverview } from './nodes_overview'; import { Toolbar } from './toolbars/toolbar'; -import { PageContent } from '../page'; -import { useSnapshot } from '../../containers/waffle/use_snaphot'; -import { useInventoryMeta } from '../../containers/inventory_metadata/use_inventory_meta'; -import { useWaffleTimeContext } from '../../pages/inventory_view/hooks/use_waffle_time'; -import { useWaffleFiltersContext } from '../../pages/inventory_view/hooks/use_waffle_filters'; -import { useWaffleOptionsContext } from '../../pages/inventory_view/hooks/use_waffle_options'; -import { useSourceContext } from '../../containers/source'; -import { InfraFormatterType, InfraWaffleMapGradientLegend } from '../../lib/lib'; +import { PageContent } from '../../../../components/page'; +import { useSnapshot } from '../hooks/use_snaphot'; +import { useInventoryMeta } from '../hooks/use_inventory_meta'; +import { useWaffleTimeContext } from '../hooks/use_waffle_time'; +import { useWaffleFiltersContext } from '../hooks/use_waffle_filters'; +import { useWaffleOptionsContext } from '../hooks/use_waffle_options'; +import { useSourceContext } from '../../../../containers/source'; +import { InfraFormatterType, InfraWaffleMapGradientLegend } from '../../../../lib/lib'; const euiVisColorPalette = euiPaletteColorBlind(); diff --git a/x-pack/plugins/infra/public/components/nodes_overview/index.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/nodes_overview.tsx similarity index 88% rename from x-pack/plugins/infra/public/components/nodes_overview/index.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/nodes_overview.tsx index ef22e0486f892..afbfd2a079253 100644 --- a/x-pack/plugins/infra/public/components/nodes_overview/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/nodes_overview.tsx @@ -10,18 +10,25 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { get, max, min } from 'lodash'; import React from 'react'; -import { euiStyled } from '../../../../observability/public'; -import { InfraFormatterType, InfraWaffleMapBounds, InfraWaffleMapOptions } from '../../lib/lib'; -import { createFormatter } from '../../utils/formatters'; -import { NoData } from '../empty_states'; -import { InfraLoadingPanel } from '../loading'; -import { Map } from '../waffle/map'; -import { ViewSwitcher } from '../waffle/view_switcher'; -import { TableView } from './table'; -import { SnapshotNode, SnapshotCustomMetricInputRT } from '../../../common/http_api/snapshot_api'; -import { convertIntervalToString } from '../../utils/convert_interval_to_string'; -import { InventoryItemType } from '../../../common/inventory_models/types'; -import { createFormatterForMetric } from '../metrics_explorer/helpers/create_formatter_for_metric'; +import { euiStyled } from '../../../../../../observability/public'; +import { + InfraFormatterType, + InfraWaffleMapBounds, + InfraWaffleMapOptions, +} from '../../../../lib/lib'; +import { createFormatter } from '../../../../utils/formatters'; +import { NoData } from '../../../../components/empty_states'; +import { InfraLoadingPanel } from '../../../../components/loading'; +import { Map } from './waffle/map'; +import { ViewSwitcher } from './waffle/view_switcher'; +import { TableView } from './table_view'; +import { + SnapshotNode, + SnapshotCustomMetricInputRT, +} from '../../../../../common/http_api/snapshot_api'; +import { convertIntervalToString } from '../../../../utils/convert_interval_to_string'; +import { InventoryItemType } from '../../../../../common/inventory_models/types'; +import { createFormatterForMetric } from '../../metrics_explorer/components/helpers/create_formatter_for_metric'; export interface KueryFilterQuery { kind: 'kuery'; diff --git a/x-pack/plugins/infra/public/pages/inventory_view/compontents/search_bar.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/search_bar.tsx similarity index 86% rename from x-pack/plugins/infra/public/pages/inventory_view/compontents/search_bar.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/search_bar.tsx index f4fde46d434f8..1f84ef3685f34 100644 --- a/x-pack/plugins/infra/public/pages/inventory_view/compontents/search_bar.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/search_bar.tsx @@ -5,9 +5,9 @@ */ import React, { useContext } from 'react'; import { i18n } from '@kbn/i18n'; -import { Source } from '../../../containers/source'; -import { AutocompleteField } from '../../../components/autocomplete_field'; -import { WithKueryAutocompletion } from '../../../containers/with_kuery_autocompletion'; +import { Source } from '../../../../containers/source'; +import { AutocompleteField } from '../../../../components/autocomplete_field'; +import { WithKueryAutocompletion } from '../../../../containers/with_kuery_autocompletion'; import { useWaffleFiltersContext } from '../hooks/use_waffle_filters'; export const SearchBar = () => { diff --git a/x-pack/plugins/infra/public/components/nodes_overview/table.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/table_view.tsx similarity index 92% rename from x-pack/plugins/infra/public/components/nodes_overview/table.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/table_view.tsx index 82991076255ee..0557343e735f9 100644 --- a/x-pack/plugins/infra/public/components/nodes_overview/table.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/table_view.tsx @@ -9,13 +9,13 @@ import { i18n } from '@kbn/i18n'; import { last } from 'lodash'; import React, { useState, useCallback, useEffect } from 'react'; -import { createWaffleMapNode } from '../../containers/waffle/nodes_to_wafflemap'; -import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../lib/lib'; -import { fieldToName } from '../waffle/lib/field_to_display_name'; -import { NodeContextMenu } from '../waffle/node_context_menu'; -import { InventoryItemType } from '../../../common/inventory_models/types'; -import { SnapshotNode, SnapshotNodePath } from '../../../common/http_api/snapshot_api'; -import { CONTAINER_CLASSNAME } from '../../apps/start_app'; +import { createWaffleMapNode } from '../lib/nodes_to_wafflemap'; +import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../../../lib/lib'; +import { fieldToName } from '../lib/field_to_display_name'; +import { NodeContextMenu } from './waffle/node_context_menu'; +import { InventoryItemType } from '../../../../../common/inventory_models/types'; +import { SnapshotNode, SnapshotNodePath } from '../../../../../common/http_api/snapshot_api'; +import { CONTAINER_CLASSNAME } from '../../../../apps/start_app'; interface Props { nodes: SnapshotNode[]; diff --git a/x-pack/plugins/infra/public/components/inventory/toolbars/save_views.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/save_views.tsx similarity index 68% rename from x-pack/plugins/infra/public/components/inventory/toolbars/save_views.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/save_views.tsx index cb315d3e17b03..eb40ea595662a 100644 --- a/x-pack/plugins/infra/public/components/inventory/toolbars/save_views.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/save_views.tsx @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ import React from 'react'; -import { SavedViewsToolbarControls } from '../../saved_views/toolbar_control'; -import { inventoryViewSavedObjectType } from '../../../../common/saved_objects/inventory_view'; -import { useWaffleViewState } from '../../../pages/inventory_view/hooks/use_waffle_view_state'; +import { SavedViewsToolbarControls } from '../../../../../components/saved_views/toolbar_control'; +import { inventoryViewSavedObjectType } from '../../../../../../common/saved_objects/inventory_view'; +import { useWaffleViewState } from '../../hooks/use_waffle_view_state'; export const SavedViews = () => { const { viewState, defaultViewState, onViewChange } = useWaffleViewState(); diff --git a/x-pack/plugins/infra/public/components/inventory/toolbars/toolbar.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar.tsx similarity index 77% rename from x-pack/plugins/infra/public/components/inventory/toolbars/toolbar.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar.tsx index 63ab6d2f4465a..3ac9c2c189628 100644 --- a/x-pack/plugins/infra/public/components/inventory/toolbars/toolbar.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar.tsx @@ -10,15 +10,15 @@ import { SnapshotMetricInput, SnapshotGroupBy, SnapshotCustomMetricInput, -} from '../../../../common/http_api/snapshot_api'; -import { InventoryCloudAccount } from '../../../../common/http_api/inventory_meta_api'; -import { findToolbar } from '../../../../common/inventory_models/toolbars'; +} from '../../../../../../common/http_api/snapshot_api'; +import { InventoryCloudAccount } from '../../../../../../common/http_api/inventory_meta_api'; +import { findToolbar } from '../../../../../../common/inventory_models/toolbars'; import { ToolbarWrapper } from './toolbar_wrapper'; -import { InfraGroupByOptions } from '../../../lib/lib'; -import { IIndexPattern } from '../../../../../../../src/plugins/data/public'; -import { InventoryItemType } from '../../../../common/inventory_models/types'; -import { WaffleOptionsState } from '../../../pages/inventory_view/hooks/use_waffle_options'; +import { InfraGroupByOptions } from '../../../../../lib/lib'; +import { IIndexPattern } from '../../../../../../../../../src/plugins/data/public'; +import { InventoryItemType } from '../../../../../../common/inventory_models/types'; +import { WaffleOptionsState } from '../../hooks/use_waffle_options'; import { SavedViews } from './save_views'; export interface ToolbarProps diff --git a/x-pack/plugins/infra/public/components/inventory/toolbars/toolbar_wrapper.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar_wrapper.tsx similarity index 95% rename from x-pack/plugins/infra/public/components/inventory/toolbars/toolbar_wrapper.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar_wrapper.tsx index fefda94372cfb..86cc0d8ee62e0 100644 --- a/x-pack/plugins/infra/public/components/inventory/toolbars/toolbar_wrapper.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/toolbars/toolbar_wrapper.tsx @@ -7,12 +7,12 @@ import React from 'react'; import { EuiFlexGroup } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { SnapshotMetricType } from '../../../../common/inventory_models/types'; -import { Toolbar } from '../../eui/toolbar'; +import { SnapshotMetricType } from '../../../../../../common/inventory_models/types'; +import { Toolbar } from '../../../../../components/eui/toolbar'; import { ToolbarProps } from './toolbar'; -import { fieldToName } from '../../waffle/lib/field_to_display_name'; -import { useSourceContext } from '../../../containers/source'; -import { useWaffleOptionsContext } from '../../../pages/inventory_view/hooks/use_waffle_options'; +import { fieldToName } from '../../lib/field_to_display_name'; +import { useSourceContext } from '../../../../../containers/source'; +import { useWaffleOptionsContext } from '../../hooks/use_waffle_options'; interface Props { children: (props: Omit) => React.ReactElement; diff --git a/x-pack/plugins/infra/public/components/waffle/conditional_tooltip.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/conditional_tooltip.tsx similarity index 100% rename from x-pack/plugins/infra/public/components/waffle/conditional_tooltip.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/conditional_tooltip.tsx diff --git a/x-pack/plugins/infra/public/components/waffle/custom_field_panel.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/custom_field_panel.tsx similarity index 97% rename from x-pack/plugins/infra/public/components/waffle/custom_field_panel.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/custom_field_panel.tsx index d2dc535f6d6b3..090d53f1ff737 100644 --- a/x-pack/plugins/infra/public/components/waffle/custom_field_panel.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/custom_field_panel.tsx @@ -8,7 +8,7 @@ import { EuiButton, EuiComboBox, EuiForm, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; import { IFieldType } from 'src/plugins/data/public'; -import { InfraGroupByOptions } from '../../lib/lib'; +import { InfraGroupByOptions } from '../../../../../lib/lib'; interface Props { onSubmit: (field: string) => void; diff --git a/x-pack/plugins/infra/public/components/waffle/gradient_legend.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/gradient_legend.tsx similarity index 96% rename from x-pack/plugins/infra/public/components/waffle/gradient_legend.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/gradient_legend.tsx index 6b0c4bb41dc98..87f7e4cbff11e 100644 --- a/x-pack/plugins/infra/public/components/waffle/gradient_legend.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/gradient_legend.tsx @@ -6,13 +6,13 @@ import React from 'react'; -import { euiStyled } from '../../../../observability/public'; +import { euiStyled } from '../../../../../../../observability/public'; import { InfraFormatter, InfraWaffleMapBounds, InfraWaffleMapGradientLegend, InfraWaffleMapGradientRule, -} from '../../lib/lib'; +} from '../../../../../lib/lib'; interface Props { legend: InfraWaffleMapGradientLegend; diff --git a/x-pack/plugins/infra/public/components/waffle/group_name.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_name.tsx similarity index 96% rename from x-pack/plugins/infra/public/components/waffle/group_name.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_name.tsx index 01bd3600a1624..308460203b132 100644 --- a/x-pack/plugins/infra/public/components/waffle/group_name.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_name.tsx @@ -6,8 +6,8 @@ import { EuiLink, EuiToolTip } from '@elastic/eui'; import React from 'react'; -import { euiStyled } from '../../../../observability/public'; -import { InfraWaffleMapGroup, InfraWaffleMapOptions } from '../../lib/lib'; +import { euiStyled } from '../../../../../../../observability/public'; +import { InfraWaffleMapGroup, InfraWaffleMapOptions } from '../../../../../lib/lib'; interface Props { onDrilldown: (filter: string) => void; diff --git a/x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_of_groups.tsx similarity index 90% rename from x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_of_groups.tsx index 9634293587d49..6b3f22007f580 100644 --- a/x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_of_groups.tsx @@ -6,15 +6,15 @@ import React from 'react'; -import { euiStyled } from '../../../../observability/public'; +import { euiStyled } from '../../../../../../../observability/public'; import { InfraWaffleMapBounds, InfraWaffleMapGroupOfGroups, InfraWaffleMapOptions, -} from '../../lib/lib'; +} from '../../../../../lib/lib'; import { GroupName } from './group_name'; import { GroupOfNodes } from './group_of_nodes'; -import { InventoryItemType } from '../../../common/inventory_models/types'; +import { InventoryItemType } from '../../../../../../common/inventory_models/types'; interface Props { onDrilldown: (filter: string) => void; diff --git a/x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_of_nodes.tsx similarity index 90% rename from x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_of_nodes.tsx index 6b82671617df7..fc438ed4ca0a2 100644 --- a/x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/group_of_nodes.tsx @@ -6,15 +6,15 @@ import React from 'react'; -import { euiStyled } from '../../../../observability/public'; +import { euiStyled } from '../../../../../../../observability/public'; import { InfraWaffleMapBounds, InfraWaffleMapGroupOfNodes, InfraWaffleMapOptions, -} from '../../lib/lib'; +} from '../../../../../lib/lib'; import { GroupName } from './group_name'; import { Node } from './node'; -import { InventoryItemType } from '../../../common/inventory_models/types'; +import { InventoryItemType } from '../../../../../../common/inventory_models/types'; interface Props { onDrilldown: (filter: string) => void; diff --git a/x-pack/plugins/infra/public/components/waffle/legend.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/legend.tsx similarity index 88% rename from x-pack/plugins/infra/public/components/waffle/legend.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/legend.tsx index 13e533b225d4d..ccb4cc71924f4 100644 --- a/x-pack/plugins/infra/public/components/waffle/legend.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/legend.tsx @@ -5,13 +5,13 @@ */ import React from 'react'; -import { euiStyled } from '../../../../observability/public'; -import { InfraFormatter, InfraWaffleMapBounds, InfraWaffleMapLegend } from '../../lib/lib'; +import { euiStyled } from '../../../../../../../observability/public'; +import { InfraFormatter, InfraWaffleMapBounds, InfraWaffleMapLegend } from '../../../../../lib/lib'; import { GradientLegend } from './gradient_legend'; import { LegendControls } from './legend_controls'; -import { isInfraWaffleMapGradientLegend, isInfraWaffleMapStepLegend } from './lib/type_guards'; +import { isInfraWaffleMapGradientLegend, isInfraWaffleMapStepLegend } from '../../lib/type_guards'; import { StepLegend } from './steps_legend'; -import { useWaffleOptionsContext } from '../../pages/inventory_view/hooks/use_waffle_options'; +import { useWaffleOptionsContext } from '../../hooks/use_waffle_options'; interface Props { legend: InfraWaffleMapLegend; bounds: InfraWaffleMapBounds; diff --git a/x-pack/plugins/infra/public/components/waffle/legend_controls.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/legend_controls.tsx similarity index 97% rename from x-pack/plugins/infra/public/components/waffle/legend_controls.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/legend_controls.tsx index 26b5b1c0af727..6ec21ad2e1b49 100644 --- a/x-pack/plugins/infra/public/components/waffle/legend_controls.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/legend_controls.tsx @@ -23,8 +23,8 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { SyntheticEvent, useState } from 'react'; -import { euiStyled } from '../../../../observability/public'; -import { InfraWaffleMapBounds } from '../../lib/lib'; +import { euiStyled } from '../../../../../../../observability/public'; +import { InfraWaffleMapBounds } from '../../../../../lib/lib'; interface Props { onChange: (options: { auto: boolean; bounds: InfraWaffleMapBounds }) => void; diff --git a/x-pack/plugins/infra/public/components/waffle/map.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/map.tsx similarity index 84% rename from x-pack/plugins/infra/public/components/waffle/map.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/map.tsx index 7cab2307dacfa..e34c63d332fd8 100644 --- a/x-pack/plugins/infra/public/components/waffle/map.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/map.tsx @@ -5,20 +5,17 @@ */ import React from 'react'; -import { euiStyled } from '../../../../observability/public'; -import { nodesToWaffleMap } from '../../containers/waffle/nodes_to_wafflemap'; -import { - isWaffleMapGroupWithGroups, - isWaffleMapGroupWithNodes, -} from '../../containers/waffle/type_guards'; -import { InfraWaffleMapBounds, InfraWaffleMapOptions } from '../../lib/lib'; -import { AutoSizer } from '../auto_sizer'; +import { euiStyled } from '../../../../../../../observability/public'; +import { nodesToWaffleMap } from '../../lib/nodes_to_wafflemap'; +import { isWaffleMapGroupWithGroups, isWaffleMapGroupWithNodes } from '../../lib/type_guards'; +import { InfraWaffleMapBounds, InfraWaffleMapOptions } from '../../../../../lib/lib'; +import { AutoSizer } from '../../../../../components/auto_sizer'; import { GroupOfGroups } from './group_of_groups'; import { GroupOfNodes } from './group_of_nodes'; import { Legend } from './legend'; -import { applyWaffleMapLayout } from './lib/apply_wafflemap_layout'; -import { SnapshotNode } from '../../../common/http_api/snapshot_api'; -import { InventoryItemType } from '../../../common/inventory_models/types'; +import { applyWaffleMapLayout } from '../../lib/apply_wafflemap_layout'; +import { SnapshotNode } from '../../../../../../common/http_api/snapshot_api'; +import { InventoryItemType } from '../../../../../../common/inventory_models/types'; interface Props { nodes: SnapshotNode[]; diff --git a/x-pack/plugins/infra/public/components/waffle/metric_control/custom_metric_form.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/custom_metric_form.tsx similarity index 97% rename from x-pack/plugins/infra/public/components/waffle/metric_control/custom_metric_form.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/custom_metric_form.tsx index 26e42061ed10b..aec624c0aff1f 100644 --- a/x-pack/plugins/infra/public/components/waffle/metric_control/custom_metric_form.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/custom_metric_form.tsx @@ -26,8 +26,11 @@ import { SnapshotCustomMetricInput, SNAPSHOT_CUSTOM_AGGREGATIONS, SnapshotCustomAggregationRT, -} from '../../../../common/http_api/snapshot_api'; -import { EuiTheme, withTheme } from '../../../../../../legacy/common/eui_styled_components'; +} from '../../../../../../../common/http_api/snapshot_api'; +import { + EuiTheme, + withTheme, +} from '../../../../../../../../../legacy/common/eui_styled_components'; interface SelectedOption { label: string; diff --git a/x-pack/plugins/infra/public/components/waffle/metric_control/get_custom_metric_label.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/get_custom_metric_label.ts similarity index 91% rename from x-pack/plugins/infra/public/components/waffle/metric_control/get_custom_metric_label.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/get_custom_metric_label.ts index 4f88c1b29c1f2..495cc8197d2e7 100644 --- a/x-pack/plugins/infra/public/components/waffle/metric_control/get_custom_metric_label.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/get_custom_metric_label.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { SnapshotCustomMetricInput } from '../../../../common/http_api/snapshot_api'; +import { SnapshotCustomMetricInput } from '../../../../../../../common/http_api/snapshot_api'; export const getCustomMetricLabel = (metric: SnapshotCustomMetricInput) => { const METRIC_LABELS = { diff --git a/x-pack/plugins/infra/public/components/waffle/metric_control/index.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/index.tsx similarity index 97% rename from x-pack/plugins/infra/public/components/waffle/metric_control/index.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/index.tsx index 0f2034fe9cb25..08d5b3e9e0670 100644 --- a/x-pack/plugins/infra/public/components/waffle/metric_control/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/index.tsx @@ -13,14 +13,14 @@ import { SnapshotMetricInput, SnapshotCustomMetricInput, SnapshotCustomMetricInputRT, -} from '../../../../common/http_api/snapshot_api'; +} from '../../../../../../../common/http_api/snapshot_api'; import { CustomMetricForm } from './custom_metric_form'; import { getCustomMetricLabel } from './get_custom_metric_label'; import { MetricsContextMenu } from './metrics_context_menu'; import { ModeSwitcher } from './mode_switcher'; import { MetricsEditMode } from './metrics_edit_mode'; import { CustomMetricMode } from './types'; -import { SnapshotMetricType } from '../../../../common/inventory_models/types'; +import { SnapshotMetricType } from '../../../../../../../common/inventory_models/types'; interface Props { options: Array<{ text: string; value: string }>; diff --git a/x-pack/plugins/infra/public/components/waffle/metric_control/metrics_context_menu.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/metrics_context_menu.tsx similarity index 94% rename from x-pack/plugins/infra/public/components/waffle/metric_control/metrics_context_menu.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/metrics_context_menu.tsx index 1aacf54244c37..1cdef493aee4f 100644 --- a/x-pack/plugins/infra/public/components/waffle/metric_control/metrics_context_menu.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/metrics_context_menu.tsx @@ -9,11 +9,11 @@ import { SnapshotMetricInput, SnapshotCustomMetricInput, SnapshotCustomMetricInputRT, -} from '../../../../common/http_api/snapshot_api'; +} from '../../../../../../../common/http_api/snapshot_api'; import { SnapshotMetricTypeRT, SnapshotMetricType, -} from '../../../../common/inventory_models/types'; +} from '../../../../../../../common/inventory_models/types'; import { getCustomMetricLabel } from './get_custom_metric_label'; interface Props { diff --git a/x-pack/plugins/infra/public/components/waffle/metric_control/metrics_edit_mode.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/metrics_edit_mode.tsx similarity index 92% rename from x-pack/plugins/infra/public/components/waffle/metric_control/metrics_edit_mode.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/metrics_edit_mode.tsx index ba1f46815db20..4d1bc906de0b9 100644 --- a/x-pack/plugins/infra/public/components/waffle/metric_control/metrics_edit_mode.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/metrics_edit_mode.tsx @@ -6,9 +6,12 @@ import React from 'react'; import { EuiFlexItem, EuiFlexGroup, EuiButtonIcon } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { SnapshotCustomMetricInput } from '../../../../common/http_api/snapshot_api'; +import { SnapshotCustomMetricInput } from '../../../../../../../common/http_api/snapshot_api'; import { getCustomMetricLabel } from './get_custom_metric_label'; -import { EuiTheme, withTheme } from '../../../../../../legacy/common/eui_styled_components'; +import { + EuiTheme, + withTheme, +} from '../../../../../../../../../legacy/common/eui_styled_components'; interface Props { theme: EuiTheme; diff --git a/x-pack/plugins/infra/public/components/waffle/metric_control/mode_switcher.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/mode_switcher.tsx similarity index 95% rename from x-pack/plugins/infra/public/components/waffle/metric_control/mode_switcher.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/mode_switcher.tsx index 43bb904594c68..acb740f1750c8 100644 --- a/x-pack/plugins/infra/public/components/waffle/metric_control/mode_switcher.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/mode_switcher.tsx @@ -8,8 +8,11 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { CustomMetricMode } from './types'; -import { SnapshotCustomMetricInput } from '../../../../common/http_api/snapshot_api'; -import { EuiTheme, withTheme } from '../../../../../../legacy/common/eui_styled_components'; +import { SnapshotCustomMetricInput } from '../../../../../../../common/http_api/snapshot_api'; +import { + EuiTheme, + withTheme, +} from '../../../../../../../../../legacy/common/eui_styled_components'; interface Props { theme: EuiTheme; diff --git a/x-pack/plugins/infra/public/components/waffle/metric_control/types.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/types.ts similarity index 100% rename from x-pack/plugins/infra/public/components/waffle/metric_control/types.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/metric_control/types.ts diff --git a/x-pack/plugins/infra/public/components/waffle/node.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/node.tsx similarity index 93% rename from x-pack/plugins/infra/public/components/waffle/node.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/node.tsx index 4eb5ccb8c1b4d..fd5b5b01f329f 100644 --- a/x-pack/plugins/infra/public/components/waffle/node.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/node.tsx @@ -10,11 +10,15 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { ConditionalToolTip } from './conditional_tooltip'; -import { euiStyled } from '../../../../observability/public'; -import { InfraWaffleMapBounds, InfraWaffleMapNode, InfraWaffleMapOptions } from '../../lib/lib'; -import { colorFromValue } from './lib/color_from_value'; +import { euiStyled } from '../../../../../../../observability/public'; +import { + InfraWaffleMapBounds, + InfraWaffleMapNode, + InfraWaffleMapOptions, +} from '../../../../../lib/lib'; +import { colorFromValue } from '../../lib/color_from_value'; import { NodeContextMenu } from './node_context_menu'; -import { InventoryItemType } from '../../../common/inventory_models/types'; +import { InventoryItemType } from '../../../../../../common/inventory_models/types'; const initialState = { isPopoverOpen: false, diff --git a/x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/node_context_menu.tsx similarity index 91% rename from x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/node_context_menu.tsx index 5f05cebd8f616..275635a33ec26 100644 --- a/x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/node_context_menu.tsx @@ -9,12 +9,13 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React, { useMemo, useState } from 'react'; -import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../lib/lib'; -import { getNodeDetailUrl, getNodeLogsUrl } from '../../pages/link_to'; -import { createUptimeLink } from './lib/create_uptime_link'; -import { findInventoryModel, findInventoryFields } from '../../../common/inventory_models'; -import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; -import { InventoryItemType } from '../../../common/inventory_models/types'; +import { AlertFlyout } from '../../../../../components/alerting/metrics/alert_flyout'; +import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../../../../lib/lib'; +import { getNodeDetailUrl, getNodeLogsUrl } from '../../../../link_to'; +import { createUptimeLink } from '../../lib/create_uptime_link'; +import { findInventoryModel, findInventoryFields } from '../../../../../../common/inventory_models'; +import { useKibana } from '../../../../../../../../../src/plugins/kibana_react/public'; +import { InventoryItemType } from '../../../../../../common/inventory_models/types'; import { Section, SectionLinkProps, @@ -23,9 +24,8 @@ import { SectionSubtitle, SectionLinks, SectionLink, -} from '../../../../observability/public'; -import { useLinkProps } from '../../hooks/use_link_props'; -import { AlertFlyout } from '../alerting/metrics/alert_flyout'; +} from '../../../../../../../observability/public'; +import { useLinkProps } from '../../../../../hooks/use_link_props'; interface Props { options: InfraWaffleMapOptions; diff --git a/x-pack/plugins/infra/public/components/waffle/steps_legend.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/steps_legend.tsx similarity index 95% rename from x-pack/plugins/infra/public/components/waffle/steps_legend.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/steps_legend.tsx index d2079d53dad71..1ef0f2d0c4288 100644 --- a/x-pack/plugins/infra/public/components/waffle/steps_legend.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/steps_legend.tsx @@ -7,13 +7,13 @@ import { darken } from 'polished'; import React from 'react'; -import { euiStyled } from '../../../../observability/public'; +import { euiStyled } from '../../../../../../../observability/public'; import { InfraFormatter, InfraWaffleMapRuleOperator, InfraWaffleMapStepLegend, InfraWaffleMapStepRule, -} from '../../lib/lib'; +} from '../../../../../lib/lib'; const OPERATORS = { [InfraWaffleMapRuleOperator.gte]: '>=', diff --git a/x-pack/plugins/infra/public/components/waffle/view_switcher.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/view_switcher.tsx similarity index 100% rename from x-pack/plugins/infra/public/components/waffle/view_switcher.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/view_switcher.tsx diff --git a/x-pack/plugins/infra/public/components/waffle/waffle_accounts_controls.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_accounts_controls.tsx similarity index 94% rename from x-pack/plugins/infra/public/components/waffle/waffle_accounts_controls.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_accounts_controls.tsx index 56c3a205b05d4..a8b0cf21bce85 100644 --- a/x-pack/plugins/infra/public/components/waffle/waffle_accounts_controls.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_accounts_controls.tsx @@ -14,7 +14,7 @@ import { import React, { useCallback, useState, useMemo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { InventoryCloudAccount } from '../../../common/http_api/inventory_meta_api'; +import { InventoryCloudAccount } from '../../../../../../common/http_api/inventory_meta_api'; interface Props { accountId: string; @@ -24,7 +24,7 @@ interface Props { export const WaffleAccountsControls = (props: Props) => { const { accountId, options } = props; - const [isOpen, setIsOpen] = useState(); + const [isOpen, setIsOpen] = useState(false); const showPopover = useCallback(() => { setIsOpen(true); diff --git a/x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_group_by_controls.tsx similarity index 95% rename from x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_group_by_controls.tsx index 1a3cef591bc07..bc763d2cf9378 100644 --- a/x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_group_by_controls.tsx @@ -17,11 +17,11 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; import { IFieldType } from 'src/plugins/data/public'; -import { InfraGroupByOptions } from '../../lib/lib'; +import { InfraGroupByOptions } from '../../../../../lib/lib'; import { CustomFieldPanel } from './custom_field_panel'; -import { euiStyled } from '../../../../observability/public'; -import { InventoryItemType } from '../../../common/inventory_models/types'; -import { SnapshotGroupBy } from '../../../common/http_api/snapshot_api'; +import { euiStyled } from '../../../../../../../observability/public'; +import { InventoryItemType } from '../../../../../../common/inventory_models/types'; +import { SnapshotGroupBy } from '../../../../../../common/http_api/snapshot_api'; interface Props { options: Array<{ text: string; field: string; toolTipContent?: string }>; diff --git a/x-pack/plugins/infra/public/components/waffle/waffle_inventory_switcher.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_inventory_switcher.tsx similarity index 94% rename from x-pack/plugins/infra/public/components/waffle/waffle_inventory_switcher.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_inventory_switcher.tsx index 21da10a0a7650..23e06823f407f 100644 --- a/x-pack/plugins/infra/public/components/waffle/waffle_inventory_switcher.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_inventory_switcher.tsx @@ -14,9 +14,9 @@ import { import React, { useCallback, useState, useMemo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { findInventoryModel } from '../../../common/inventory_models'; -import { InventoryItemType } from '../../../common/inventory_models/types'; -import { useWaffleOptionsContext } from '../../pages/inventory_view/hooks/use_waffle_options'; +import { findInventoryModel } from '../../../../../../common/inventory_models'; +import { InventoryItemType } from '../../../../../../common/inventory_models/types'; +import { useWaffleOptionsContext } from '../../hooks/use_waffle_options'; const getDisplayNameForType = (type: InventoryItemType) => { const inventoryModel = findInventoryModel(type); diff --git a/x-pack/plugins/infra/public/components/waffle/waffle_region_controls.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_region_controls.tsx similarity index 97% rename from x-pack/plugins/infra/public/components/waffle/waffle_region_controls.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_region_controls.tsx index 52377bf4b8296..671e44f42ef6a 100644 --- a/x-pack/plugins/infra/public/components/waffle/waffle_region_controls.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_region_controls.tsx @@ -23,7 +23,7 @@ interface Props { export const WaffleRegionControls = (props: Props) => { const { region, options } = props; - const [isOpen, setIsOpen] = useState(); + const [isOpen, setIsOpen] = useState(false); const showPopover = useCallback(() => { setIsOpen(true); diff --git a/x-pack/plugins/infra/public/components/waffle/waffle_time_controls.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_time_controls.tsx similarity index 95% rename from x-pack/plugins/infra/public/components/waffle/waffle_time_controls.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_time_controls.tsx index 458bb674afade..7f190f21484d9 100644 --- a/x-pack/plugins/infra/public/components/waffle/waffle_time_controls.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/waffle/waffle_time_controls.tsx @@ -8,7 +8,7 @@ import { EuiButtonEmpty, EuiDatePicker, EuiFormControlLayout } from '@elastic/eu import { FormattedMessage } from '@kbn/i18n/react'; import moment, { Moment } from 'moment'; import React, { useCallback } from 'react'; -import { useWaffleTimeContext } from '../../pages/inventory_view/hooks/use_waffle_time'; +import { useWaffleTimeContext } from '../../hooks/use_waffle_time'; export const WaffleTimeControls = () => { const { diff --git a/x-pack/plugins/infra/public/containers/inventory_metadata/use_inventory_meta.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_inventory_meta.ts similarity index 79% rename from x-pack/plugins/infra/public/containers/inventory_metadata/use_inventory_meta.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_inventory_meta.ts index 0ed1f3e35449b..b038491690a13 100644 --- a/x-pack/plugins/infra/public/containers/inventory_metadata/use_inventory_meta.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_inventory_meta.ts @@ -7,13 +7,13 @@ import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; import { useEffect } from 'react'; -import { throwErrors, createPlainError } from '../../../common/runtime_types'; -import { useHTTPRequest } from '../../hooks/use_http_request'; +import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; +import { useHTTPRequest } from '../../../../hooks/use_http_request'; import { InventoryMetaResponseRT, InventoryMetaResponse, -} from '../../../common/http_api/inventory_meta_api'; -import { InventoryItemType } from '../../../common/inventory_models/types'; +} from '../../../../../common/http_api/inventory_meta_api'; +import { InventoryItemType } from '../../../../../common/inventory_models/types'; export function useInventoryMeta(sourceId: string, nodeType: InventoryItemType) { const decodeResponse = (response: any) => { diff --git a/x-pack/plugins/infra/public/containers/waffle/use_snaphot.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_snaphot.ts similarity index 83% rename from x-pack/plugins/infra/public/containers/waffle/use_snaphot.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_snaphot.ts index 31f02f46caeda..3ec63d7b2de28 100644 --- a/x-pack/plugins/infra/public/containers/waffle/use_snaphot.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_snaphot.ts @@ -8,14 +8,17 @@ import { useEffect } from 'react'; import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; -import { throwErrors, createPlainError } from '../../../common/runtime_types'; -import { useHTTPRequest } from '../../hooks/use_http_request'; +import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; +import { useHTTPRequest } from '../../../../hooks/use_http_request'; import { SnapshotNodeResponseRT, SnapshotNodeResponse, SnapshotGroupBy, -} from '../../../common/http_api/snapshot_api'; -import { InventoryItemType, SnapshotMetricType } from '../../../common/inventory_models/types'; +} from '../../../../../common/http_api/snapshot_api'; +import { + InventoryItemType, + SnapshotMetricType, +} from '../../../../../common/inventory_models/types'; export function useSnapshot( filterQuery: string | null | undefined, diff --git a/x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_filters.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_filters.ts similarity index 90% rename from x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_filters.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_filters.ts index 02c079dcaddc4..f6cbb59779039 100644 --- a/x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_filters.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_filters.ts @@ -10,10 +10,10 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { fold } from 'fp-ts/lib/Either'; import { constant, identity } from 'fp-ts/lib/function'; import createContainter from 'constate'; -import { useUrlState } from '../../../utils/use_url_state'; -import { useSourceContext } from '../../../containers/source'; -import { convertKueryToElasticSearchQuery } from '../../../utils/kuery'; -import { esKuery } from '../../../../../../../src/plugins/data/public'; +import { useUrlState } from '../../../../utils/use_url_state'; +import { useSourceContext } from '../../../../containers/source'; +import { convertKueryToElasticSearchQuery } from '../../../../utils/kuery'; +import { esKuery } from '../../../../../../../../src/plugins/data/public'; const validateKuery = (expression: string) => { try { diff --git a/x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_options.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_options.ts similarity index 95% rename from x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_options.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_options.ts index 2853917d5f683..32bfe6e085b4e 100644 --- a/x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_options.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_options.ts @@ -17,9 +17,9 @@ import { SnapshotMetricInputRT, SnapshotGroupByRT, SnapshotCustomMetricInputRT, -} from '../../../../common/http_api/snapshot_api'; -import { useUrlState } from '../../../utils/use_url_state'; -import { InventoryItemType, ItemTypeRT } from '../../../../common/inventory_models/types'; +} from '../../../../../common/http_api/snapshot_api'; +import { useUrlState } from '../../../../utils/use_url_state'; +import { InventoryItemType, ItemTypeRT } from '../../../../../common/inventory_models/types'; export const DEFAULT_WAFFLE_OPTIONS_STATE: WaffleOptionsState = { metric: { type: 'cpu' }, diff --git a/x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_time.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_time.ts similarity index 97% rename from x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_time.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_time.ts index 051b5e598cb75..db3abd37b58dd 100644 --- a/x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_time.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_time.ts @@ -9,7 +9,7 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { fold } from 'fp-ts/lib/Either'; import { constant, identity } from 'fp-ts/lib/function'; import createContainer from 'constate'; -import { useUrlState } from '../../../utils/use_url_state'; +import { useUrlState } from '../../../../utils/use_url_state'; export const DEFAULT_WAFFLE_TIME_STATE: WaffleTimeState = { currentTime: Date.now(), diff --git a/x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_view_state.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_view_state.ts similarity index 100% rename from x-pack/plugins/infra/public/pages/inventory_view/hooks/use_waffle_view_state.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_waffle_view_state.ts diff --git a/x-pack/plugins/infra/public/pages/infrastructure/snapshot/index.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/index.tsx similarity index 98% rename from x-pack/plugins/infra/public/pages/infrastructure/snapshot/index.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/index.tsx index 48cc56388c0f2..e473aea7a1f0b 100644 --- a/x-pack/plugins/infra/public/pages/infrastructure/snapshot/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/index.tsx @@ -20,7 +20,7 @@ import { ViewSourceConfigurationButton } from '../../../components/source_config import { Source } from '../../../containers/source'; import { useTrackPageview } from '../../../../../observability/public'; import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; -import { Layout } from '../../../components/inventory/layout'; +import { Layout } from './components/layout'; import { useLinkProps } from '../../../hooks/use_link_props'; export const SnapshotPage = () => { diff --git a/x-pack/plugins/infra/public/components/waffle/lib/apply_wafflemap_layout.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/apply_wafflemap_layout.ts similarity index 94% rename from x-pack/plugins/infra/public/components/waffle/lib/apply_wafflemap_layout.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/apply_wafflemap_layout.ts index 5f3c06fcfbba7..68600ac5d2ce4 100644 --- a/x-pack/plugins/infra/public/components/waffle/lib/apply_wafflemap_layout.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/apply_wafflemap_layout.ts @@ -4,11 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ import { first, sortBy } from 'lodash'; -import { - isWaffleMapGroupWithGroups, - isWaffleMapGroupWithNodes, -} from '../../../containers/waffle/type_guards'; -import { InfraWaffleMapGroup } from '../../../lib/lib'; +import { isWaffleMapGroupWithGroups, isWaffleMapGroupWithNodes } from './type_guards'; +import { InfraWaffleMapGroup } from '../../../../lib/lib'; import { sizeOfSquares } from './size_of_squares'; export function getColumns(n: number, w = 1, h = 1) { diff --git a/x-pack/plugins/infra/public/components/waffle/lib/color_from_value.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/color_from_value.ts similarity index 98% rename from x-pack/plugins/infra/public/components/waffle/lib/color_from_value.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/color_from_value.ts index c082686bb9d63..334865306ee88 100644 --- a/x-pack/plugins/infra/public/components/waffle/lib/color_from_value.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/color_from_value.ts @@ -12,7 +12,7 @@ import { InfraWaffleMapLegend, InfraWaffleMapRuleOperator, InfraWaffleMapStepLegend, -} from '../../../lib/lib'; +} from '../../../../lib/lib'; import { isInfraWaffleMapGradientLegend, isInfraWaffleMapStepLegend } from './type_guards'; const OPERATOR_TO_FN = { diff --git a/x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.test.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_uptime_link.test.ts similarity index 96% rename from x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.test.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_uptime_link.test.ts index 902969c83ba39..5f760cf2f591e 100644 --- a/x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.test.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_uptime_link.test.ts @@ -5,8 +5,8 @@ */ import { createUptimeLink } from './create_uptime_link'; -import { InfraWaffleMapOptions, InfraFormatterType } from '../../../lib/lib'; -import { SnapshotMetricType } from '../../../../common/inventory_models/types'; +import { InfraWaffleMapOptions, InfraFormatterType } from '../../../../lib/lib'; +import { SnapshotMetricType } from '../../../../../common/inventory_models/types'; const options: InfraWaffleMapOptions = { fields: { diff --git a/x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_uptime_link.ts similarity index 83% rename from x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_uptime_link.ts index 72b46f4fb5c7b..6c089ee8d22f4 100644 --- a/x-pack/plugins/infra/public/components/waffle/lib/create_uptime_link.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/create_uptime_link.ts @@ -5,9 +5,9 @@ */ import { get } from 'lodash'; -import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../../lib/lib'; -import { InventoryItemType } from '../../../../common/inventory_models/types'; -import { LinkDescriptor } from '../../../hooks/use_link_props'; +import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../../../lib/lib'; +import { InventoryItemType } from '../../../../../common/inventory_models/types'; +import { LinkDescriptor } from '../../../../hooks/use_link_props'; export const createUptimeLink = ( options: InfraWaffleMapOptions, diff --git a/x-pack/plugins/infra/public/components/waffle/lib/field_to_display_name.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/field_to_display_name.ts similarity index 100% rename from x-pack/plugins/infra/public/components/waffle/lib/field_to_display_name.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/field_to_display_name.ts diff --git a/x-pack/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/nodes_to_wafflemap.ts similarity index 97% rename from x-pack/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/nodes_to_wafflemap.ts index d2511ba7e669e..469b54b2d9d68 100644 --- a/x-pack/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/nodes_to_wafflemap.ts @@ -11,9 +11,9 @@ import { InfraWaffleMapGroupOfGroups, InfraWaffleMapGroupOfNodes, InfraWaffleMapNode, -} from '../../lib/lib'; +} from '../../../../lib/lib'; import { isWaffleMapGroupWithGroups, isWaffleMapGroupWithNodes } from './type_guards'; -import { SnapshotNodePath, SnapshotNode } from '../../../common/http_api/snapshot_api'; +import { SnapshotNodePath, SnapshotNode } from '../../../../../common/http_api/snapshot_api'; export function createId(path: SnapshotNodePath[]) { return path.map(p => p.value).join('/'); diff --git a/x-pack/plugins/infra/public/components/waffle/lib/size_of_squares.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/size_of_squares.ts similarity index 100% rename from x-pack/plugins/infra/public/components/waffle/lib/size_of_squares.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/size_of_squares.ts diff --git a/x-pack/plugins/infra/public/containers/waffle/type_guards.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/type_guards.ts similarity index 55% rename from x-pack/plugins/infra/public/containers/waffle/type_guards.ts rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/type_guards.ts index 3e21e3a56a6c6..62d02022d4c93 100644 --- a/x-pack/plugins/infra/public/containers/waffle/type_guards.ts +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/lib/type_guards.ts @@ -4,7 +4,22 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraWaffleMapGroupOfGroups, InfraWaffleMapGroupOfNodes } from '../../lib/lib'; +import { + InfraWaffleMapGroupOfGroups, + InfraWaffleMapGroupOfNodes, + InfraWaffleMapGradientLegend, + InfraWaffleMapStepLegend, +} from '../../../../lib/lib'; + +export function isInfraWaffleMapStepLegend(subject: any): subject is InfraWaffleMapStepLegend { + return subject.type && subject.type === 'step'; +} + +export function isInfraWaffleMapGradientLegend( + subject: any +): subject is InfraWaffleMapGradientLegend { + return subject.type && subject.type === 'gradient'; +} export function isWaffleMapGroupWithNodes(subject: any): subject is InfraWaffleMapGroupOfNodes { return subject && subject.nodes != null && Array.isArray(subject.nodes); diff --git a/x-pack/plugins/infra/public/pages/infrastructure/snapshot/toolbar.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/toolbar.tsx similarity index 75% rename from x-pack/plugins/infra/public/pages/infrastructure/snapshot/toolbar.tsx rename to x-pack/plugins/infra/public/pages/metrics/inventory_view/toolbar.tsx index ccdaa5e8dc785..d6a87a0197f5f 100644 --- a/x-pack/plugins/infra/public/pages/infrastructure/snapshot/toolbar.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/toolbar.tsx @@ -8,9 +8,9 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React from 'react'; import { Toolbar } from '../../../components/eui/toolbar'; -import { WaffleTimeControls } from '../../../components/waffle/waffle_time_controls'; -import { WaffleInventorySwitcher } from '../../../components/waffle/waffle_inventory_switcher'; -import { SearchBar } from '../../inventory_view/compontents/search_bar'; +import { WaffleTimeControls } from './components/waffle/waffle_time_controls'; +import { WaffleInventorySwitcher } from './components/waffle/waffle_inventory_switcher'; +import { SearchBar } from './components/search_bar'; export const SnapshotToolbar = () => ( diff --git a/x-pack/plugins/infra/public/pages/metrics/components/chart_section_vis.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/chart_section_vis.tsx similarity index 94% rename from x-pack/plugins/infra/public/pages/metrics/components/chart_section_vis.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/chart_section_vis.tsx index 290f0eda452ce..588a0d84918c6 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/chart_section_vis.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/chart_section_vis.tsx @@ -8,7 +8,7 @@ import moment from 'moment'; import { i18n } from '@kbn/i18n'; import { Axis, Chart, niceTimeFormatter, Position, Settings, TooltipValue } from '@elastic/charts'; import { EuiPageContentBody } from '@elastic/eui'; -import { getChartTheme } from '../../../components/metrics_explorer/helpers/get_chart_theme'; +import { getChartTheme } from '../../metrics_explorer/components/helpers/get_chart_theme'; import { SeriesChart } from './series_chart'; import { getFormatter, @@ -19,8 +19,8 @@ import { seriesHasLessThen2DataPoints, } from './helpers'; import { ErrorMessage } from './error_message'; -import { useKibanaUiSetting } from '../../../utils/use_kibana_ui_setting'; -import { useUiSetting } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibanaUiSetting } from '../../../../utils/use_kibana_ui_setting'; +import { useUiSetting } from '../../../../../../../../src/plugins/kibana_react/public'; import { VisSectionProps } from '../types'; export const ChartSectionVis = ({ diff --git a/x-pack/plugins/infra/public/pages/metrics/components/error_message.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/error_message.tsx similarity index 100% rename from x-pack/plugins/infra/public/pages/metrics/components/error_message.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/error_message.tsx diff --git a/x-pack/plugins/infra/public/pages/metrics/components/gauges_section_vis.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/gauges_section_vis.tsx similarity index 92% rename from x-pack/plugins/infra/public/pages/metrics/components/gauges_section_vis.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/gauges_section_vis.tsx index e069b52be8be7..0aab676b7d6c5 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/gauges_section_vis.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/gauges_section_vis.tsx @@ -16,9 +16,9 @@ import { import { get, last, max } from 'lodash'; import React, { ReactText } from 'react'; -import { euiStyled } from '../../../../../observability/public'; -import { createFormatter } from '../../../utils/formatters'; -import { InventoryFormatterType } from '../../../../common/inventory_models/types'; +import { euiStyled } from '../../../../../../observability/public'; +import { createFormatter } from '../../../../utils/formatters'; +import { InventoryFormatterType } from '../../../../../common/inventory_models/types'; import { SeriesOverrides, VisSectionProps } from '../types'; import { getChartName } from './helpers'; diff --git a/x-pack/plugins/infra/public/pages/metrics/components/helpers.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/helpers.ts similarity index 91% rename from x-pack/plugins/infra/public/pages/metrics/components/helpers.ts rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/helpers.ts index 4449196f2fb53..bb4ad32660952 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/helpers.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/helpers.ts @@ -7,15 +7,15 @@ import { ReactText } from 'react'; import Color from 'color'; import { get, first, last, min, max } from 'lodash'; -import { createFormatter } from '../../../utils/formatters'; -import { InfraDataSeries } from '../../../graphql/types'; +import { createFormatter } from '../../../../utils/formatters'; +import { InfraDataSeries } from '../../../../graphql/types'; import { InventoryVisTypeRT, InventoryFormatterType, InventoryVisType, -} from '../../../../common/inventory_models/types'; +} from '../../../../../common/inventory_models/types'; import { SeriesOverrides } from '../types'; -import { NodeDetailsMetricData } from '../../../../common/http_api/node_details_api'; +import { NodeDetailsMetricData } from '../../../../../common/http_api/node_details_api'; /** * Returns a formatter diff --git a/x-pack/plugins/infra/public/pages/metrics/components/invalid_node.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/invalid_node.tsx similarity index 90% rename from x-pack/plugins/infra/public/pages/metrics/components/invalid_node.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/invalid_node.tsx index b089e2237c2e5..6d83017a3f689 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/invalid_node.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/invalid_node.tsx @@ -7,9 +7,9 @@ import { EuiButton, EuiEmptyPrompt, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import { euiStyled } from '../../../../../observability/public'; -import { ViewSourceConfigurationButton } from '../../../components/source_configuration'; -import { useLinkProps } from '../../../hooks/use_link_props'; +import { euiStyled } from '../../../../../../observability/public'; +import { ViewSourceConfigurationButton } from '../../../../components/source_configuration'; +import { useLinkProps } from '../../../../hooks/use_link_props'; interface InvalidNodeErrorProps { nodeName: string; diff --git a/x-pack/plugins/infra/public/pages/metrics/components/layout_content.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/layout_content.tsx similarity index 84% rename from x-pack/plugins/infra/public/pages/metrics/components/layout_content.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/layout_content.tsx index 4e10f245acdcc..4620102517549 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/layout_content.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/layout_content.tsx @@ -5,7 +5,7 @@ */ import { EuiPageContent } from '@elastic/eui'; -import { euiStyled } from '../../../../../observability/public'; +import { euiStyled } from '../../../../../../observability/public'; export const LayoutContent = euiStyled(EuiPageContent)` position: relative; diff --git a/x-pack/plugins/infra/public/pages/metrics/components/metadata_details.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/metadata_details.tsx similarity index 97% rename from x-pack/plugins/infra/public/pages/metrics/components/metadata_details.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/metadata_details.tsx index 3bf492d398f2c..7ca69dd56251d 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/metadata_details.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/metadata_details.tsx @@ -8,8 +8,8 @@ import React, { useContext, useState, useCallback, useMemo } from 'react'; import { EuiButtonIcon, EuiFlexGrid, EuiFlexItem, EuiTitle, EuiText } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { get } from 'lodash'; -import { InfraMetadata } from '../../../../common/http_api'; -import { euiStyled } from '../../../../../observability/public'; +import { InfraMetadata } from '../../../../../common/http_api'; +import { euiStyled } from '../../../../../../observability/public'; import { MetadataContext } from '../containers/metadata_context'; interface FieldDef { diff --git a/x-pack/plugins/infra/public/pages/metrics/components/node_details_page.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/node_details_page.tsx similarity index 90% rename from x-pack/plugins/infra/public/pages/metrics/components/node_details_page.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/node_details_page.tsx index dd2a5f2bdb39e..0d0bc8c82397e 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/node_details_page.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/node_details_page.tsx @@ -13,19 +13,19 @@ import { EuiHideFor, EuiTitle, } from '@elastic/eui'; -import { InfraTimerangeInput } from '../../../../common/http_api/snapshot_api'; -import { InventoryMetric, InventoryItemType } from '../../../../common/inventory_models/types'; -import { useNodeDetails } from '../../../containers/node_details/use_node_details'; +import { InfraTimerangeInput } from '../../../../../common/http_api/snapshot_api'; +import { InventoryMetric, InventoryItemType } from '../../../../../common/inventory_models/types'; +import { useNodeDetails } from '../hooks/use_node_details'; import { MetricsSideNav } from './side_nav'; -import { AutoSizer } from '../../../components/auto_sizer'; +import { AutoSizer } from '../../../../components/auto_sizer'; import { MetricsTimeControls } from './time_controls'; import { SideNavContext, NavItem } from '../lib/side_nav_context'; import { PageBody } from './page_body'; -import { euiStyled } from '../../../../../observability/public'; +import { euiStyled } from '../../../../../../observability/public'; import { MetricsTimeInput } from '../hooks/use_metrics_time'; -import { InfraMetadata } from '../../../../common/http_api/metadata_api'; +import { InfraMetadata } from '../../../../../common/http_api/metadata_api'; import { PageError } from './page_error'; -import { MetadataContext } from '../../../pages/metrics/containers/metadata_context'; +import { MetadataContext } from '../containers/metadata_context'; interface Props { name: string; diff --git a/x-pack/plugins/infra/public/pages/metrics/components/page_body.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/page_body.tsx similarity index 82% rename from x-pack/plugins/infra/public/pages/metrics/components/page_body.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/page_body.tsx index e651d6b92d981..68166a6e53bfd 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/page_body.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/page_body.tsx @@ -6,13 +6,13 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { findLayout } from '../../../../common/inventory_models/layouts'; -import { InventoryItemType } from '../../../../common/inventory_models/types'; +import { findLayout } from '../../../../../common/inventory_models/layouts'; +import { InventoryItemType } from '../../../../../common/inventory_models/types'; import { MetricsTimeInput } from '../hooks/use_metrics_time'; -import { InfraLoadingPanel } from '../../../components/loading'; -import { NoData } from '../../../components/empty_states'; -import { NodeDetailsMetricData } from '../../../../common/http_api/node_details_api'; +import { InfraLoadingPanel } from '../../../../components/loading'; +import { NoData } from '../../../../components/empty_states'; +import { NodeDetailsMetricData } from '../../../../../common/http_api/node_details_api'; interface Props { loading: boolean; diff --git a/x-pack/plugins/infra/public/pages/metrics/components/page_error.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/page_error.tsx similarity index 90% rename from x-pack/plugins/infra/public/pages/metrics/components/page_error.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/page_error.tsx index e54cdcd151f6f..bda2a5941e023 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/page_error.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/page_error.tsx @@ -10,8 +10,8 @@ import { i18n } from '@kbn/i18n'; import { IHttpFetchError } from 'src/core/public'; import { InvalidNodeError } from './invalid_node'; // import { InfraMetricsErrorCodes } from '../../../../common/errors'; -import { DocumentTitle } from '../../../components/document_title'; -import { ErrorPageBody } from '../../error'; +import { DocumentTitle } from '../../../../components/document_title'; +import { ErrorPageBody } from '../../../error'; interface Props { name: string; diff --git a/x-pack/plugins/infra/public/pages/metrics/components/section.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/section.tsx similarity index 100% rename from x-pack/plugins/infra/public/pages/metrics/components/section.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/section.tsx diff --git a/x-pack/plugins/infra/public/pages/metrics/components/series_chart.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/series_chart.tsx similarity index 93% rename from x-pack/plugins/infra/public/pages/metrics/components/series_chart.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/series_chart.tsx index 849a5b8922165..0d7716ad3cc66 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/series_chart.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/series_chart.tsx @@ -13,8 +13,8 @@ import { BarSeriesStyle, AreaSeriesStyle, } from '@elastic/charts'; -import { InfraDataSeries } from '../../../graphql/types'; -import { InventoryVisType } from '../../../../common/inventory_models/types'; +import { InfraDataSeries } from '../../../../graphql/types'; +import { InventoryVisType } from '../../../../../common/inventory_models/types'; interface Props { id: string; diff --git a/x-pack/plugins/infra/public/pages/metrics/components/side_nav.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/side_nav.tsx similarity index 95% rename from x-pack/plugins/infra/public/pages/metrics/components/side_nav.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/side_nav.tsx index 94f97c7f45e61..1cba3366acbbb 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/side_nav.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/side_nav.tsx @@ -6,7 +6,7 @@ import { EuiHideFor, EuiPageSideBar, EuiShowFor, EuiSideNav } from '@elastic/eui'; import React, { useState, useCallback } from 'react'; -import { euiStyled } from '../../../../../observability/public'; +import { euiStyled } from '../../../../../../observability/public'; import { NavItem } from '../lib/side_nav_context'; interface Props { diff --git a/x-pack/plugins/infra/public/pages/metrics/components/sub_section.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/sub_section.tsx similarity index 94% rename from x-pack/plugins/infra/public/pages/metrics/components/sub_section.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/sub_section.tsx index 325d510293135..7b269adc96638 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/sub_section.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/sub_section.tsx @@ -6,7 +6,7 @@ import React, { isValidElement, cloneElement, FunctionComponent, Children, useMemo } from 'react'; import { EuiTitle } from '@elastic/eui'; -import { InventoryMetric } from '../../../../common/inventory_models/types'; +import { InventoryMetric } from '../../../../../common/inventory_models/types'; import { LayoutProps } from '../types'; type SubSectionProps = LayoutProps & { diff --git a/x-pack/plugins/infra/public/pages/metrics/components/time_controls.test.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/time_controls.test.tsx similarity index 96% rename from x-pack/plugins/infra/public/pages/metrics/components/time_controls.test.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/time_controls.test.tsx index 02ba506e8abe1..83f5187f8a46c 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/time_controls.test.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/time_controls.test.tsx @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../utils/use_kibana_ui_setting', () => ({ +jest.mock('../../../../utils/use_kibana_ui_setting', () => ({ _esModule: true, useKibanaUiSetting: jest.fn(() => [ [ diff --git a/x-pack/plugins/infra/public/pages/metrics/components/time_controls.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/time_controls.tsx similarity index 91% rename from x-pack/plugins/infra/public/pages/metrics/components/time_controls.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/components/time_controls.tsx index cdbdc9bb7ecdb..ef6486eac0fdb 100644 --- a/x-pack/plugins/infra/public/pages/metrics/components/time_controls.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/components/time_controls.tsx @@ -6,10 +6,10 @@ import { EuiSuperDatePicker, OnRefreshChangeProps, OnTimeChangeProps } from '@elastic/eui'; import React, { useCallback } from 'react'; -import { euiStyled } from '../../../../../observability/public'; +import { euiStyled } from '../../../../../../observability/public'; import { MetricsTimeInput } from '../hooks/use_metrics_time'; -import { useKibanaUiSetting } from '../../../utils/use_kibana_ui_setting'; -import { mapKibanaQuickRangesToDatePickerRanges } from '../../../utils/map_timepicker_quickranges_to_datepicker_ranges'; +import { useKibanaUiSetting } from '../../../../utils/use_kibana_ui_setting'; +import { mapKibanaQuickRangesToDatePickerRanges } from '../../../../utils/map_timepicker_quickranges_to_datepicker_ranges'; interface MetricsTimeControlsProps { currentTimeRange: MetricsTimeInput; diff --git a/x-pack/plugins/infra/public/pages/metrics/containers/metadata_context.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/containers/metadata_context.ts similarity index 84% rename from x-pack/plugins/infra/public/pages/metrics/containers/metadata_context.ts rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/containers/metadata_context.ts index 4ecf7fa15548c..b8995d27d4dbe 100644 --- a/x-pack/plugins/infra/public/pages/metrics/containers/metadata_context.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/containers/metadata_context.ts @@ -5,5 +5,5 @@ */ import React from 'react'; -import { InfraMetadata } from '../../../../common/http_api'; +import { InfraMetadata } from '../../../../../common/http_api'; export const MetadataContext = React.createContext(null); diff --git a/x-pack/plugins/infra/public/pages/metrics/hooks/metrics_time.test.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/metrics_time.test.tsx similarity index 100% rename from x-pack/plugins/infra/public/pages/metrics/hooks/metrics_time.test.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/metrics_time.test.tsx diff --git a/x-pack/plugins/infra/public/containers/metadata/use_metadata.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metadata.ts similarity index 76% rename from x-pack/plugins/infra/public/containers/metadata/use_metadata.ts rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metadata.ts index 1ba016195bef4..d2a20d449d89a 100644 --- a/x-pack/plugins/infra/public/containers/metadata/use_metadata.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metadata.ts @@ -8,12 +8,12 @@ import { useEffect } from 'react'; import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; -import { InfraMetadata, InfraMetadataRT } from '../../../common/http_api/metadata_api'; -import { useHTTPRequest } from '../../hooks/use_http_request'; -import { throwErrors, createPlainError } from '../../../common/runtime_types'; -import { InventoryMetric, InventoryItemType } from '../../../common/inventory_models/types'; -import { getFilteredMetrics } from './lib/get_filtered_metrics'; -import { MetricsTimeInput } from '../../pages/metrics/hooks/use_metrics_time'; +import { InfraMetadata, InfraMetadataRT } from '../../../../../common/http_api/metadata_api'; +import { useHTTPRequest } from '../../../../hooks/use_http_request'; +import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; +import { InventoryMetric, InventoryItemType } from '../../../../../common/inventory_models/types'; +import { getFilteredMetrics } from '../lib/get_filtered_metrics'; +import { MetricsTimeInput } from './use_metrics_time'; export function useMetadata( nodeId: string, diff --git a/x-pack/plugins/infra/public/pages/metrics/hooks/use_metrics_time.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metrics_time.ts similarity index 96% rename from x-pack/plugins/infra/public/pages/metrics/hooks/use_metrics_time.ts rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metrics_time.ts index 2ed86863535ff..98803ef2e69c6 100644 --- a/x-pack/plugins/infra/public/pages/metrics/hooks/use_metrics_time.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_metrics_time.ts @@ -12,8 +12,8 @@ import * as rt from 'io-ts'; import { pipe } from 'fp-ts/lib/pipeable'; import { fold } from 'fp-ts/lib/Either'; import { constant, identity } from 'fp-ts/lib/function'; -import { useUrlState } from '../../../utils/use_url_state'; -import { replaceStateKeyInQueryString } from '../../../utils/url_state'; +import { useUrlState } from '../../../../utils/use_url_state'; +import { replaceStateKeyInQueryString } from '../../../../utils/url_state'; const parseRange = (range: MetricsTimeInput) => { const parsedFrom = dateMath.parse(range.from.toString()); diff --git a/x-pack/plugins/infra/public/containers/node_details/use_node_details.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_node_details.ts similarity index 75% rename from x-pack/plugins/infra/public/containers/node_details/use_node_details.ts rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_node_details.ts index 189c48ba1a70c..3bb6c98c8eac0 100644 --- a/x-pack/plugins/infra/public/containers/node_details/use_node_details.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/hooks/use_node_details.ts @@ -6,14 +6,14 @@ import { fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; import { pipe } from 'fp-ts/lib/pipeable'; -import { throwErrors, createPlainError } from '../../../common/runtime_types'; -import { useHTTPRequest } from '../../hooks/use_http_request'; +import { throwErrors, createPlainError } from '../../../../../common/runtime_types'; +import { useHTTPRequest } from '../../../../hooks/use_http_request'; import { NodeDetailsMetricDataResponseRT, NodeDetailsMetricDataResponse, -} from '../../../common/http_api/node_details_api'; -import { InventoryMetric, InventoryItemType } from '../../../common/inventory_models/types'; -import { InfraTimerangeInput } from '../../../common/http_api/snapshot_api'; +} from '../../../../../common/http_api/node_details_api'; +import { InventoryMetric, InventoryItemType } from '../../../../../common/inventory_models/types'; +import { InfraTimerangeInput } from '../../../../../common/http_api/snapshot_api'; export function useNodeDetails( metrics: InventoryMetric[], diff --git a/x-pack/plugins/infra/public/pages/metrics/metric_detail/index.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/index.tsx new file mode 100644 index 0000000000000..197a735f7fd1f --- /dev/null +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/index.tsx @@ -0,0 +1,140 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { i18n } from '@kbn/i18n'; +import React, { useContext, useState } from 'react'; +import { euiStyled, EuiTheme, withTheme } from '../../../../../observability/public'; +import { DocumentTitle } from '../../../components/document_title'; +import { Header } from '../../../components/header'; +import { ColumnarPage, PageContent } from '../../../components/page'; +import { withMetricPageProviders } from './page_providers'; +import { useMetadata } from './hooks/use_metadata'; +import { Source } from '../../../containers/source'; +import { InfraLoadingPanel } from '../../../components/loading'; +import { findInventoryModel } from '../../../../common/inventory_models'; +import { NavItem } from './lib/side_nav_context'; +import { NodeDetailsPage } from './components/node_details_page'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { InventoryItemType } from '../../../../common/inventory_models/types'; +import { useMetricsTimeContext } from './hooks/use_metrics_time'; +import { useLinkProps } from '../../../hooks/use_link_props'; + +const DetailPageContent = euiStyled(PageContent)` + overflow: auto; + background-color: ${props => props.theme.eui.euiColorLightestShade}; +`; + +interface Props { + theme: EuiTheme; + match: { + params: { + type: string; + node: string; + }; + }; +} + +export const MetricDetail = withMetricPageProviders( + withTheme(({ match }: Props) => { + const uiCapabilities = useKibana().services.application?.capabilities; + const nodeId = match.params.node; + const nodeType = match.params.type as InventoryItemType; + const inventoryModel = findInventoryModel(nodeType); + const { sourceId } = useContext(Source.Context); + const { + timeRange, + parsedTimeRange, + setTimeRange, + refreshInterval, + setRefreshInterval, + isAutoReloading, + setAutoReload, + triggerRefresh, + } = useMetricsTimeContext(); + const { + name, + filteredRequiredMetrics, + loading: metadataLoading, + cloudId, + metadata, + } = useMetadata(nodeId, nodeType, inventoryModel.requiredMetrics, sourceId, parsedTimeRange); + + const [sideNav, setSideNav] = useState([]); + + const addNavItem = React.useCallback( + (item: NavItem) => { + if (!sideNav.some(n => n.id === item.id)) { + setSideNav([item, ...sideNav]); + } + }, + [sideNav] + ); + + const metricsLinkProps = useLinkProps({ + app: 'metrics', + pathname: '/', + }); + + const breadcrumbs = [ + { + ...metricsLinkProps, + text: i18n.translate('xpack.infra.header.infrastructureTitle', { + defaultMessage: 'Metrics', + }), + }, + { text: name }, + ]; + + if (metadataLoading && !filteredRequiredMetrics.length) { + return ( + + ); + } + + return ( + +
+ + + {metadata ? ( + + ) : null} + + + ); + }) +); diff --git a/x-pack/plugins/infra/public/containers/metadata/lib/get_filtered_metrics.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/lib/get_filtered_metrics.ts similarity index 78% rename from x-pack/plugins/infra/public/containers/metadata/lib/get_filtered_metrics.ts rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/lib/get_filtered_metrics.ts index b485c90700145..57ff182f01963 100644 --- a/x-pack/plugins/infra/public/containers/metadata/lib/get_filtered_metrics.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/lib/get_filtered_metrics.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraMetadataFeature } from '../../../../common/http_api/metadata_api'; -import { InventoryMetric } from '../../../../common/inventory_models/types'; -import { metrics } from '../../../../common/inventory_models/metrics'; +import { InfraMetadataFeature } from '../../../../../common/http_api/metadata_api'; +import { InventoryMetric } from '../../../../../common/inventory_models/types'; +import { metrics } from '../../../../../common/inventory_models/metrics'; export const getFilteredMetrics = ( requiredMetrics: InventoryMetric[], diff --git a/x-pack/plugins/infra/public/pages/metrics/lib/side_nav_context.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/lib/side_nav_context.ts similarity index 100% rename from x-pack/plugins/infra/public/pages/metrics/lib/side_nav_context.ts rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/lib/side_nav_context.ts diff --git a/x-pack/plugins/infra/public/pages/metrics/page_providers.tsx b/x-pack/plugins/infra/public/pages/metrics/metric_detail/page_providers.tsx similarity index 91% rename from x-pack/plugins/infra/public/pages/metrics/page_providers.tsx rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/page_providers.tsx index d3f10adec06ed..597977d9d2735 100644 --- a/x-pack/plugins/infra/public/pages/metrics/page_providers.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/page_providers.tsx @@ -6,7 +6,7 @@ import React from 'react'; -import { Source } from '../../containers/source'; +import { Source } from '../../../containers/source'; import { MetricsTimeProvider } from './hooks/use_metrics_time'; export const withMetricPageProviders = (Component: React.ComponentType) => ( diff --git a/x-pack/plugins/infra/public/pages/metrics/types.ts b/x-pack/plugins/infra/public/pages/metrics/metric_detail/types.ts similarity index 86% rename from x-pack/plugins/infra/public/pages/metrics/types.ts rename to x-pack/plugins/infra/public/pages/metrics/metric_detail/types.ts index 2cc261df28977..3ec57e23a425d 100644 --- a/x-pack/plugins/infra/public/pages/metrics/types.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metric_detail/types.ts @@ -5,10 +5,10 @@ */ import rt from 'io-ts'; -import { EuiTheme } from '../../../../observability/public'; -import { InventoryFormatterTypeRT } from '../../../common/inventory_models/types'; +import { EuiTheme } from '../../../../../observability/public'; +import { InventoryFormatterTypeRT } from '../../../../common/inventory_models/types'; import { MetricsTimeInput } from './hooks/use_metrics_time'; -import { NodeDetailsMetricData } from '../../../common/http_api/node_details_api'; +import { NodeDetailsMetricData } from '../../../../common/http_api/node_details_api'; export interface LayoutProps { metrics?: NodeDetailsMetricData[]; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/aggregation.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/aggregation.tsx similarity index 89% rename from x-pack/plugins/infra/public/components/metrics_explorer/aggregation.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/aggregation.tsx index 76fa519ab3756..0c0f7b33b3a4a 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/aggregation.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/aggregation.tsx @@ -8,12 +8,12 @@ import { EuiSelect } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React, { useCallback } from 'react'; -import { MetricsExplorerAggregation } from '../../../common/http_api/metrics_explorer'; -import { MetricsExplorerOptions } from '../../containers/metrics_explorer/use_metrics_explorer_options'; +import { MetricsExplorerAggregation } from '../../../../../common/http_api/metrics_explorer'; +import { MetricsExplorerOptions } from '../hooks/use_metrics_explorer_options'; import { metricsExplorerAggregationRT, METRIC_EXPLORER_AGGREGATIONS, -} from '../../../common/http_api/metrics_explorer'; +} from '../../../../../common/http_api/metrics_explorer'; interface Props { options: MetricsExplorerOptions; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/chart.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart.tsx similarity index 92% rename from x-pack/plugins/infra/public/components/metrics_explorer/chart.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart.tsx index 43b08f45eed34..089e1abfc4c91 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/chart.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart.tsx @@ -10,24 +10,24 @@ import { EuiTitle, EuiToolTip, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { Axis, Chart, niceTimeFormatter, Position, Settings, TooltipValue } from '@elastic/charts'; import { first, last } from 'lodash'; import moment from 'moment'; -import { MetricsExplorerSeries } from '../../../common/http_api/metrics_explorer'; +import { MetricsExplorerSeries } from '../../../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions, MetricsExplorerYAxisMode, MetricsExplorerChartOptions, -} from '../../containers/metrics_explorer/use_metrics_explorer_options'; -import { euiStyled } from '../../../../observability/public'; +} from '../hooks/use_metrics_explorer_options'; +import { euiStyled } from '../../../../../../observability/public'; import { createFormatterForMetric } from './helpers/create_formatter_for_metric'; import { MetricExplorerSeriesChart } from './series_chart'; import { MetricsExplorerChartContextMenu } from './chart_context_menu'; -import { SourceQuery } from '../../graphql/types'; +import { SourceQuery } from '../../../../graphql/types'; import { MetricsExplorerEmptyChart } from './empty_chart'; import { MetricsExplorerNoMetrics } from './no_metrics'; import { getChartTheme } from './helpers/get_chart_theme'; -import { useKibanaUiSetting } from '../../utils/use_kibana_ui_setting'; +import { useKibanaUiSetting } from '../../../../utils/use_kibana_ui_setting'; import { calculateDomain } from './helpers/calculate_domain'; -import { useKibana, useUiSetting } from '../../../../../../src/plugins/kibana_react/public'; +import { useKibana, useUiSetting } from '../../../../../../../../src/plugins/kibana_react/public'; interface Props { title?: string | null; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.test.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_context_menu.test.tsx similarity index 96% rename from x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.test.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_context_menu.test.tsx index 8ffef269a42ea..5c0abb8fd845f 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.test.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_context_menu.test.tsx @@ -7,9 +7,14 @@ import React from 'react'; import { MetricsExplorerChartContextMenu, createNodeDetailLink, Props } from './chart_context_menu'; import { ReactWrapper, mount } from 'enzyme'; -import { options, source, timeRange, chartOptions } from '../../utils/fixtures/metrics_explorer'; +import { + options, + source, + timeRange, + chartOptions, +} from '../../../../utils/fixtures/metrics_explorer'; import { Capabilities } from 'src/core/public'; -import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; import { coreMock } from 'src/core/public/mocks'; const coreStartMock = coreMock.createStart(); diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_context_menu.tsx similarity index 91% rename from x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_context_menu.tsx index 75a04cbe9799e..31086a21ca13f 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/chart_context_menu.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_context_menu.tsx @@ -14,18 +14,18 @@ import { } from '@elastic/eui'; import DateMath from '@elastic/datemath'; import { Capabilities } from 'src/core/public'; -import { MetricsExplorerSeries } from '../../../common/http_api/metrics_explorer'; +import { AlertFlyout } from '../../../../components/alerting/metrics/alert_flyout'; +import { MetricsExplorerSeries } from '../../../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions, MetricsExplorerChartOptions, -} from '../../containers/metrics_explorer/use_metrics_explorer_options'; +} from '../hooks/use_metrics_explorer_options'; import { createTSVBLink } from './helpers/create_tsvb_link'; -import { getNodeDetailUrl } from '../../pages/link_to/redirect_to_node_detail'; -import { SourceConfiguration } from '../../utils/source_configuration'; -import { InventoryItemType } from '../../../common/inventory_models/types'; -import { AlertFlyout } from '../alerting/metrics/alert_flyout'; -import { useLinkProps } from '../../hooks/use_link_props'; +import { getNodeDetailUrl } from '../../../link_to/redirect_to_node_detail'; +import { SourceConfiguration } from '../../../../utils/source_configuration'; +import { InventoryItemType } from '../../../../../common/inventory_models/types'; +import { useLinkProps } from '../../../../hooks/use_link_props'; export interface Props { options: MetricsExplorerOptions; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/chart_options.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_options.tsx similarity index 98% rename from x-pack/plugins/infra/public/components/metrics_explorer/chart_options.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_options.tsx index 657c4cea30f3a..ba28075ededb6 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/chart_options.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_options.tsx @@ -19,7 +19,7 @@ import { MetricsExplorerChartOptions as ChartOptions, MetricsExplorerYAxisMode, MetricsExplorerChartType, -} from '../../containers/metrics_explorer/use_metrics_explorer_options'; +} from '../hooks/use_metrics_explorer_options'; interface Props { chartOptions: ChartOptions; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/charts.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/charts.tsx similarity index 92% rename from x-pack/plugins/infra/public/components/metrics_explorer/charts.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/charts.tsx index 64e7b27f5722f..ecec116310875 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/charts.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/charts.tsx @@ -8,16 +8,16 @@ import { EuiButton, EuiFlexGrid, EuiFlexItem, EuiText, EuiHorizontalRule } from import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import React from 'react'; -import { MetricsExplorerResponse } from '../../../common/http_api/metrics_explorer'; +import { MetricsExplorerResponse } from '../../../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions, MetricsExplorerChartOptions, -} from '../../containers/metrics_explorer/use_metrics_explorer_options'; -import { InfraLoadingPanel } from '../loading'; -import { NoData } from '../empty_states/no_data'; +} from '../hooks/use_metrics_explorer_options'; +import { InfraLoadingPanel } from '../../../../components/loading'; +import { NoData } from '../../../../components/empty_states/no_data'; import { MetricsExplorerChart } from './chart'; -import { SourceQuery } from '../../graphql/types'; +import { SourceQuery } from '../../../../graphql/types'; interface Props { loading: boolean; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/empty_chart.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/empty_chart.tsx similarity index 100% rename from x-pack/plugins/infra/public/components/metrics_explorer/empty_chart.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/empty_chart.tsx diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/group_by.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/group_by.tsx similarity index 72% rename from x-pack/plugins/infra/public/components/metrics_explorer/group_by.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/group_by.tsx index 750894fd0188b..bfe8ddb2e0829 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/group_by.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/group_by.tsx @@ -9,8 +9,7 @@ import { i18n } from '@kbn/i18n'; import React, { useCallback } from 'react'; import { IFieldType } from 'src/plugins/data/public'; -import { MetricsExplorerOptions } from '../../containers/metrics_explorer/use_metrics_explorer_options'; -import { isDisplayable } from '../../utils/is_displayable'; +import { MetricsExplorerOptions } from '../hooks/use_metrics_explorer_options'; interface Props { options: MetricsExplorerOptions; @@ -27,18 +26,6 @@ export const MetricsExplorerGroupBy = ({ options, onChange, fields }: Props) => [onChange] ); - const metricPrefixes = options.metrics - .map( - metric => - (metric.field && - metric.field - .split(/\./) - .slice(0, 2) - .join('.')) || - null - ) - .filter(metric => metric) as string[]; - return ( singleSelection={true} selectedOptions={(options.groupBy && [{ label: options.groupBy }]) || []} options={fields - .filter(f => isDisplayable(f, metricPrefixes) && f.aggregatable && f.type === 'string') + .filter(f => f.aggregatable && f.type === 'string') .map(f => ({ label: f.name }))} onChange={handleChange} isClearable={true} diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domain.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/calculate_domain.ts similarity index 87% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domain.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/calculate_domain.ts index 90569854b833b..811486d355f2e 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domain.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/calculate_domain.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ import { min, max, sum, isNumber } from 'lodash'; -import { MetricsExplorerSeries } from '../../../../common/http_api/metrics_explorer'; -import { MetricsExplorerOptionsMetric } from '../../../containers/metrics_explorer/use_metrics_explorer_options'; +import { MetricsExplorerSeries } from '../../../../../../common/http_api/metrics_explorer'; +import { MetricsExplorerOptionsMetric } from '../../hooks/use_metrics_explorer_options'; const getMin = (values: Array) => { const minValue = min(values); diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domian.test.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/calculate_domian.test.ts similarity index 85% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domian.test.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/calculate_domian.test.ts index 4b45534d41db8..f94c6b6156ae4 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/calculate_domian.test.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/calculate_domian.test.ts @@ -5,9 +5,9 @@ */ import { calculateDomain } from './calculate_domain'; -import { MetricsExplorerSeries } from '../../../../common/http_api/metrics_explorer'; -import { MetricsExplorerOptionsMetric } from '../../../containers/metrics_explorer/use_metrics_explorer_options'; -import { MetricsExplorerColor } from '../../../../common/color_palette'; +import { MetricsExplorerSeries } from '../../../../../../common/http_api/metrics_explorer'; +import { MetricsExplorerOptionsMetric } from '../../hooks/use_metrics_explorer_options'; +import { MetricsExplorerColor } from '../../../../../../common/color_palette'; describe('calculateDomain()', () => { const series: MetricsExplorerSeries = { id: 'test-01', diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metric.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_formatter_for_metric.ts similarity index 76% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metric.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_formatter_for_metric.ts index 33ec2ce2715a3..d07a6b45f02be 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metric.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_formatter_for_metric.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; -import { createFormatter } from '../../../utils/formatters'; -import { InfraFormatterType } from '../../../lib/lib'; +import { MetricsExplorerMetric } from '../../../../../../common/http_api/metrics_explorer'; +import { createFormatter } from '../../../../../utils/formatters'; +import { InfraFormatterType } from '../../../../../lib/lib'; import { metricToFormat } from './metric_to_format'; export const createFormatterForMetric = (metric?: MetricsExplorerMetric) => { if (metric && metric.field) { diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metrics.test.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_formatter_for_metrics.test.ts similarity index 94% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metrics.test.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_formatter_for_metrics.test.ts index ec41e90e441a4..e039d5d4b3eeb 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_formatter_for_metrics.test.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_formatter_for_metrics.test.ts @@ -5,7 +5,7 @@ */ import { createFormatterForMetric } from './create_formatter_for_metric'; -import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; +import { MetricsExplorerMetric } from '../../../../../../common/http_api/metrics_explorer'; describe('createFormatterForMetric()', () => { it('should just work for count', () => { diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.test.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_metric_label.test.ts similarity index 88% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.test.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_metric_label.test.ts index cbf6904d246c7..367c472f414e4 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.test.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_metric_label.test.ts @@ -5,7 +5,7 @@ */ import { createMetricLabel } from './create_metric_label'; -import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; +import { MetricsExplorerMetric } from '../../../../../../common/http_api/metrics_explorer'; describe('createMetricLabel()', () => { it('should work with metrics with fields', () => { diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_metric_label.ts similarity index 80% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_metric_label.ts index b6453a81317b1..1607302a6259a 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_metric_label.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_metric_label.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; +import { MetricsExplorerMetric } from '../../../../../../common/http_api/metrics_explorer'; export const createMetricLabel = (metric: MetricsExplorerMetric) => { return `${metric.aggregation}(${metric.field || ''})`; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.test.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.test.ts similarity index 97% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.test.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.test.ts index 05637642b8dd9..47bb4c8c57716 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.test.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.test.ts @@ -5,14 +5,19 @@ */ import { createTSVBLink, createFilterFromOptions } from './create_tsvb_link'; -import { source, options, timeRange, chartOptions } from '../../../utils/fixtures/metrics_explorer'; +import { + source, + options, + timeRange, + chartOptions, +} from '../../../../../utils/fixtures/metrics_explorer'; import uuid from 'uuid'; import { OutputBuffer } from 'uuid/interfaces'; import { MetricsExplorerYAxisMode, MetricsExplorerChartType, -} from '../../../containers/metrics_explorer/use_metrics_explorer_options'; -import { MetricsExplorerOptions } from '../../../containers/metrics_explorer/use_metrics_explorer_options'; +} from '../../hooks/use_metrics_explorer_options'; +import { MetricsExplorerOptions } from '../../hooks/use_metrics_explorer_options'; jest.mock('uuid'); const mockedUuid = uuid as jest.Mocked; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts similarity index 91% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts index 20706f563ec63..559422584f579 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/create_tsvb_link.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts @@ -7,8 +7,8 @@ import { encode } from 'rison-node'; import uuid from 'uuid'; import { set } from 'lodash'; -import { colorTransformer, MetricsExplorerColor } from '../../../../common/color_palette'; -import { MetricsExplorerSeries } from '../../../../common/http_api/metrics_explorer'; +import { colorTransformer, MetricsExplorerColor } from '../../../../../../common/color_palette'; +import { MetricsExplorerSeries } from '../../../../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerOptionsMetric, @@ -16,12 +16,12 @@ import { MetricsExplorerChartOptions, MetricsExplorerYAxisMode, MetricsExplorerChartType, -} from '../../../containers/metrics_explorer/use_metrics_explorer_options'; +} from '../../hooks/use_metrics_explorer_options'; import { metricToFormat } from './metric_to_format'; -import { InfraFormatterType } from '../../../lib/lib'; -import { SourceQuery } from '../../../graphql/types'; +import { InfraFormatterType } from '../../../../../lib/lib'; +import { SourceQuery } from '../../../../../graphql/types'; import { createMetricLabel } from './create_metric_label'; -import { LinkDescriptor } from '../../../hooks/use_link_props'; +import { LinkDescriptor } from '../../../../../hooks/use_link_props'; export const metricsExplorerMetricToTSVBMetric = (metric: MetricsExplorerOptionsMetric) => { if (metric.aggregation === 'rate') { diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/get_chart_theme.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/get_chart_theme.ts similarity index 100% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/get_chart_theme.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/get_chart_theme.ts diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.test.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/metric_to_format.test.ts similarity index 90% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.test.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/metric_to_format.test.ts index 4cb27b4fb65c3..6b27627a9fb5b 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.test.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/metric_to_format.test.ts @@ -5,8 +5,8 @@ */ import { metricToFormat } from './metric_to_format'; -import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; -import { InfraFormatterType } from '../../../lib/lib'; +import { MetricsExplorerMetric } from '../../../../../../common/http_api/metrics_explorer'; +import { InfraFormatterType } from '../../../../../lib/lib'; describe('metricToFormat()', () => { it('should just work for numeric metrics', () => { const metric: MetricsExplorerMetric = { aggregation: 'avg', field: 'system.load.1' }; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/metric_to_format.ts similarity index 82% rename from x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/metric_to_format.ts index 63272c86a5dc7..1dbbf97a32217 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/helpers/metric_to_format.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/helpers/metric_to_format.ts @@ -5,8 +5,8 @@ */ import { last } from 'lodash'; -import { MetricsExplorerMetric } from '../../../../common/http_api/metrics_explorer'; -import { InfraFormatterType } from '../../../lib/lib'; +import { MetricsExplorerMetric } from '../../../../../../common/http_api/metrics_explorer'; +import { InfraFormatterType } from '../../../../../lib/lib'; export const metricToFormat = (metric?: MetricsExplorerMetric) => { if (metric && metric.field) { const suffix = last(metric.field.split(/\./)); diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/kuery_bar.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/kuery_bar.tsx similarity index 84% rename from x-pack/plugins/infra/public/components/metrics_explorer/kuery_bar.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/kuery_bar.tsx index dcc160d05b6ad..e9826e1ff3955 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/kuery_bar.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/kuery_bar.tsx @@ -7,10 +7,9 @@ import { i18n } from '@kbn/i18n'; import React, { useEffect, useState } from 'react'; -import { WithKueryAutocompletion } from '../../containers/with_kuery_autocompletion'; -import { AutocompleteField } from '../autocomplete_field'; -import { isDisplayable } from '../../utils/is_displayable'; -import { esKuery, IIndexPattern } from '../../../../../../src/plugins/data/public'; +import { WithKueryAutocompletion } from '../../../../containers/with_kuery_autocompletion'; +import { AutocompleteField } from '../../../../components/autocomplete_field'; +import { esKuery, IIndexPattern } from '../../../../../../../../src/plugins/data/public'; interface Props { derivedIndexPattern: IIndexPattern; @@ -51,7 +50,7 @@ export const MetricsExplorerKueryBar = ({ const filteredDerivedIndexPattern = { ...derivedIndexPattern, - fields: derivedIndexPattern.fields.filter(field => isDisplayable(field)), + fields: derivedIndexPattern.fields, }; const defaultPlaceholder = i18n.translate( diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/metrics.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/metrics.tsx similarity index 85% rename from x-pack/plugins/infra/public/components/metrics_explorer/metrics.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/metrics.tsx index 79d4122733c55..612735e2ba772 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/metrics.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/metrics.tsx @@ -9,10 +9,9 @@ import { i18n } from '@kbn/i18n'; import React, { useCallback, useState } from 'react'; import { IFieldType } from 'src/plugins/data/public'; -import { colorTransformer, MetricsExplorerColor } from '../../../common/color_palette'; -import { MetricsExplorerMetric } from '../../../common/http_api/metrics_explorer'; -import { MetricsExplorerOptions } from '../../containers/metrics_explorer/use_metrics_explorer_options'; -import { isDisplayable } from '../../utils/is_displayable'; +import { colorTransformer, MetricsExplorerColor } from '../../../../../common/color_palette'; +import { MetricsExplorerMetric } from '../../../../../common/http_api/metrics_explorer'; +import { MetricsExplorerOptions } from '../hooks/use_metrics_explorer_options'; interface Props { autoFocus?: boolean; @@ -54,9 +53,7 @@ export const MetricsExplorerMetrics = ({ options, onChange, fields, autoFocus = [onChange, options.aggregation, colors] ); - const comboOptions = fields - .filter(field => isDisplayable(field)) - .map(field => ({ label: field.name, value: field.name })); + const comboOptions = fields.map(field => ({ label: field.name, value: field.name })); const selectedOptions = options.metrics .filter(m => m.aggregation !== 'count') .map(metric => ({ diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/no_metrics.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/no_metrics.tsx similarity index 100% rename from x-pack/plugins/infra/public/components/metrics_explorer/no_metrics.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/no_metrics.tsx diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/series_chart.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/series_chart.tsx similarity index 93% rename from x-pack/plugins/infra/public/components/metrics_explorer/series_chart.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/series_chart.tsx index ed7a994dd2bbe..ad7ce83539526 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/series_chart.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/series_chart.tsx @@ -13,13 +13,13 @@ import { AreaSeriesStyle, BarSeriesStyle, } from '@elastic/charts'; -import { MetricsExplorerSeries } from '../../../common/http_api/metrics_explorer'; -import { colorTransformer, MetricsExplorerColor } from '../../../common/color_palette'; +import { MetricsExplorerSeries } from '../../../../../common/http_api/metrics_explorer'; +import { colorTransformer, MetricsExplorerColor } from '../../../../../common/color_palette'; import { createMetricLabel } from './helpers/create_metric_label'; import { MetricsExplorerOptionsMetric, MetricsExplorerChartType, -} from '../../containers/metrics_explorer/use_metrics_explorer_options'; +} from '../hooks/use_metrics_explorer_options'; interface Props { metric: MetricsExplorerOptionsMetric; diff --git a/x-pack/plugins/infra/public/components/metrics_explorer/toolbar.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/toolbar.tsx similarity index 88% rename from x-pack/plugins/infra/public/components/metrics_explorer/toolbar.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/toolbar.tsx index 0fbb0b6acad17..81971bd31a973 100644 --- a/x-pack/plugins/infra/public/components/metrics_explorer/toolbar.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/toolbar.tsx @@ -11,23 +11,23 @@ import { IIndexPattern } from 'src/plugins/data/public'; import { MetricsExplorerMetric, MetricsExplorerAggregation, -} from '../../../common/http_api/metrics_explorer'; +} from '../../../../../common/http_api/metrics_explorer'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions, MetricsExplorerChartOptions, -} from '../../containers/metrics_explorer/use_metrics_explorer_options'; -import { Toolbar } from '../eui/toolbar'; +} from '../hooks/use_metrics_explorer_options'; +import { Toolbar } from '../../../../components/eui/toolbar'; import { MetricsExplorerKueryBar } from './kuery_bar'; import { MetricsExplorerMetrics } from './metrics'; import { MetricsExplorerGroupBy } from './group_by'; import { MetricsExplorerAggregationPicker } from './aggregation'; import { MetricsExplorerChartOptions as MetricsExplorerChartOptionsComponent } from './chart_options'; -import { SavedViewsToolbarControls } from '../saved_views/toolbar_control'; -import { MetricExplorerViewState } from '../../pages/infrastructure/metrics_explorer/use_metric_explorer_state'; -import { metricsExplorerViewSavedObjectType } from '../../../common/saved_objects/metrics_explorer_view'; -import { useKibanaUiSetting } from '../../utils/use_kibana_ui_setting'; -import { mapKibanaQuickRangesToDatePickerRanges } from '../../utils/map_timepicker_quickranges_to_datepicker_ranges'; +import { SavedViewsToolbarControls } from '../../../../components/saved_views/toolbar_control'; +import { MetricExplorerViewState } from '../hooks/use_metric_explorer_state'; +import { metricsExplorerViewSavedObjectType } from '../../../../../common/saved_objects/metrics_explorer_view'; +import { useKibanaUiSetting } from '../../../../utils/use_kibana_ui_setting'; +import { mapKibanaQuickRangesToDatePickerRanges } from '../../../../utils/map_timepicker_quickranges_to_datepicker_ranges'; interface Props { derivedIndexPattern: IIndexPattern; diff --git a/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.test.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.test.tsx similarity index 96% rename from x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.test.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.test.tsx index 874ac0987023b..f0734f76cfacd 100644 --- a/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.test.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.test.tsx @@ -6,14 +6,14 @@ import { renderHook, act } from '@testing-library/react-hooks'; import { useMetricsExplorerState } from './use_metric_explorer_state'; -import { MetricsExplorerOptionsContainer } from '../../../containers/metrics_explorer/use_metrics_explorer_options'; +import { MetricsExplorerOptionsContainer } from './use_metrics_explorer_options'; import React from 'react'; import { source, derivedIndexPattern, resp, createSeries, -} from '../../../utils/fixtures/metrics_explorer'; +} from '../../../../utils/fixtures/metrics_explorer'; const renderUseMetricsExplorerStateHook = () => renderHook(props => useMetricsExplorerState(props.source, props.derivedIndexPattern), { @@ -27,7 +27,7 @@ const renderUseMetricsExplorerStateHook = () => const mockedUseMetricsExplorerData = jest.fn(); -jest.mock('../../../containers/metrics_explorer/use_metrics_explorer_data', () => { +jest.mock('./use_metrics_explorer_data', () => { return { useMetricsExplorerData: () => { return mockedUseMetricsExplorerData(); diff --git a/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.ts similarity index 92% rename from x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.ts index 88e6d9d800661..8a9ed901de0b0 100644 --- a/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/use_metric_explorer_state.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metric_explorer_state.ts @@ -9,15 +9,15 @@ import { IIndexPattern } from 'src/plugins/data/public'; import { MetricsExplorerMetric, MetricsExplorerAggregation, -} from '../../../../common/http_api/metrics_explorer'; -import { useMetricsExplorerData } from '../../../containers/metrics_explorer/use_metrics_explorer_data'; +} from '../../../../../common/http_api/metrics_explorer'; +import { useMetricsExplorerData } from './use_metrics_explorer_data'; import { MetricsExplorerOptionsContainer, MetricsExplorerChartOptions, MetricsExplorerTimeOptions, MetricsExplorerOptions, -} from '../../../containers/metrics_explorer/use_metrics_explorer_options'; -import { SourceQuery } from '../../../graphql/types'; +} from './use_metrics_explorer_options'; +import { SourceQuery } from '../../../../graphql/types'; export interface MetricExplorerViewState { chartOptions: MetricsExplorerChartOptions; diff --git a/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.test.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.test.tsx similarity index 96% rename from x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.test.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.test.tsx index bbc8778545b4a..94edab54fb71e 100644 --- a/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.test.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.test.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { useMetricsExplorerData } from './use_metrics_explorer_data'; import { renderHook } from '@testing-library/react-hooks'; -import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; import { options, @@ -17,7 +17,7 @@ import { timeRange, resp, createSeries, -} from '../../utils/fixtures/metrics_explorer'; +} from '../../../../utils/fixtures/metrics_explorer'; const mockedFetch = jest.fn(); @@ -54,7 +54,7 @@ const renderUseMetricsExplorerDataHook = () => { ); }; -jest.mock('../../utils/kuery', () => { +jest.mock('../../../../utils/kuery', () => { return { convertKueryToElasticSearchQuery: (query: string) => query, }; diff --git a/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.ts similarity index 91% rename from x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.ts index b32496fbf30a1..93aacb586a5cd 100644 --- a/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_data.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_data.ts @@ -8,15 +8,15 @@ import DateMath from '@elastic/datemath'; import { isEqual } from 'lodash'; import { useEffect, useState } from 'react'; import { IIndexPattern } from 'src/plugins/data/public'; -import { SourceQuery } from '../../../common/graphql/types'; +import { SourceQuery } from '../../../../../common/graphql/types'; import { MetricsExplorerResponse, metricsExplorerResponseRT, -} from '../../../common/http_api/metrics_explorer'; -import { convertKueryToElasticSearchQuery } from '../../utils/kuery'; +} from '../../../../../common/http_api/metrics_explorer'; +import { convertKueryToElasticSearchQuery } from '../../../../utils/kuery'; import { MetricsExplorerOptions, MetricsExplorerTimeOptions } from './use_metrics_explorer_options'; -import { useKibana } from '../../../../../../src/plugins/kibana_react/public'; -import { decodeOrThrow } from '../../../common/runtime_types'; +import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; +import { decodeOrThrow } from '../../../../../common/runtime_types'; function isSameOptions(current: MetricsExplorerOptions, next: MetricsExplorerOptions) { return isEqual(current, next); diff --git a/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.test.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options.test.tsx similarity index 100% rename from x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.test.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options.test.tsx diff --git a/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.ts b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options.ts similarity index 96% rename from x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.ts rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options.ts index 2b802af8e8c15..9d124a6af8012 100644 --- a/x-pack/plugins/infra/public/containers/metrics_explorer/use_metrics_explorer_options.ts +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options.ts @@ -6,11 +6,11 @@ import createContainer from 'constate'; import { useState, useEffect, Dispatch, SetStateAction } from 'react'; -import { MetricsExplorerColor } from '../../../common/color_palette'; +import { MetricsExplorerColor } from '../../../../../common/color_palette'; import { MetricsExplorerAggregation, MetricsExplorerMetric, -} from '../../../common/http_api/metrics_explorer'; +} from '../../../../../common/http_api/metrics_explorer'; export type MetricsExplorerOptionsMetric = MetricsExplorerMetric & { color?: MetricsExplorerColor; diff --git a/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/index.tsx b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx similarity index 92% rename from x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/index.tsx rename to x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx index 0999cea59731c..a213671e9436e 100644 --- a/x-pack/plugins/infra/public/pages/infrastructure/metrics_explorer/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/metrics_explorer/index.tsx @@ -9,11 +9,11 @@ import { i18n } from '@kbn/i18n'; import React from 'react'; import { IIndexPattern } from 'src/plugins/data/public'; import { DocumentTitle } from '../../../components/document_title'; -import { MetricsExplorerCharts } from '../../../components/metrics_explorer/charts'; -import { MetricsExplorerToolbar } from '../../../components/metrics_explorer/toolbar'; +import { MetricsExplorerCharts } from './components/charts'; +import { MetricsExplorerToolbar } from './components/toolbar'; import { SourceQuery } from '../../../../common/graphql/types'; import { NoData } from '../../../components/empty_states'; -import { useMetricsExplorerState } from './use_metric_explorer_state'; +import { useMetricsExplorerState } from './hooks/use_metric_explorer_state'; import { useTrackPageview } from '../../../../../observability/public'; interface MetricsExplorerPageProps { diff --git a/x-pack/plugins/infra/public/pages/infrastructure/settings.tsx b/x-pack/plugins/infra/public/pages/metrics/settings.tsx similarity index 100% rename from x-pack/plugins/infra/public/pages/infrastructure/settings.tsx rename to x-pack/plugins/infra/public/pages/metrics/settings.tsx diff --git a/x-pack/plugins/infra/public/routers/metrics_router.tsx b/x-pack/plugins/infra/public/routers/metrics_router.tsx index 7cb9de65e7291..0e427150a46cc 100644 --- a/x-pack/plugins/infra/public/routers/metrics_router.tsx +++ b/x-pack/plugins/infra/public/routers/metrics_router.tsx @@ -8,12 +8,12 @@ import React from 'react'; import { Route, Router, Switch } from 'react-router-dom'; import { NotFoundPage } from '../pages/404'; -import { InfrastructurePage } from '../pages/infrastructure'; -import { LinkToMetricsPage } from '../pages/link_to'; -import { MetricDetail } from '../pages/metrics'; +import { InfrastructurePage } from '../pages/metrics'; +import { MetricDetail } from '../pages/metrics/metric_detail'; import { RedirectWithQueryParams } from '../utils/redirect_with_query_params'; import { useKibana } from '../../../../../src/plugins/kibana_react/public'; import { AppRouter } from './index'; +import { LinkToMetricsPage } from '../pages/link_to'; export const MetricsRouter: AppRouter = ({ history }) => { const uiCapabilities = useKibana().services.application?.capabilities; diff --git a/x-pack/plugins/infra/public/utils/fixtures/metrics_explorer.ts b/x-pack/plugins/infra/public/utils/fixtures/metrics_explorer.ts index e39d6f785d53e..15159ad45c7f3 100644 --- a/x-pack/plugins/infra/public/utils/fixtures/metrics_explorer.ts +++ b/x-pack/plugins/infra/public/utils/fixtures/metrics_explorer.ts @@ -14,7 +14,7 @@ import { MetricsExplorerChartType, MetricsExplorerYAxisMode, MetricsExplorerChartOptions, -} from '../../containers/metrics_explorer/use_metrics_explorer_options'; +} from '../../pages/metrics/metrics_explorer/hooks/use_metrics_explorer_options'; export const options: MetricsExplorerOptions = { limit: 3, diff --git a/x-pack/plugins/infra/server/infra_server.ts b/x-pack/plugins/infra/server/infra_server.ts index fb9dd172bf6ed..88b78dfd3e41c 100644 --- a/x-pack/plugins/infra/server/infra_server.ts +++ b/x-pack/plugins/infra/server/infra_server.ts @@ -29,6 +29,7 @@ import { initLogEntriesItemRoute, } from './routes/log_entries'; import { initInventoryMetaRoute } from './routes/inventory_metadata'; +import { initSourceRoute } from './routes/source'; export const initInfraServer = (libs: InfraBackendLibs) => { const schema = makeExecutableSchema({ @@ -48,6 +49,7 @@ export const initInfraServer = (libs: InfraBackendLibs) => { initGetLogEntryRateRoute(libs); initSnapshotRoute(libs); initNodeDetailsRoute(libs); + initSourceRoute(libs); initValidateLogAnalysisIndicesRoute(libs); initLogEntriesRoute(libs); initLogEntriesHighlightsRoute(libs); diff --git a/x-pack/plugins/infra/server/lib/sources/defaults.ts b/x-pack/plugins/infra/server/lib/sources/defaults.ts index b9ead0d169ee6..6b00f59cca1f4 100644 --- a/x-pack/plugins/infra/server/lib/sources/defaults.ts +++ b/x-pack/plugins/infra/server/lib/sources/defaults.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraSourceConfiguration } from './types'; +import { InfraSourceConfiguration } from '../../../common/http_api/source_api'; export const defaultSourceConfiguration: InfraSourceConfiguration = { name: 'Default', diff --git a/x-pack/plugins/infra/server/lib/sources/index.ts b/x-pack/plugins/infra/server/lib/sources/index.ts index 6837f953ea18a..9dcbe02bd064b 100644 --- a/x-pack/plugins/infra/server/lib/sources/index.ts +++ b/x-pack/plugins/infra/server/lib/sources/index.ts @@ -7,4 +7,4 @@ export * from './defaults'; export * from './saved_object_mappings'; export * from './sources'; -export * from './types'; +export * from '../../../common/http_api/source_api'; diff --git a/x-pack/plugins/infra/server/lib/sources/saved_object_mappings.ts b/x-pack/plugins/infra/server/lib/sources/saved_object_mappings.ts index 973a790eeedaf..e5b230373b7ec 100644 --- a/x-pack/plugins/infra/server/lib/sources/saved_object_mappings.ts +++ b/x-pack/plugins/infra/server/lib/sources/saved_object_mappings.ts @@ -5,7 +5,7 @@ */ import { ElasticsearchMappingOf } from '../../utils/typed_elasticsearch_mappings'; -import { InfraSavedSourceConfiguration } from './types'; +import { InfraSavedSourceConfiguration } from '../../../common/http_api/source_api'; export const infraSourceConfigurationSavedObjectType = 'infrastructure-ui-source'; diff --git a/x-pack/plugins/infra/server/lib/sources/sources.ts b/x-pack/plugins/infra/server/lib/sources/sources.ts index c7ff6c9638204..99e062aa49ccf 100644 --- a/x-pack/plugins/infra/server/lib/sources/sources.ts +++ b/x-pack/plugins/infra/server/lib/sources/sources.ts @@ -20,7 +20,8 @@ import { pickSavedSourceConfiguration, SourceConfigurationSavedObjectRuntimeType, StaticSourceConfigurationRuntimeType, -} from './types'; + InfraSource, +} from '../../../common/http_api/source_api'; import { InfraConfig } from '../../../server'; interface Libs { @@ -35,7 +36,10 @@ export class InfraSources { this.libs = libs; } - public async getSourceConfiguration(requestContext: RequestHandlerContext, sourceId: string) { + public async getSourceConfiguration( + requestContext: RequestHandlerContext, + sourceId: string + ): Promise { const staticDefaultSourceConfiguration = await this.getStaticDefaultSourceConfiguration(); const savedSourceConfiguration = await this.getInternalSourceConfiguration(sourceId) diff --git a/x-pack/plugins/infra/server/lib/sources/types.ts b/x-pack/plugins/infra/server/lib/sources/types.ts deleted file mode 100644 index 1f850635cf35a..0000000000000 --- a/x-pack/plugins/infra/server/lib/sources/types.ts +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -/* eslint-disable @typescript-eslint/no-empty-interface */ - -import * as runtimeTypes from 'io-ts'; -import moment from 'moment'; -import { pipe } from 'fp-ts/lib/pipeable'; -import { chain } from 'fp-ts/lib/Either'; - -export const TimestampFromString = new runtimeTypes.Type( - 'TimestampFromString', - (input): input is number => typeof input === 'number', - (input, context) => - pipe( - runtimeTypes.string.validate(input, context), - chain(stringInput => { - const momentValue = moment(stringInput); - return momentValue.isValid() - ? runtimeTypes.success(momentValue.valueOf()) - : runtimeTypes.failure(stringInput, context); - }) - ), - output => new Date(output).toISOString() -); - -/** - * Stored source configuration as read from and written to saved objects - */ - -const SavedSourceConfigurationFieldsRuntimeType = runtimeTypes.partial({ - container: runtimeTypes.string, - host: runtimeTypes.string, - pod: runtimeTypes.string, - tiebreaker: runtimeTypes.string, - timestamp: runtimeTypes.string, -}); - -export const SavedSourceConfigurationTimestampColumnRuntimeType = runtimeTypes.type({ - timestampColumn: runtimeTypes.type({ - id: runtimeTypes.string, - }), -}); - -export const SavedSourceConfigurationMessageColumnRuntimeType = runtimeTypes.type({ - messageColumn: runtimeTypes.type({ - id: runtimeTypes.string, - }), -}); - -export const SavedSourceConfigurationFieldColumnRuntimeType = runtimeTypes.type({ - fieldColumn: runtimeTypes.type({ - id: runtimeTypes.string, - field: runtimeTypes.string, - }), -}); - -export const SavedSourceConfigurationColumnRuntimeType = runtimeTypes.union([ - SavedSourceConfigurationTimestampColumnRuntimeType, - SavedSourceConfigurationMessageColumnRuntimeType, - SavedSourceConfigurationFieldColumnRuntimeType, -]); - -export const SavedSourceConfigurationRuntimeType = runtimeTypes.partial({ - name: runtimeTypes.string, - description: runtimeTypes.string, - metricAlias: runtimeTypes.string, - logAlias: runtimeTypes.string, - fields: SavedSourceConfigurationFieldsRuntimeType, - logColumns: runtimeTypes.array(SavedSourceConfigurationColumnRuntimeType), -}); - -export interface InfraSavedSourceConfiguration - extends runtimeTypes.TypeOf {} - -export const pickSavedSourceConfiguration = ( - value: InfraSourceConfiguration -): InfraSavedSourceConfiguration => { - const { name, description, metricAlias, logAlias, fields, logColumns } = value; - const { container, host, pod, tiebreaker, timestamp } = fields; - - return { - name, - description, - metricAlias, - logAlias, - fields: { container, host, pod, tiebreaker, timestamp }, - logColumns, - }; -}; - -/** - * Static source configuration as read from the configuration file - */ - -const StaticSourceConfigurationFieldsRuntimeType = runtimeTypes.partial({ - ...SavedSourceConfigurationFieldsRuntimeType.props, - message: runtimeTypes.array(runtimeTypes.string), -}); - -export const StaticSourceConfigurationRuntimeType = runtimeTypes.partial({ - name: runtimeTypes.string, - description: runtimeTypes.string, - metricAlias: runtimeTypes.string, - logAlias: runtimeTypes.string, - fields: StaticSourceConfigurationFieldsRuntimeType, - logColumns: runtimeTypes.array(SavedSourceConfigurationColumnRuntimeType), -}); - -export interface InfraStaticSourceConfiguration - extends runtimeTypes.TypeOf {} - -/** - * Full source configuration type after all cleanup has been done at the edges - */ - -const SourceConfigurationFieldsRuntimeType = runtimeTypes.type({ - ...StaticSourceConfigurationFieldsRuntimeType.props, -}); - -export const SourceConfigurationRuntimeType = runtimeTypes.type({ - ...SavedSourceConfigurationRuntimeType.props, - fields: SourceConfigurationFieldsRuntimeType, - logColumns: runtimeTypes.array(SavedSourceConfigurationColumnRuntimeType), -}); - -export interface InfraSourceConfiguration - extends runtimeTypes.TypeOf {} - -/** - * Saved object type with metadata - */ - -export const SourceConfigurationSavedObjectRuntimeType = runtimeTypes.intersection([ - runtimeTypes.type({ - id: runtimeTypes.string, - attributes: SavedSourceConfigurationRuntimeType, - }), - runtimeTypes.partial({ - version: runtimeTypes.string, - updated_at: TimestampFromString, - }), -]); - -export interface SourceConfigurationSavedObject - extends runtimeTypes.TypeOf {} diff --git a/x-pack/plugins/infra/server/plugin.ts b/x-pack/plugins/infra/server/plugin.ts index 64fc496f3597e..e3804078604cc 100644 --- a/x-pack/plugins/infra/server/plugin.ts +++ b/x-pack/plugins/infra/server/plugin.ts @@ -26,7 +26,7 @@ import { InfraSources } from './lib/sources'; import { InfraServerPluginDeps } from './lib/adapters/framework'; import { METRICS_FEATURE, LOGS_FEATURE } from './features'; import { UsageCollector } from './usage/usage_collector'; -import { InfraStaticSourceConfiguration } from './lib/sources/types'; +import { InfraStaticSourceConfiguration } from '../common/http_api/source_api'; import { registerAlertTypes } from './lib/alerting'; export const config = { diff --git a/x-pack/plugins/infra/server/routes/source/index.ts b/x-pack/plugins/infra/server/routes/source/index.ts new file mode 100644 index 0000000000000..2f29320d7bb81 --- /dev/null +++ b/x-pack/plugins/infra/server/routes/source/index.ts @@ -0,0 +1,65 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { schema } from '@kbn/config-schema'; +import { SourceResponseRuntimeType } from '../../../common/http_api/source_api'; +import { InfraBackendLibs } from '../../lib/infra_types'; +import { InfraIndexType } from '../../graphql/types'; + +const typeToInfraIndexType = (value: string | undefined) => { + switch (value) { + case 'metrics': + return InfraIndexType.METRICS; + case 'logs': + return InfraIndexType.LOGS; + default: + return InfraIndexType.ANY; + } +}; + +export const initSourceRoute = (libs: InfraBackendLibs) => { + const { framework } = libs; + + framework.registerRoute( + { + method: 'get', + path: '/api/metrics/source/{sourceId}/{type?}', + validate: { + params: schema.object({ + sourceId: schema.string(), + type: schema.string(), + }), + }, + }, + async (requestContext, request, response) => { + try { + const { type, sourceId } = request.params; + + const source = await libs.sources.getSourceConfiguration(requestContext, sourceId); + if (!source) { + return response.notFound(); + } + + const status = { + logIndicesExist: await libs.sourceStatus.hasLogIndices(requestContext, sourceId), + metricIndicesExist: await libs.sourceStatus.hasMetricIndices(requestContext, sourceId), + indexFields: await libs.fields.getFields( + requestContext, + sourceId, + typeToInfraIndexType(type) + ), + }; + + return response.ok({ + body: SourceResponseRuntimeType.encode({ source, status }), + }); + } catch (error) { + return response.internalError({ + body: error.message, + }); + } + } + ); +}; diff --git a/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts b/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts index 3496ea782ee99..17509571f1985 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts +++ b/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.test.ts @@ -3,11 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { NewDatasource, DatasourceInput } from '../types'; +import { Datasource, NewDatasource, DatasourceInput } from '../types'; import { storedDatasourceToAgentDatasource } from './datasource_to_agent_datasource'; describe('Ingest Manager - storedDatasourceToAgentDatasource', () => { - const mockDatasource: NewDatasource = { + const mockNewDatasource: NewDatasource = { name: 'mock-datasource', description: '', config_id: '', @@ -17,6 +17,12 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => { inputs: [], }; + const mockDatasource: Datasource = { + ...mockNewDatasource, + id: 'some-uuid', + revision: 1, + }; + const mockInput: DatasourceInput = { type: 'test-logs', enabled: true, @@ -70,7 +76,8 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => { it('returns agent datasource config for datasource with no inputs', () => { expect(storedDatasourceToAgentDatasource(mockDatasource)).toEqual({ - id: 'mock-datasource', + id: 'some-uuid', + name: 'mock-datasource', namespace: 'default', enabled: true, use_output: 'default', @@ -87,7 +94,8 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => { }, }) ).toEqual({ - id: 'mock-datasource', + id: 'some-uuid', + name: 'mock-datasource', namespace: 'default', enabled: true, use_output: 'default', @@ -99,9 +107,21 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => { }); }); + it('uses name for id when id is not provided in case of new datasource', () => { + expect(storedDatasourceToAgentDatasource(mockNewDatasource)).toEqual({ + id: 'mock-datasource', + name: 'mock-datasource', + namespace: 'default', + enabled: true, + use_output: 'default', + inputs: [], + }); + }); + it('returns agent datasource config with flattened input and package stream', () => { expect(storedDatasourceToAgentDatasource({ ...mockDatasource, inputs: [mockInput] })).toEqual({ - id: 'mock-datasource', + id: 'some-uuid', + name: 'mock-datasource', namespace: 'default', enabled: true, use_output: 'default', @@ -140,7 +160,8 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => { ], }) ).toEqual({ - id: 'mock-datasource', + id: 'some-uuid', + name: 'mock-datasource', namespace: 'default', enabled: true, use_output: 'default', @@ -169,7 +190,8 @@ describe('Ingest Manager - storedDatasourceToAgentDatasource', () => { inputs: [{ ...mockInput, enabled: false }], }) ).toEqual({ - id: 'mock-datasource', + id: 'some-uuid', + name: 'mock-datasource', namespace: 'default', enabled: true, use_output: 'default', diff --git a/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts b/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts index b509878b7f945..9e09d3fa3153a 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts +++ b/x-pack/plugins/ingest_manager/common/services/datasource_to_agent_datasource.ts @@ -12,7 +12,8 @@ export const storedDatasourceToAgentDatasource = ( const { name, namespace, enabled, package: pkg, inputs } = datasource; const fullDatasource: FullAgentConfigDatasource = { - id: name, + id: 'id' in datasource ? datasource.id : name, + name, namespace, enabled, use_output: DEFAULT_OUTPUT.name, // TODO: hardcoded to default output for now diff --git a/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts b/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts index 002c3784446a8..2372caee512af 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts @@ -34,8 +34,10 @@ export interface AgentConfig extends NewAgentConfig, SavedObjectAttributes { revision: number; } -export type FullAgentConfigDatasource = Pick & { - id: string; +export type FullAgentConfigDatasource = Pick< + Datasource, + 'id' | 'name' | 'namespace' | 'enabled' +> & { package?: Pick; use_output: string; inputs: Array< diff --git a/x-pack/plugins/ingest_manager/common/types/models/epm.ts b/x-pack/plugins/ingest_manager/common/types/models/epm.ts index 064341c68a97a..53ad0310ea613 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/epm.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/epm.ts @@ -218,6 +218,7 @@ export type PackageInfo = Installable< export interface Installation extends SavedObjectAttributes { installed: AssetReference[]; + es_index_patterns: Record; name: string; version: string; } diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/components/alpha_messaging.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/components/alpha_messaging.tsx new file mode 100644 index 0000000000000..0f3ddee29fa44 --- /dev/null +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/components/alpha_messaging.tsx @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import React from 'react'; +import styled from 'styled-components'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { EuiText } from '@elastic/eui'; + +const Message = styled(EuiText).attrs(props => ({ + color: 'subdued', + textAlign: 'center', +}))` + padding: ${props => props.theme.eui.paddingSizes.m}; +`; + +export const AlphaMessaging: React.FC<{}> = () => ( + +

+ + + + + {' – '} + + +

+
+); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/components/header.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/components/header.tsx index 1aab6d901a992..ceb87fb048ae3 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/components/header.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/components/header.tsx @@ -31,7 +31,7 @@ const Tabs = styled(EuiTabs)` `; export interface HeaderProps { - restrictHeaderWidth?: number; + maxWidth?: number; leftColumn?: JSX.Element; rightColumn?: JSX.Element; rightColumnGrow?: EuiFlexItemProps['grow']; @@ -52,10 +52,10 @@ export const Header: React.FC = ({ rightColumn, rightColumnGrow, tabs, - restrictHeaderWidth, + maxWidth, }) => ( - + = ({ section, childre {children} + ); }; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/layouts/with_header.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/layouts/with_header.tsx index c77a50d95dca3..d5ce5e17ad84e 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/layouts/with_header.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/layouts/with_header.tsx @@ -14,12 +14,18 @@ const Page = styled(EuiPage)` interface Props extends HeaderProps { restrictWidth?: number; + restrictHeaderWidth?: number; children?: React.ReactNode; } -export const WithHeaderLayout: React.FC = ({ restrictWidth, children, ...rest }) => ( +export const WithHeaderLayout: React.FC = ({ + restrictWidth, + restrictHeaderWidth, + children, + ...rest +}) => ( -
+
diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/layout.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/layout.tsx index 73a7ba8ec119d..39d882f7fdf65 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/layout.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/layout.tsx @@ -18,16 +18,14 @@ import { import { WithHeaderLayout } from '../../../../layouts'; import { AgentConfig, PackageInfo } from '../../../../types'; import { PackageIcon } from '../../../../components/package_icon'; -import { CreateDatasourceFrom, CreateDatasourceStep } from '../types'; +import { CreateDatasourceFrom } from '../types'; export const CreateDatasourcePageLayout: React.FunctionComponent<{ from: CreateDatasourceFrom; - basePath: string; cancelUrl: string; - maxStep: CreateDatasourceStep | ''; agentConfig?: AgentConfig; packageInfo?: PackageInfo; -}> = ({ from, basePath, cancelUrl, maxStep, agentConfig, packageInfo, children }) => { +}> = ({ from, cancelUrl, agentConfig, packageInfo, children }) => { const leftColumn = ( diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx index 1ad579d591b21..3c79fe17fdbb5 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx @@ -28,12 +28,11 @@ import { } from '../../../hooks'; import { useLinks as useEPMLinks } from '../../epm/hooks'; import { CreateDatasourcePageLayout, ConfirmCreateDatasourceModal } from './components'; -import { CreateDatasourceFrom, CreateDatasourceStep } from './types'; +import { CreateDatasourceFrom } from './types'; import { DatasourceValidationResults, validateDatasource, validationHasErrors } from './services'; import { StepSelectPackage } from './step_select_package'; import { StepSelectConfig } from './step_select_config'; import { StepConfigureDatasource } from './step_configure_datasource'; - import { StepDefineDatasource } from './step_define_datasource'; export const CreateDatasourcePage: React.FunctionComponent = () => { @@ -43,11 +42,9 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { } = useConfig(); const { params: { configId, pkgkey }, - url: basePath, } = useRouteMatch(); const history = useHistory(); const from: CreateDatasourceFrom = configId ? 'config' : 'package'; - const [maxStep, setMaxStep] = useState(''); // Agent config and package info states const [agentConfig, setAgentConfig] = useState(); @@ -91,7 +88,6 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { } else { setFormState('INVALID'); setPackageInfo(undefined); - setMaxStep(''); } // eslint-disable-next-line no-console @@ -105,7 +101,6 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { } else { setFormState('INVALID'); setAgentConfig(undefined); - setMaxStep(''); } // eslint-disable-next-line no-console @@ -189,9 +184,7 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { const layoutProps = { from, - basePath, cancelUrl, - maxStep, agentConfig, packageInfo, }; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/types.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/types.ts index bd05be2d8a558..85cc758fc4c46 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/types.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/types.ts @@ -5,4 +5,3 @@ */ export type CreateDatasourceFrom = 'package' | 'config'; -export type CreateDatasourceStep = 'selectConfig' | 'selectPackage' | 'configure' | 'review'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/yaml/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/yaml/index.tsx index c1cdde730837f..ad27c590d5eaa 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/yaml/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/yaml/index.tsx @@ -25,7 +25,17 @@ import { import { ShellEnrollmentInstructions } from '../../../../../components/enrollment_instructions'; import { Loading } from '../../../../../components'; -const CONFIG_KEYS_ORDER = ['id', 'revision', 'outputs', 'datasources']; +const CONFIG_KEYS_ORDER = [ + 'id', + 'name', + 'revision', + 'type', + 'outputs', + 'datasources', + 'enabled', + 'package', + 'input', +]; export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => { const core = useCore(); @@ -44,10 +54,20 @@ export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => { return ( - + {dump(fullConfigRequest.data.item, { sortKeys: (keyA: string, keyB: string) => { - return CONFIG_KEYS_ORDER.indexOf(keyA) - CONFIG_KEYS_ORDER.indexOf(keyB); + const indexA = CONFIG_KEYS_ORDER.indexOf(keyA); + const indexB = CONFIG_KEYS_ORDER.indexOf(keyB); + if (indexA >= 0 && indexB < 0) { + return -1; + } + + if (indexA < 0 && indexB >= 0) { + return 1; + } + + return indexA - indexB; }, })} diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/index.tsx index ea6b045f504ec..05d150fd9ae23 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/index.tsx @@ -3,12 +3,71 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; -import { EuiText, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import React, { useState } from 'react'; +import styled from 'styled-components'; +import { + EuiButton, + EuiButtonEmpty, + EuiPanel, + EuiText, + EuiTitle, + EuiDescriptionList, + EuiDescriptionListDescription, + EuiDescriptionListTitle, + EuiFlexGrid, + EuiFlexGroup, + EuiFlexItem, +} from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { WithHeaderLayout } from '../../layouts'; +import { useLink, useGetAgentConfigs } from '../../hooks'; +import { AgentEnrollmentFlyout } from '../fleet/agent_list_page/components'; +import { EPM_PATH, FLEET_PATH, AGENT_CONFIG_PATH } from '../../constants'; + +const OverviewPanel = styled(EuiPanel).attrs(props => ({ + paddingSize: 'm', +}))` + header { + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1px solid ${props => props.theme.eui.euiColorLightShade}; + margin: -${props => props.theme.eui.paddingSizes.m} -${props => props.theme.eui.paddingSizes.m} + ${props => props.theme.eui.paddingSizes.m}; + padding: ${props => props.theme.eui.paddingSizes.s} ${props => props.theme.eui.paddingSizes.m}; + } + + h2 { + padding: ${props => props.theme.eui.paddingSizes.xs} 0; + } +`; + +const OverviewStats = styled(EuiDescriptionList).attrs(props => ({ + compressed: true, + textStyle: 'reverse', + type: 'column', +}))` + & > * { + margin-top: ${props => props.theme.eui.paddingSizes.s} !important; + + &:first-child, + &:nth-child(2) { + margin-top: 0 !important; + } + } +`; export const IngestManagerOverview: React.FunctionComponent = () => { + // Agent enrollment flyout state + const [isEnrollmentFlyoutOpen, setIsEnrollmentFlyoutOpen] = useState(false); + + // Agent configs required for enrollment flyout + const agentConfigsRequest = useGetAgentConfigs({ + page: 1, + perPage: 1000, + }); + const agentConfigs = agentConfigsRequest.data ? agentConfigsRequest.data.items : []; + return ( {

} - /> + rightColumn={ + + + setIsEnrollmentFlyoutOpen(true)}> + + + + + } + > + {isEnrollmentFlyoutOpen && ( + setIsEnrollmentFlyoutOpen(false)} + /> + )} + + + + +
+ +

+ +

+
+ + + +
+ + Total available + 999 + Installed + 1 + Updated available + 0 + +
+
+ + + +
+ +

+ +

+
+ + + +
+ + Total configs + 1 + Data sources + 1 + +
+
+ + + +
+ +

+ +

+
+ + + +
+ + Total agents + 0 + Active + 0 + Offline + 0 + Error + 0 + +
+
+ + + +
+ +

+ +

+
+ + + +
+ + Data streams + 0 + Name spaces + 0 + Total size + 0 MB + +
+
+
+ ); }; diff --git a/x-pack/plugins/ingest_manager/server/index.ts b/x-pack/plugins/ingest_manager/server/index.ts index df7c3d7cf0fbf..7859c44ccfd89 100644 --- a/x-pack/plugins/ingest_manager/server/index.ts +++ b/x-pack/plugins/ingest_manager/server/index.ts @@ -7,6 +7,9 @@ import { schema, TypeOf } from '@kbn/config-schema'; import { PluginInitializerContext } from 'src/core/server'; import { IngestManagerPlugin } from './plugin'; +export { ESIndexPatternService } from './services'; +export { IngestManagerSetupContract } from './plugin'; + export const config = { exposeToBrowser: { epm: true, diff --git a/x-pack/plugins/ingest_manager/server/plugin.ts b/x-pack/plugins/ingest_manager/server/plugin.ts index 45c847fe1f68a..4dd070a7414f0 100644 --- a/x-pack/plugins/ingest_manager/server/plugin.ts +++ b/x-pack/plugins/ingest_manager/server/plugin.ts @@ -11,7 +11,9 @@ import { Plugin, PluginInitializerContext, SavedObjectsServiceStart, -} from 'src/core/server'; + RecursiveReadonly, +} from 'kibana/server'; +import { deepFreeze } from '../../../../src/core/utils'; import { LicensingPluginSetup } from '../../licensing/server'; import { EncryptedSavedObjectsPluginStart } from '../../encrypted_saved_objects/server'; import { SecurityPluginSetup } from '../../security/server'; @@ -38,7 +40,18 @@ import { } from './routes'; import { IngestManagerConfigType } from '../common'; -import { appContextService } from './services'; +import { + appContextService, + ESIndexPatternService, + ESIndexPatternSavedObjectService, +} from './services'; + +/** + * Describes public IngestManager plugin contract returned at the `setup` stage. + */ +export interface IngestManagerSetupContract { + esIndexPatternService: ESIndexPatternService; +} export interface IngestManagerSetupDeps { licensing: LicensingPluginSetup; @@ -63,7 +76,7 @@ const allSavedObjectTypes = [ ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, ]; -export class IngestManagerPlugin implements Plugin { +export class IngestManagerPlugin implements Plugin { private config$: Observable; private security: SecurityPluginSetup | undefined; @@ -71,7 +84,10 @@ export class IngestManagerPlugin implements Plugin { this.config$ = this.initializerContext.config.create(); } - public async setup(core: CoreSetup, deps: IngestManagerSetupDeps) { + public async setup( + core: CoreSetup, + deps: IngestManagerSetupDeps + ): Promise> { if (deps.security) { this.security = deps.security; } @@ -130,6 +146,9 @@ export class IngestManagerPlugin implements Plugin { basePath: core.http.basePath, }); } + return deepFreeze({ + esIndexPatternService: new ESIndexPatternSavedObjectService(), + }); } public async start( diff --git a/x-pack/plugins/ingest_manager/server/saved_objects.ts b/x-pack/plugins/ingest_manager/server/saved_objects.ts index 1c36fda36847d..dc0b4695603e4 100644 --- a/x-pack/plugins/ingest_manager/server/saved_objects.ts +++ b/x-pack/plugins/ingest_manager/server/saved_objects.ts @@ -150,6 +150,10 @@ export const savedObjectMappings = { name: { type: 'keyword' }, version: { type: 'keyword' }, internal: { type: 'boolean' }, + es_index_patterns: { + dynamic: false, + type: 'object', + }, installed: { type: 'nested', properties: { diff --git a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap index 0e239c24dd9cf..166983fbccc35 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap +++ b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/__snapshots__/template.test.ts.snap @@ -47,12 +47,12 @@ exports[`tests loading base.yml: base.yml 1`] = ` "user": { "properties": { "auid": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "euid": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" } } }, @@ -73,12 +73,12 @@ exports[`tests loading base.yml: base.yml 1`] = ` "nested": { "properties": { "bar": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "baz": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" } } }, @@ -142,8 +142,8 @@ exports[`tests loading coredns.logs.yml: coredns.logs.yml 1`] = ` "coredns": { "properties": { "id": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "query": { "properties": { @@ -151,28 +151,28 @@ exports[`tests loading coredns.logs.yml: coredns.logs.yml 1`] = ` "type": "long" }, "class": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "name": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "type": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" } } }, "response": { "properties": { "code": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "flags": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "size": { "type": "long" @@ -509,12 +509,12 @@ exports[`tests loading system.yml: system.yml 1`] = ` "diskio": { "properties": { "name": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "serial_number": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "read": { "properties": { @@ -643,16 +643,16 @@ exports[`tests loading system.yml: system.yml 1`] = ` "type": "long" }, "device_name": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "type": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "mount_point": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "files": { "type": "long" @@ -867,8 +867,8 @@ exports[`tests loading system.yml: system.yml 1`] = ` "network": { "properties": { "name": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "out": { "properties": { @@ -946,12 +946,12 @@ exports[`tests loading system.yml: system.yml 1`] = ` "process": { "properties": { "state": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "cmdline": { - "type": "keyword", - "ignore_above": 2048 + "ignore_above": 2048, + "type": "keyword" }, "env": { "type": "object" @@ -1040,22 +1040,22 @@ exports[`tests loading system.yml: system.yml 1`] = ` "cgroup": { "properties": { "id": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "path": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "cpu": { "properties": { "id": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "path": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "cfs": { "properties": { @@ -1118,12 +1118,12 @@ exports[`tests loading system.yml: system.yml 1`] = ` "cpuacct": { "properties": { "id": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "path": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "total": { "properties": { @@ -1158,12 +1158,12 @@ exports[`tests loading system.yml: system.yml 1`] = ` "memory": { "properties": { "id": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "path": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "mem": { "properties": { @@ -1382,12 +1382,12 @@ exports[`tests loading system.yml: system.yml 1`] = ` "blkio": { "properties": { "id": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "path": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "total": { "properties": { @@ -1436,20 +1436,20 @@ exports[`tests loading system.yml: system.yml 1`] = ` "raid": { "properties": { "name": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "status": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "level": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "sync_action": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "disks": { "properties": { @@ -1507,24 +1507,24 @@ exports[`tests loading system.yml: system.yml 1`] = ` "type": "long" }, "host": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "etld_plus_one": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "host_error": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" } } }, "process": { "properties": { "cmdline": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" } } }, @@ -1622,42 +1622,42 @@ exports[`tests loading system.yml: system.yml 1`] = ` "users": { "properties": { "id": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "seat": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "path": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "type": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "service": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "remote": { "type": "boolean" }, "state": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "scope": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" }, "leader": { "type": "long" }, "remote_host": { - "type": "keyword", - "ignore_above": 1024 + "ignore_above": 1024, + "type": "keyword" } } } diff --git a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.test.ts b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.test.ts index f4e13748641ed..1a73c9581a2de 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.test.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.test.ts @@ -63,3 +63,199 @@ test('tests loading system.yml', () => { expect(template).toMatchSnapshot(path.basename(ymlPath)); }); + +test('tests processing text field with multi fields', () => { + const textWithMultiFieldsLiteralYml = ` +- name: textWithMultiFields + type: text + multi_fields: + - name: raw + type: keyword + - name: indexed + type: text +`; + const textWithMultiFieldsMapping = { + properties: { + textWithMultiFields: { + type: 'text', + fields: { + raw: { + ignore_above: 1024, + type: 'keyword', + }, + indexed: { + type: 'text', + }, + }, + }, + }, + }; + const fields: Field[] = safeLoad(textWithMultiFieldsLiteralYml); + const processedFields = processFields(fields); + const mappings = generateMappings(processedFields); + expect(JSON.stringify(mappings)).toEqual(JSON.stringify(textWithMultiFieldsMapping)); +}); + +test('tests processing keyword field with multi fields', () => { + const keywordWithMultiFieldsLiteralYml = ` +- name: keywordWithMultiFields + type: keyword + multi_fields: + - name: raw + type: keyword + - name: indexed + type: text +`; + + const keywordWithMultiFieldsMapping = { + properties: { + keywordWithMultiFields: { + ignore_above: 1024, + type: 'keyword', + fields: { + raw: { + ignore_above: 1024, + type: 'keyword', + }, + indexed: { + type: 'text', + }, + }, + }, + }, + }; + const fields: Field[] = safeLoad(keywordWithMultiFieldsLiteralYml); + const processedFields = processFields(fields); + const mappings = generateMappings(processedFields); + expect(JSON.stringify(mappings)).toEqual(JSON.stringify(keywordWithMultiFieldsMapping)); +}); + +test('tests processing keyword field with multi fields with analyzed text field', () => { + const keywordWithAnalyzedMultiFieldsLiteralYml = ` + - name: keywordWithAnalyzedMultiField + type: keyword + multi_fields: + - name: analyzed + type: text + analyzer: autocomplete + search_analyzer: standard + `; + + const keywordWithAnalyzedMultiFieldsMapping = { + properties: { + keywordWithAnalyzedMultiField: { + ignore_above: 1024, + type: 'keyword', + fields: { + analyzed: { + analyzer: 'autocomplete', + search_analyzer: 'standard', + type: 'text', + }, + }, + }, + }, + }; + const fields: Field[] = safeLoad(keywordWithAnalyzedMultiFieldsLiteralYml); + const processedFields = processFields(fields); + const mappings = generateMappings(processedFields); + expect(JSON.stringify(mappings)).toEqual(JSON.stringify(keywordWithAnalyzedMultiFieldsMapping)); +}); + +test('tests processing object field with no other attributes', () => { + const objectFieldLiteralYml = ` +- name: objectField + type: object +`; + const objectFieldMapping = { + properties: { + objectField: { + type: 'object', + }, + }, + }; + const fields: Field[] = safeLoad(objectFieldLiteralYml); + const processedFields = processFields(fields); + const mappings = generateMappings(processedFields); + expect(JSON.stringify(mappings)).toEqual(JSON.stringify(objectFieldMapping)); +}); + +test('tests processing object field with enabled set to false', () => { + const objectFieldEnabledFalseLiteralYml = ` +- name: objectField + type: object + enabled: false +`; + const objectFieldEnabledFalseMapping = { + properties: { + objectField: { + type: 'object', + enabled: false, + }, + }, + }; + const fields: Field[] = safeLoad(objectFieldEnabledFalseLiteralYml); + const processedFields = processFields(fields); + const mappings = generateMappings(processedFields); + expect(JSON.stringify(mappings)).toEqual(JSON.stringify(objectFieldEnabledFalseMapping)); +}); + +test('tests processing object field with dynamic set to false', () => { + const objectFieldDynamicFalseLiteralYml = ` +- name: objectField + type: object + dynamic: false +`; + const objectFieldDynamicFalseMapping = { + properties: { + objectField: { + type: 'object', + dynamic: false, + }, + }, + }; + const fields: Field[] = safeLoad(objectFieldDynamicFalseLiteralYml); + const processedFields = processFields(fields); + const mappings = generateMappings(processedFields); + expect(JSON.stringify(mappings)).toEqual(JSON.stringify(objectFieldDynamicFalseMapping)); +}); + +test('tests processing object field with dynamic set to true', () => { + const objectFieldDynamicTrueLiteralYml = ` +- name: objectField + type: object + dynamic: true +`; + const objectFieldDynamicTrueMapping = { + properties: { + objectField: { + type: 'object', + dynamic: true, + }, + }, + }; + const fields: Field[] = safeLoad(objectFieldDynamicTrueLiteralYml); + const processedFields = processFields(fields); + const mappings = generateMappings(processedFields); + expect(JSON.stringify(mappings)).toEqual(JSON.stringify(objectFieldDynamicTrueMapping)); +}); + +test('tests processing object field with dynamic set to strict', () => { + const objectFieldDynamicStrictLiteralYml = ` +- name: objectField + type: object + dynamic: strict +`; + const objectFieldDynamicStrictMapping = { + properties: { + objectField: { + type: 'object', + dynamic: 'strict', + }, + }, + }; + const fields: Field[] = safeLoad(objectFieldDynamicStrictLiteralYml); + const processedFields = processFields(fields); + const mappings = generateMappings(processedFields); + expect(JSON.stringify(mappings)).toEqual(JSON.stringify(objectFieldDynamicStrictMapping)); +}); diff --git a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts index 71c9acc6c10da..22a61d2bdfb7c 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Field } from '../../fields/field'; +import { Field, Fields } from '../../fields/field'; import { Dataset, IndexTemplate } from '../../../../types'; import { getDatasetAssetBaseName } from '../index'; @@ -15,6 +15,14 @@ interface Mappings { properties: any; } +interface Mapping { + [key: string]: any; +} + +interface MultiFields { + [key: string]: object; +} + const DEFAULT_SCALING_FACTOR = 1000; const DEFAULT_IGNORE_ABOVE = 1024; @@ -67,26 +75,27 @@ export function generateMappings(fields: Field[]): Mappings { fieldProps.scaling_factor = field.scaling_factor || DEFAULT_SCALING_FACTOR; break; case 'text': - fieldProps.type = 'text'; - if (field.analyzer) { - fieldProps.analyzer = field.analyzer; - } - if (field.search_analyzer) { - fieldProps.search_analyzer = field.search_analyzer; + const textMapping = generateTextMapping(field); + fieldProps = { ...fieldProps, ...textMapping, type: 'text' }; + if (field.multi_fields) { + fieldProps.fields = generateMultiFields(field.multi_fields); } break; case 'keyword': - fieldProps.type = 'keyword'; - if (field.ignore_above) { - fieldProps.ignore_above = field.ignore_above; - } else { - fieldProps.ignore_above = DEFAULT_IGNORE_ABOVE; + const keywordMapping = generateKeywordMapping(field); + fieldProps = { ...fieldProps, ...keywordMapping, type: 'keyword' }; + if (field.multi_fields) { + fieldProps.fields = generateMultiFields(field.multi_fields); } break; - // TODO move handling of multi_fields here? case 'object': - // TODO improve fieldProps.type = 'object'; + if (field.hasOwnProperty('enabled')) { + fieldProps.enabled = field.enabled; + } + if (field.hasOwnProperty('dynamic')) { + fieldProps.dynamic = field.dynamic; + } break; case 'array': // this assumes array fields were validated in an earlier step @@ -113,6 +122,45 @@ export function generateMappings(fields: Field[]): Mappings { return { properties: props }; } +function generateMultiFields(fields: Fields): MultiFields { + const multiFields: MultiFields = {}; + if (fields) { + fields.forEach((f: Field) => { + const type = f.type; + switch (type) { + case 'text': + multiFields[f.name] = { ...generateTextMapping(f), type: f.type }; + break; + case 'keyword': + multiFields[f.name] = { ...generateKeywordMapping(f), type: f.type }; + break; + } + }); + } + return multiFields; +} + +function generateKeywordMapping(field: Field): Mapping { + const mapping: Mapping = { + ignore_above: DEFAULT_IGNORE_ABOVE, + }; + if (field.ignore_above) { + mapping.ignore_above = field.ignore_above; + } + return mapping; +} + +function generateTextMapping(field: Field): Mapping { + const mapping: Mapping = {}; + if (field.analyzer) { + mapping.analyzer = field.analyzer; + } + if (field.search_analyzer) { + mapping.search_analyzer = field.search_analyzer; + } + return mapping; +} + function getDefaultProperties(field: Field): Properties { const properties: Properties = {}; @@ -136,6 +184,22 @@ export function generateTemplateName(dataset: Dataset): string { return getDatasetAssetBaseName(dataset); } +/** + * Returns a map of the dataset path fields to elasticsearch index pattern. + * @param datasets an array of Dataset objects + */ +export function generateESIndexPatterns(datasets: Dataset[] | undefined): Record { + if (!datasets) { + return {}; + } + + const patterns: Record = {}; + for (const dataset of datasets) { + patterns[dataset.path] = generateTemplateName(dataset) + '-*'; + } + return patterns; +} + function getBaseTemplate(type: string, templateName: string, mappings: Mappings): IndexTemplate { return { // We need to decide which order we use for the templates diff --git a/x-pack/plugins/ingest_manager/server/services/epm/fields/field.ts b/x-pack/plugins/ingest_manager/server/services/epm/fields/field.ts index 810896bb50389..9c9843e0454ab 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/fields/field.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/fields/field.ts @@ -27,6 +27,7 @@ export interface Field { ignore_above?: number; object_type?: string; scaling_factor?: number; + dynamic?: 'strict' | boolean; // Kibana specific analyzed?: boolean; diff --git a/x-pack/plugins/ingest_manager/server/services/epm/packages/install.ts b/x-pack/plugins/ingest_manager/server/services/epm/packages/install.ts index e250b4f176819..0a7642752b3e9 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/packages/install.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/packages/install.ts @@ -18,6 +18,7 @@ import * as Registry from '../registry'; import { getObject } from './get_objects'; import { getInstallation } from './index'; import { installTemplates } from '../elasticsearch/template/install'; +import { generateESIndexPatterns } from '../elasticsearch/template/template'; import { installPipelines } from '../elasticsearch/ingest_pipeline/install'; import { installILMPolicy } from '../elasticsearch/ilm/install'; @@ -117,17 +118,18 @@ export async function installPackage(options: { installTemplatePromises, ]); - const toSave = res.flat(); + const toSaveAssetRefs: AssetReference[] = res.flat(); + const toSaveESIndexPatterns = generateESIndexPatterns(registryPackageInfo.datasets); // Save those references in the package manager's state saved object - await saveInstallationReferences({ + return await saveInstallationReferences({ savedObjectsClient, pkgkey, pkgName, pkgVersion, internal, - toSave, + toSaveAssetRefs, + toSaveESIndexPatterns, }); - return toSave; } // TODO: make it an exhaustive list @@ -156,25 +158,44 @@ export async function saveInstallationReferences(options: { pkgName: string; pkgVersion: string; internal: boolean; - toSave: AssetReference[]; + toSaveAssetRefs: AssetReference[]; + toSaveESIndexPatterns: Record; }) { - const { savedObjectsClient, pkgName, pkgVersion, internal, toSave } = options; + const { + savedObjectsClient, + pkgName, + pkgVersion, + internal, + toSaveAssetRefs, + toSaveESIndexPatterns, + } = options; const installation = await getInstallation({ savedObjectsClient, pkgName }); - const savedRefs = installation?.installed || []; + const savedAssetRefs = installation?.installed || []; + const toInstallESIndexPatterns = Object.assign( + installation?.es_index_patterns || {}, + toSaveESIndexPatterns + ); + const mergeRefsReducer = (current: AssetReference[], pending: AssetReference) => { const hasRef = current.find(c => c.id === pending.id && c.type === pending.type); if (!hasRef) current.push(pending); return current; }; - const toInstall = toSave.reduce(mergeRefsReducer, savedRefs); + const toInstallAssetsRefs = toSaveAssetRefs.reduce(mergeRefsReducer, savedAssetRefs); await savedObjectsClient.create( PACKAGES_SAVED_OBJECT_TYPE, - { installed: toInstall, name: pkgName, version: pkgVersion, internal }, + { + installed: toInstallAssetsRefs, + es_index_patterns: toInstallESIndexPatterns, + name: pkgName, + version: pkgVersion, + internal, + }, { id: pkgName, overwrite: true } ); - return toInstall; + return toInstallAssetsRefs; } async function installKibanaSavedObjects({ diff --git a/x-pack/plugins/ingest_manager/server/services/es_index_pattern.ts b/x-pack/plugins/ingest_manager/server/services/es_index_pattern.ts new file mode 100644 index 0000000000000..167e22873979c --- /dev/null +++ b/x-pack/plugins/ingest_manager/server/services/es_index_pattern.ts @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { SavedObjectsClientContract } from 'kibana/server'; +import { getInstallation } from './epm/packages/get'; + +export interface ESIndexPatternService { + getESIndexPattern( + savedObjectsClient: SavedObjectsClientContract, + pkgName: string, + datasetPath: string + ): Promise; +} + +export class ESIndexPatternSavedObjectService implements ESIndexPatternService { + public async getESIndexPattern( + savedObjectsClient: SavedObjectsClientContract, + pkgName: string, + datasetPath: string + ): Promise { + const installation = await getInstallation({ savedObjectsClient, pkgName }); + return installation?.es_index_patterns[datasetPath]; + } +} diff --git a/x-pack/plugins/ingest_manager/server/services/index.ts b/x-pack/plugins/ingest_manager/server/services/index.ts index dd0c898afa425..d64f1b0c2b6fb 100644 --- a/x-pack/plugins/ingest_manager/server/services/index.ts +++ b/x-pack/plugins/ingest_manager/server/services/index.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ export { appContextService } from './app_context'; +export { ESIndexPatternService, ESIndexPatternSavedObjectService } from './es_index_pattern'; // Saved object services export { datasourceService } from './datasource'; diff --git a/x-pack/plugins/lens/public/datatable_visualization/expression.tsx b/x-pack/plugins/lens/public/datatable_visualization/expression.tsx index cbdc0617e8568..772ee13168d02 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/expression.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/expression.tsx @@ -140,6 +140,7 @@ function DatatableComponent(props: DatatableProps & { formatFactory: FormatFacto { const col = firstTable.columns.find(c => c.id === field); diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/_expression_renderer.scss b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/_expression_renderer.scss index d43a857e05639..9519544ece575 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/_expression_renderer.scss +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/_expression_renderer.scss @@ -1,9 +1,10 @@ .lnsExpressionRenderer { + @include euiScrollBar; position: relative; width: 100%; height: 100%; display: flex; - overflow-x: hidden; + overflow: auto; .lnsExpressionRenderer__component { position: static; // Let the progress indicator position itself against the outer parent diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/_workspace_panel_wrapper.scss b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/_workspace_panel_wrapper.scss index 3ef387eca1e8b..4ba19cb4ab05b 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/_workspace_panel_wrapper.scss +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/_workspace_panel_wrapper.scss @@ -29,7 +29,7 @@ display: flex; align-items: center; justify-content: center; - overflow-x: hidden; + overflow: hidden; } } } diff --git a/x-pack/plugins/lens/server/routes/existing_fields.test.ts b/x-pack/plugins/lens/server/routes/existing_fields.test.ts index 9bd11b6863d93..ed1f85ab902f8 100644 --- a/x-pack/plugins/lens/server/routes/existing_fields.test.ts +++ b/x-pack/plugins/lens/server/routes/existing_fields.test.ts @@ -57,6 +57,24 @@ describe('existingFields', () => { expect(result).toEqual(['geo.coordinates']); }); + it('should handle objects with dotted fields', () => { + const result = existingFields( + [indexPattern({ 'geo.country_name': 'US' })], + [field('geo.country_name')] + ); + + expect(result).toEqual(['geo.country_name']); + }); + + it('should handle arrays with dotted fields on both sides', () => { + const result = existingFields( + [indexPattern({ 'process.cpu': [{ 'user.pct': 50 }] })], + [field('process.cpu.user.pct')] + ); + + expect(result).toEqual(['process.cpu.user.pct']); + }); + it('should be false if it hits a positive leaf before the end of the path', () => { const result = existingFields( [indexPattern({ geo: { coordinates: 32 } })], diff --git a/x-pack/plugins/lens/server/routes/existing_fields.ts b/x-pack/plugins/lens/server/routes/existing_fields.ts index b1964a9150982..3e91d17950061 100644 --- a/x-pack/plugins/lens/server/routes/existing_fields.ts +++ b/x-pack/plugins/lens/server/routes/existing_fields.ts @@ -258,6 +258,8 @@ async function fetchIndexPatternStats({ return result.hits.hits; } +// Recursive function to determine if the _source of a document +// contains a known path. function exists(obj: unknown, path: string[], i = 0): boolean { if (obj == null) { return false; @@ -272,6 +274,22 @@ function exists(obj: unknown, path: string[], i = 0): boolean { } if (typeof obj === 'object') { + // Because Elasticsearch flattens paths, dots in the field name are allowed + // as JSON keys. For example, { 'a.b': 10 } + const partialKeyMatches = Object.getOwnPropertyNames(obj) + .map(key => key.split('.')) + .filter(keyPaths => keyPaths.every((key, keyIndex) => key === path[keyIndex + i])); + + if (partialKeyMatches.length) { + return partialKeyMatches.every(keyPaths => { + return exists( + (obj as Record)[keyPaths.join('.')], + path, + i + keyPaths.length + ); + }); + } + return exists((obj as Record)[path[i]], path, i + 1); } diff --git a/x-pack/plugins/lens/server/saved_objects.ts b/x-pack/plugins/lens/server/saved_objects.ts index b2eb325c09266..ac80eb098e780 100644 --- a/x-pack/plugins/lens/server/saved_objects.ts +++ b/x-pack/plugins/lens/server/saved_objects.ts @@ -12,7 +12,7 @@ export function setupSavedObjects(core: CoreSetup) { core.savedObjects.registerType({ name: 'lens', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'lensApp', defaultSearchField: 'title', @@ -46,7 +46,7 @@ export function setupSavedObjects(core: CoreSetup) { core.savedObjects.registerType({ name: 'lens-ui-telemetry', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { name: { diff --git a/x-pack/plugins/lens/server/usage/task.ts b/x-pack/plugins/lens/server/usage/task.ts index 469457f973b62..e1a0bf20f7b48 100644 --- a/x-pack/plugins/lens/server/usage/task.ts +++ b/x-pack/plugins/lens/server/usage/task.ts @@ -210,6 +210,7 @@ export function telemetryTaskRunner( }) .catch(errMsg => logger.warn(`Error executing lens telemetry task: ${errMsg}`)); }, + async cancel() {}, }; }; } diff --git a/x-pack/plugins/logstash/kibana.json b/x-pack/plugins/logstash/kibana.json index bcc926535d3c2..97dbf58865a88 100644 --- a/x-pack/plugins/logstash/kibana.json +++ b/x-pack/plugins/logstash/kibana.json @@ -4,9 +4,13 @@ "kibanaVersion": "kibana", "configPath": ["xpack", "logstash"], "requiredPlugins": [ - "licensing" + "licensing", + "management" + ], + "optionalPlugins": [ + "home", + "security" ], - "optionalPlugins": ["security"], "server": true, - "ui": false + "ui": true } diff --git a/x-pack/legacy/plugins/logstash/public/sections/breadcrumbs.js b/x-pack/plugins/logstash/public/application/breadcrumbs.js similarity index 80% rename from x-pack/legacy/plugins/logstash/public/sections/breadcrumbs.js rename to x-pack/plugins/logstash/public/application/breadcrumbs.js index 3121a58ff6a74..322b9860b3785 100644 --- a/x-pack/legacy/plugins/logstash/public/sections/breadcrumbs.js +++ b/x-pack/plugins/logstash/public/application/breadcrumbs.js @@ -5,11 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import { MANAGEMENT_BREADCRUMB } from 'ui/management'; export function getPipelineListBreadcrumbs() { return [ - MANAGEMENT_BREADCRUMB, { text: i18n.translate('xpack.logstash.pipelines.listBreadcrumb', { defaultMessage: 'Pipelines', @@ -19,12 +17,11 @@ export function getPipelineListBreadcrumbs() { ]; } -export function getPipelineEditBreadcrumbs($route) { - const { pipeline } = $route.current.locals; +export function getPipelineEditBreadcrumbs(pipelineId) { return [ ...getPipelineListBreadcrumbs(), { - text: pipeline.id, + text: pipelineId, }, ]; } diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/__snapshots__/confirm_delete_pipeline_modal.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_editor/__snapshots__/confirm_delete_pipeline_modal.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/__snapshots__/confirm_delete_pipeline_modal.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/__snapshots__/confirm_delete_pipeline_modal.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/__snapshots__/flex_item_setting.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_editor/__snapshots__/flex_item_setting.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/__snapshots__/flex_item_setting.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/__snapshots__/flex_item_setting.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/__snapshots__/form_label_with_icon_tip.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_editor/__snapshots__/form_label_with_icon_tip.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/__snapshots__/form_label_with_icon_tip.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/__snapshots__/form_label_with_icon_tip.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/__snapshots__/pipeline_editor.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_editor/__snapshots__/pipeline_editor.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/__snapshots__/pipeline_editor.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/__snapshots__/pipeline_editor.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/confirm_delete_pipeline_modal.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/confirm_delete_pipeline_modal.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/confirm_delete_pipeline_modal.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/confirm_delete_pipeline_modal.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/confirm_delete_pipeline_modal.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/confirm_delete_pipeline_modal.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/confirm_delete_pipeline_modal.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/confirm_delete_pipeline_modal.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/constants.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/constants.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/constants.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/constants.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/flex_item_setting.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/flex_item_setting.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/flex_item_setting.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/flex_item_setting.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/flex_item_setting.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/flex_item_setting.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/flex_item_setting.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/flex_item_setting.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/form_label_with_icon_tip.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/form_label_with_icon_tip.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/form_label_with_icon_tip.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/form_label_with_icon_tip.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/form_label_with_icon_tip.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/form_label_with_icon_tip.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/form_label_with_icon_tip.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/form_label_with_icon_tip.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/index.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/index.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/index.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/index.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/pipeline_editor.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.js similarity index 97% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/pipeline_editor.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.js index 5e430ccbd8ceb..e45820d56cc03 100644 --- a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/pipeline_editor.js +++ b/x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.js @@ -13,7 +13,7 @@ import 'brace/mode/plain_text'; import 'brace/theme/github'; import { isEmpty } from 'lodash'; -import { TOOLTIPS } from '../../../../../../plugins/logstash/common/constants/tooltips'; +import { TOOLTIPS } from '../../../../common/constants/tooltips'; import { EuiButton, EuiButtonEmpty, @@ -40,7 +40,6 @@ class PipelineEditorUi extends React.Component { const { pipeline: { id, description, pipeline, settings }, - username, } = this.props; const pipelineWorkersSet = typeof settings['pipeline.workers'] === 'number'; @@ -60,7 +59,6 @@ class PipelineEditorUi extends React.Component { 'queue.max_bytes': settings['queue.max_bytes.number'] + settings['queue.max_bytes.units'], 'queue.type': settings['queue.type'], }, - username, }, pipelineIdErrors: [], pipelineIdPattern: /^[A-Za-z\_][A-Za-z0-9\-\_]*$/, @@ -236,15 +234,7 @@ class PipelineEditorUi extends React.Component { }; getPipelineHeadingText = () => { - const { - routeService: { - current: { - params: { clone, id }, - }, - }, - isNewPipeline, - intl, - } = this.props; + const { clone, id, isNewPipeline, intl } = this.props; if (!!clone && id) { return intl.formatMessage( @@ -502,6 +492,8 @@ class PipelineEditorUi extends React.Component { } PipelineEditorUi.propTypes = { + id: PropTypes.string, + clone: PropTypes.bool.isRequired, close: PropTypes.func.isRequired, isNewPipeline: PropTypes.bool.isRequired, licenseService: PropTypes.shape({ @@ -527,20 +519,11 @@ PipelineEditorUi.propTypes = { deletePipeline: PropTypes.func.isRequired, savePipeline: PropTypes.func.isRequired, }).isRequired, - routeService: PropTypes.shape({ - current: PropTypes.shape({ - params: PropTypes.shape({ - clone: PropTypes.oneOf([true, undefined]), - id: PropTypes.string, - }), - }), - }).isRequired, toastNotifications: PropTypes.shape({ addWarning: PropTypes.func.isRequired, addSuccess: PropTypes.func.isRequired, addError: PropTypes.func.isRequired, }).isRequired, - username: PropTypes.string, }; export const PipelineEditor = injectI18n(PipelineEditorUi); diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/pipeline_editor.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.test.js similarity index 96% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_editor/pipeline_editor.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.test.js index 2d7ed5f257fbd..bb5961ce36120 100644 --- a/x-pack/legacy/plugins/logstash/public/components/pipeline_editor/pipeline_editor.test.js +++ b/x-pack/plugins/logstash/public/application/components/pipeline_editor/pipeline_editor.test.js @@ -17,7 +17,6 @@ describe('PipelineEditor component', () => { let open; let pipeline; let pipelineService; - let routeService; let toastNotifications; let username; @@ -47,14 +46,6 @@ describe('PipelineEditor component', () => { deletePipeline: jest.fn(), savePipeline: jest.fn(), }; - routeService = { - current: { - params: { - clone: undefined, - id: undefined, - }, - }, - }; toastNotifications = { addWarning: jest.fn(), addSuccess: jest.fn(), @@ -62,13 +53,14 @@ describe('PipelineEditor component', () => { }; username = 'elastic'; props = { + clone: false, + id: 'pipelineId', close, isNewPipeline, licenseService, open, pipeline, pipelineService, - routeService, toastNotifications, username, }; @@ -79,10 +71,8 @@ describe('PipelineEditor component', () => { }); it('matches snapshot for clone pipeline', () => { - routeService.current.params = { - clone: true, - id: 'pipelineToClone', - }; + props.clone = true; + props.id = 'pipelineToClone'; expect(shallowWithIntl()).toMatchSnapshot(); }); diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/add_role_alert.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/add_role_alert.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/add_role_alert.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/add_role_alert.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/alert_call_out.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/alert_call_out.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/alert_call_out.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/alert_call_out.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/confirm_delete_modal.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/confirm_delete_modal.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/confirm_delete_modal.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/confirm_delete_modal.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/enable_monitoring_alert.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/enable_monitoring_alert.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/enable_monitoring_alert.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/enable_monitoring_alert.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/info_alerts.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/info_alerts.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/info_alerts.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/info_alerts.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/pipelines_table.test.js.snap b/x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/pipelines_table.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/__snapshots__/pipelines_table.test.js.snap rename to x-pack/plugins/logstash/public/application/components/pipeline_list/__snapshots__/pipelines_table.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/add_role_alert.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/add_role_alert.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/add_role_alert.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/add_role_alert.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/add_role_alert.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/add_role_alert.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/add_role_alert.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/add_role_alert.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/alert_call_out.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/alert_call_out.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/alert_call_out.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/alert_call_out.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/alert_call_out.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/alert_call_out.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/alert_call_out.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/alert_call_out.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/confirm_delete_modal.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/confirm_delete_modal.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/confirm_delete_modal.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/confirm_delete_modal.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/confirm_delete_modal.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/confirm_delete_modal.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/confirm_delete_modal.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/confirm_delete_modal.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/constants.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/constants.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/constants.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/constants.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/enable_monitoring_alert.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/enable_monitoring_alert.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/enable_monitoring_alert.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/enable_monitoring_alert.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/enable_monitoring_alert.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/enable_monitoring_alert.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/enable_monitoring_alert.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/enable_monitoring_alert.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/index.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/index.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/index.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/index.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/info_alerts.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/info_alerts.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/info_alerts.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/info_alerts.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/info_alerts.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/info_alerts.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/info_alerts.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/info_alerts.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/pipeline_list.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/pipeline_list.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/pipeline_list.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/pipeline_list.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/pipeline_list.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/pipeline_list.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/pipeline_list.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/pipeline_list.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/pipelines_table.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/pipelines_table.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/pipelines_table.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/pipelines_table.js diff --git a/x-pack/legacy/plugins/logstash/public/components/pipeline_list/pipelines_table.test.js b/x-pack/plugins/logstash/public/application/components/pipeline_list/pipelines_table.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/pipeline_list/pipelines_table.test.js rename to x-pack/plugins/logstash/public/application/components/pipeline_list/pipelines_table.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/__snapshots__/upgrade_failure.test.js.snap b/x-pack/plugins/logstash/public/application/components/upgrade_failure/__snapshots__/upgrade_failure.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/__snapshots__/upgrade_failure.test.js.snap rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/__snapshots__/upgrade_failure.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/__snapshots__/upgrade_failure_actions.test.js.snap b/x-pack/plugins/logstash/public/application/components/upgrade_failure/__snapshots__/upgrade_failure_actions.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/__snapshots__/upgrade_failure_actions.test.js.snap rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/__snapshots__/upgrade_failure_actions.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/__snapshots__/upgrade_failure_title.test.js.snap b/x-pack/plugins/logstash/public/application/components/upgrade_failure/__snapshots__/upgrade_failure_title.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/__snapshots__/upgrade_failure_title.test.js.snap rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/__snapshots__/upgrade_failure_title.test.js.snap diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/constants.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/constants.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/constants.js rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/constants.js diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/index.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/index.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/index.js rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/index.js diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure.js rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure.js diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure.test.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure.test.js rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure_actions.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_actions.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure_actions.js rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_actions.js diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure_actions.test.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_actions.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure_actions.test.js rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_actions.test.js diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure_title.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_title.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure_title.js rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_title.js diff --git a/x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure_title.test.js b/x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_title.test.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/components/upgrade_failure/upgrade_failure_title.test.js rename to x-pack/plugins/logstash/public/application/components/upgrade_failure/upgrade_failure_title.test.js diff --git a/x-pack/plugins/logstash/public/application/index.tsx b/x-pack/plugins/logstash/public/application/index.tsx new file mode 100644 index 0000000000000..438038d6c885e --- /dev/null +++ b/x-pack/plugins/logstash/public/application/index.tsx @@ -0,0 +1,117 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import { HashRouter, Route, Switch, Redirect } from 'react-router-dom'; +import { Observable } from 'rxjs'; +import { first } from 'rxjs/operators'; + +import { CoreStart } from 'src/core/public'; +import { ManagementAppMountParams } from '../../../../../src/plugins/management/public'; +import { + ClusterService, + MonitoringService, + PipelineService, + PipelinesService, + UpgradeService, + // @ts-ignore +} from '../services'; +// @ts-ignore +import { PipelineList } from './components/pipeline_list'; +import { PipelineEditView } from './pipeline_edit_view'; +// @ts-ignore +import { Pipeline } from '../models/pipeline'; +// @ts-ignore +import * as Breadcrumbs from './breadcrumbs'; + +export const renderApp = async ( + core: CoreStart, + { basePath, element, setBreadcrumbs }: ManagementAppMountParams, + licenseService$: Observable +) => { + const logstashLicenseService = await licenseService$.pipe(first()).toPromise(); + const clusterService = new ClusterService(core.http); + const monitoringService = new MonitoringService( + core.http, + // When monitoring is migrated this should be fetched from monitoring's plugin contract + core.injectedMetadata.getInjectedVar('monitoringUiEnabled'), + clusterService + ); + const pipelinesService = new PipelinesService(core.http, monitoringService); + const pipelineService = new PipelineService(core.http, pipelinesService); + const upgradeService = new UpgradeService(core.http); + + ReactDOM.render( + + + + { + setBreadcrumbs(Breadcrumbs.getPipelineListBreadcrumbs()); + return ( + history.push(`/pipeline/${id}/edit`)} + clonePipeline={(id: string) => history.push(`/pipeline/${id}/edit?clone`)} + createPipeline={() => history.push(`/pipeline/new-pipeline`)} + pipelinesService={pipelinesService} + toastNotifications={core.notifications.toasts} + /> + ); + }} + /> + ( + + )} + /> + } + /> + ( + + )} + /> + + + , + element + ); + + return () => { + ReactDOM.unmountComponentAtNode(element); + }; +}; diff --git a/x-pack/plugins/logstash/public/application/pipeline_edit_view.tsx b/x-pack/plugins/logstash/public/application/pipeline_edit_view.tsx new file mode 100644 index 0000000000000..c1b465febcd9b --- /dev/null +++ b/x-pack/plugins/logstash/public/application/pipeline_edit_view.tsx @@ -0,0 +1,153 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { useState, useLayoutEffect, useCallback } from 'react'; +import { usePromise } from 'react-use'; +import { History } from 'history'; + +import { i18n } from '@kbn/i18n'; +import { ToastsStart } from 'src/core/public'; + +// @ts-ignore +import { UpgradeFailure } from './components/upgrade_failure'; +// @ts-ignore +import { PipelineEditor } from './components/pipeline_editor'; +// @ts-ignore +import { Pipeline } from '../models/pipeline'; +import { ManagementAppMountParams } from '../../../../../src/plugins/management/public'; +// @ts-ignore +import * as Breadcrumbs from './breadcrumbs'; + +const usePipeline = ( + pipelineService: any, + logstashLicenseService: any, + toasts: ToastsStart, + shouldClone: boolean, + id?: string +) => { + const mounted = usePromise(); + const [pipeline, setPipeline] = useState(null); + + useLayoutEffect(() => { + (async () => { + if (!id) { + return setPipeline(new Pipeline()); + } + + try { + const result = await mounted(pipelineService.loadPipeline(id) as Promise); + setPipeline(shouldClone ? result.clone : result); + } catch (e) { + await logstashLicenseService.checkValidity(); + if (e.status !== 403) { + toasts.addDanger( + i18n.translate('xpack.logstash.couldNotLoadPipelineErrorNotification', { + defaultMessage: `Couldn't load pipeline. Error: '{errStatusText}'.`, + values: { + errStatusText: e.statusText, + }, + }) + ); + } + } + })(); + }, [pipelineService, id, mounted, shouldClone, logstashLicenseService, toasts]); + + return pipeline; +}; + +const useIsUpgraded = (upgradeService: any) => { + const [isUpgraded, setIsUpgraded] = useState(null); + const mounted = usePromise(); + + useLayoutEffect(() => { + mounted(upgradeService.executeUpgrade() as Promise).then(result => + setIsUpgraded(result) + ); + }, [mounted, upgradeService]); + + return isUpgraded; +}; + +interface EditProps { + pipelineService: any; + logstashLicenseService: any; + upgradeService: any; + toasts: ToastsStart; + history: History; + setBreadcrumbs: ManagementAppMountParams['setBreadcrumbs']; + + // URL params + id?: string; +} + +export const PipelineEditView: React.FC = ({ + pipelineService, + logstashLicenseService, + upgradeService, + toasts, + history, + setBreadcrumbs, + id, +}) => { + const params = new URLSearchParams(history.location.search); + const shouldRetry = params.get('retry') === 'true'; + const shouldClone = params.get('clone') === ''; + + const pipeline = usePipeline(pipelineService, logstashLicenseService, toasts, shouldClone, id); + const isUpgraded = useIsUpgraded(upgradeService); + + const onRetry = useCallback(() => { + const newParams = new URLSearchParams(history.location.search); + newParams.set('retry', 'true'); + history.replace({ search: newParams.toString() }); + }, [history]); + const close = useCallback(() => { + history.push('/'); + }, [history]); + const open = useCallback( + (newId: string) => { + history.push(`/pipeline/${newId}/edit`); + }, + [history] + ); + + if (!pipeline || isUpgraded === null) { + return null; + } + + const isNewPipeline = !pipeline.id; + setBreadcrumbs( + isNewPipeline + ? Breadcrumbs.getPipelineCreateBreadcrumbs() + : Breadcrumbs.getPipelineEditBreadcrumbs(pipeline.id) + ); + + if (!isUpgraded) { + return ( + + ); + } + + return ( + + ); +}; diff --git a/x-pack/plugins/logstash/public/index.ts b/x-pack/plugins/logstash/public/index.ts new file mode 100644 index 0000000000000..26a1ca4e8c6c4 --- /dev/null +++ b/x-pack/plugins/logstash/public/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { LogstashPlugin } from './plugin'; + +export const plugin = () => new LogstashPlugin(); diff --git a/x-pack/legacy/plugins/logstash/public/lib/get_search_value/get_search_value.js b/x-pack/plugins/logstash/public/lib/get_search_value/get_search_value.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/lib/get_search_value/get_search_value.js rename to x-pack/plugins/logstash/public/lib/get_search_value/get_search_value.js diff --git a/x-pack/legacy/plugins/logstash/public/lib/get_search_value/index.js b/x-pack/plugins/logstash/public/lib/get_search_value/index.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/lib/get_search_value/index.js rename to x-pack/plugins/logstash/public/lib/get_search_value/index.js diff --git a/x-pack/legacy/plugins/logstash/public/models/cluster/cluster.js b/x-pack/plugins/logstash/public/models/cluster/cluster.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/models/cluster/cluster.js rename to x-pack/plugins/logstash/public/models/cluster/cluster.js diff --git a/x-pack/legacy/plugins/logstash/public/models/cluster/index.js b/x-pack/plugins/logstash/public/models/cluster/index.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/models/cluster/index.js rename to x-pack/plugins/logstash/public/models/cluster/index.js diff --git a/x-pack/legacy/plugins/logstash/public/models/pipeline/index.js b/x-pack/plugins/logstash/public/models/pipeline/index.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/models/pipeline/index.js rename to x-pack/plugins/logstash/public/models/pipeline/index.js diff --git a/x-pack/legacy/plugins/logstash/public/models/pipeline/pipeline.js b/x-pack/plugins/logstash/public/models/pipeline/pipeline.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/models/pipeline/pipeline.js rename to x-pack/plugins/logstash/public/models/pipeline/pipeline.js diff --git a/x-pack/legacy/plugins/logstash/public/models/pipeline_list_item/index.js b/x-pack/plugins/logstash/public/models/pipeline_list_item/index.js similarity index 100% rename from x-pack/legacy/plugins/logstash/public/models/pipeline_list_item/index.js rename to x-pack/plugins/logstash/public/models/pipeline_list_item/index.js diff --git a/x-pack/legacy/plugins/logstash/public/models/pipeline_list_item/pipeline_list_item.js b/x-pack/plugins/logstash/public/models/pipeline_list_item/pipeline_list_item.js similarity index 83% rename from x-pack/legacy/plugins/logstash/public/models/pipeline_list_item/pipeline_list_item.js rename to x-pack/plugins/logstash/public/models/pipeline_list_item/pipeline_list_item.js index 06d01a05bac27..3a304e467e0c0 100755 --- a/x-pack/legacy/plugins/logstash/public/models/pipeline_list_item/pipeline_list_item.js +++ b/x-pack/plugins/logstash/public/models/pipeline_list_item/pipeline_list_item.js @@ -5,10 +5,10 @@ */ import { pick, capitalize } from 'lodash'; +import moment from 'moment'; -import { getSearchValue } from 'plugins/logstash/lib/get_search_value'; -import { getMoment } from 'plugins/logstash/../common/lib/get_moment'; -import { PIPELINE } from '../../../../../../plugins/logstash/common/constants'; +import { getSearchValue } from '../../lib/get_search_value'; +import { PIPELINE } from '../../../common/constants'; /** * Represents the model for listing pipelines in the UI @@ -25,7 +25,7 @@ export class PipelineListItem { this.username = props.username; if (props.lastModified) { - this.lastModified = getMoment(props.lastModified); + this.lastModified = getMomentDate(props.lastModified); this.lastModifiedHumanized = capitalize(this.lastModified.fromNow()); } } @@ -51,3 +51,11 @@ export class PipelineListItem { return new PipelineListItem(props); } } + +function getMomentDate(date) { + if (!date) { + return null; + } + + return moment(date); +} diff --git a/x-pack/plugins/logstash/public/plugin.ts b/x-pack/plugins/logstash/public/plugin.ts new file mode 100644 index 0000000000000..91d1a39d3970c --- /dev/null +++ b/x-pack/plugins/logstash/public/plugin.ts @@ -0,0 +1,92 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; +import { Subscription } from 'rxjs'; +import { map } from 'rxjs/operators'; +import { once } from 'lodash'; + +import { CoreSetup, CoreStart, Plugin } from 'src/core/public'; +import { + HomePublicPluginSetup, + FeatureCatalogueCategory, +} from '../../../../src/plugins/home/public'; +import { LicensingPluginSetup } from '../../licensing/public'; +import { ManagementSetup } from '../../../../src/plugins/management/public'; + +// @ts-ignore +import { LogstashLicenseService } from './services'; + +interface SetupDeps { + licensing: LicensingPluginSetup; + management: ManagementSetup; + + home?: HomePublicPluginSetup; +} + +export class LogstashPlugin implements Plugin { + private licenseSubscription?: Subscription; + + public setup(core: CoreSetup, plugins: SetupDeps) { + const logstashLicense$ = plugins.licensing.license$.pipe( + map(license => new LogstashLicenseService(license)) + ); + const section = plugins.management.sections.register({ + id: 'logstash', + title: 'Logstash', + order: 30, + euiIconType: 'logoLogstash', + }); + const managementApp = section.registerApp({ + id: 'pipelines', + title: i18n.translate('xpack.logstash.managementSection.pipelinesTitle', { + defaultMessage: 'Pipelines', + }), + order: 10, + mount: async params => { + const [coreStart] = await core.getStartServices(); + const { renderApp } = await import('./application'); + + return renderApp(coreStart, params, logstashLicense$); + }, + }); + + this.licenseSubscription = logstashLicense$.subscribe((license: any) => { + if (license.enableLinks) { + managementApp.enable(); + } else { + managementApp.disable(); + } + + if (plugins.home && license.enableLinks) { + // Ensure that we don't register the feature more than once + once(() => { + plugins.home!.featureCatalogue.register({ + id: 'management_logstash', + title: i18n.translate('xpack.logstash.homeFeature.logstashPipelinesTitle', { + defaultMessage: 'Logstash Pipelines', + }), + description: i18n.translate('xpack.logstash.homeFeature.logstashPipelinesDescription', { + defaultMessage: 'Create, delete, update, and clone data ingestion pipelines.', + }), + icon: 'pipelineApp', + path: '/app/kibana#/management/logstash/pipelines', + showOnHomePage: true, + category: FeatureCatalogueCategory.ADMIN, + }); + }); + } + }); + } + + public start(core: CoreStart) {} + + public stop() { + if (this.licenseSubscription) { + this.licenseSubscription.unsubscribe(); + } + } +} diff --git a/x-pack/legacy/plugins/logstash/public/services/cluster/cluster_service.js b/x-pack/plugins/logstash/public/services/cluster/cluster_service.js similarity index 51% rename from x-pack/legacy/plugins/logstash/public/services/cluster/cluster_service.js rename to x-pack/plugins/logstash/public/services/cluster/cluster_service.js index e89c2fe7d11bf..20f3b0d349c80 100755 --- a/x-pack/legacy/plugins/logstash/public/services/cluster/cluster_service.js +++ b/x-pack/plugins/logstash/public/services/cluster/cluster_service.js @@ -4,22 +4,20 @@ * you may not use this file except in compliance with the Elastic License. */ -import chrome from 'ui/chrome'; -import { ROUTES } from '../../../../../../plugins/logstash/common/constants'; -import { Cluster } from 'plugins/logstash/models/cluster'; +import { ROUTES } from '../../../common/constants'; +import { Cluster } from '../../models/cluster'; export class ClusterService { - constructor($http) { - this.$http = $http; - this.basePath = chrome.addBasePath(ROUTES.API_ROOT); + constructor(http) { + this.http = http; } loadCluster() { - return this.$http.get(`${this.basePath}/cluster`).then(response => { - if (!response.data) { + return this.http.get(`${ROUTES.API_ROOT}/cluster`).then(response => { + if (!response) { return; } - return Cluster.fromUpstreamJSON(response.data.cluster); + return Cluster.fromUpstreamJSON(response.cluster); }); } diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/index.js b/x-pack/plugins/logstash/public/services/cluster/index.js similarity index 82% rename from x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/index.js rename to x-pack/plugins/logstash/public/services/cluster/index.js index 4b699ed79cd26..4417262d9f442 100755 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/index.js +++ b/x-pack/plugins/logstash/public/services/cluster/index.js @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -import './pipeline_edit_route'; +export { ClusterService } from './cluster_service'; diff --git a/x-pack/plugins/logstash/public/services/index.js b/x-pack/plugins/logstash/public/services/index.js new file mode 100644 index 0000000000000..a7e8aa5c6259f --- /dev/null +++ b/x-pack/plugins/logstash/public/services/index.js @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { ClusterService } from './cluster'; +export { LogstashLicenseService } from './license'; +export { MonitoringService } from './monitoring'; +export { PipelineService } from './pipeline'; +export { PipelinesService } from './pipelines'; +export { UpgradeService } from './upgrade'; diff --git a/x-pack/legacy/plugins/logstash/public/lib/update_management_sections/index.js b/x-pack/plugins/logstash/public/services/license/index.js similarity index 77% rename from x-pack/legacy/plugins/logstash/public/lib/update_management_sections/index.js rename to x-pack/plugins/logstash/public/services/license/index.js index 9d53d4dd61163..64f39b1144cee 100755 --- a/x-pack/legacy/plugins/logstash/public/lib/update_management_sections/index.js +++ b/x-pack/plugins/logstash/public/services/license/index.js @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { updateLogstashSections } from './update_logstash_sections'; +export { LogstashLicenseService } from './logstash_license_service'; diff --git a/x-pack/plugins/logstash/public/services/license/logstash_license_service.js b/x-pack/plugins/logstash/public/services/license/logstash_license_service.js new file mode 100755 index 0000000000000..b836b75b89cc7 --- /dev/null +++ b/x-pack/plugins/logstash/public/services/license/logstash_license_service.js @@ -0,0 +1,106 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; + +export class LogstashLicenseService { + constructor(license, navigateToApp, toasts) { + this.license = license; + this.navigateToApp = navigateToApp; + this.toasts = toasts; + } + + get enableLinks() { + return this.calculated.enableLinks; + } + + get isAvailable() { + return this.calculated.isAvailable; + } + + get isReadOnly() { + return this.calculated.isReadOnly; + } + + get message() { + return this.calculated.message; + } + + get isSecurityEnabled() { + return this.license.getFeature(`security`).isEnabled; + } + + /** + * Checks if the license is valid or the license can perform downgraded UI tasks. + * Rejects if the plugin is not available due to license. + */ + checkValidity() { + return new Promise((resolve, reject) => { + if (this.isAvailable) { + return resolve(); + } + + return reject(); + }); + } + + get calculated() { + if (!this.license) { + throw new Error(`No license available!`); + } + + if (!this.isSecurityEnabled) { + return { + isAvailable: false, + enableLinks: false, + isReadOnly: false, + message: i18n.translate('xpack.logstash.managementSection.enableSecurityDescription', { + defaultMessage: + 'Security must be enabled in order to use Logstash pipeline management features.' + + ' Please set xpack.security.enabled: true in your elasticsearch.yml.', + }), + }; + } + + if (!this.license.hasAtLeast('standard')) { + return { + isAvailable: false, + enableLinks: false, + isReadOnly: false, + message: i18n.translate( + 'xpack.logstash.managementSection.licenseDoesNotSupportDescription', + { + defaultMessage: + 'Your {licenseType} license does not support Logstash pipeline management features. Please upgrade your license.', + values: { licenseType: this.license.type }, + } + ), + }; + } + + if (!this.license.isActive) { + return { + isAvailable: true, + enableLinks: true, + isReadonly: true, + message: i18n.translate( + 'xpack.logstash.managementSection.pipelineCrudOperationsNotAllowedDescription', + { + defaultMessage: + 'You cannot edit, create, or delete your Logstash pipelines because your {licenseType} license has expired.', + values: { licenseType: this.license.type }, + } + ), + }; + } + + return { + isAvailable: true, + enableLinks: true, + isReadOnly: false, + }; + } +} diff --git a/x-pack/plugins/logstash/public/services/monitoring/index.js b/x-pack/plugins/logstash/public/services/monitoring/index.js new file mode 100755 index 0000000000000..bc0e8b6bc978a --- /dev/null +++ b/x-pack/plugins/logstash/public/services/monitoring/index.js @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { MonitoringService } from './monitoring_service'; diff --git a/x-pack/legacy/plugins/logstash/public/services/monitoring/monitoring_service.js b/x-pack/plugins/logstash/public/services/monitoring/monitoring_service.js similarity index 58% rename from x-pack/legacy/plugins/logstash/public/services/monitoring/monitoring_service.js rename to x-pack/plugins/logstash/public/services/monitoring/monitoring_service.js index 6103e730c2171..d551f4fba61d2 100755 --- a/x-pack/legacy/plugins/logstash/public/services/monitoring/monitoring_service.js +++ b/x-pack/plugins/logstash/public/services/monitoring/monitoring_service.js @@ -5,17 +5,14 @@ */ import moment from 'moment'; -import chrome from 'ui/chrome'; -import { ROUTES, MONITORING } from '../../../../../../plugins/logstash/common/constants'; -import { PipelineListItem } from 'plugins/logstash/models/pipeline_list_item'; +import { ROUTES, MONITORING } from '../../../common/constants'; +import { PipelineListItem } from '../../models/pipeline_list_item'; export class MonitoringService { - constructor($http, Promise, monitoringUiEnabled, clusterService) { - this.$http = $http; - this.Promise = Promise; + constructor(http, monitoringUiEnabled, clusterService) { + this.http = http; this.monitoringUiEnabled = monitoringUiEnabled; this.clusterService = clusterService; - this.basePath = chrome.addBasePath(ROUTES.MONITORING_API_ROOT); } isMonitoringEnabled() { @@ -30,18 +27,18 @@ export class MonitoringService { return this.clusterService .loadCluster() .then(cluster => { - const url = `${this.basePath}/v1/clusters/${cluster.uuid}/logstash/pipeline_ids`; + const url = `${ROUTES.MONITORING_API_ROOT}/v1/clusters/${cluster.uuid}/logstash/pipeline_ids`; const now = moment.utc(); - const body = { + const body = JSON.stringify({ timeRange: { max: now.toISOString(), min: now.subtract(MONITORING.ACTIVE_PIPELINE_RANGE_S, 'seconds').toISOString(), }, - }; - return this.$http.post(url, body); + }); + return this.http.post(url, { body }); }) .then(response => - response.data.map(pipeline => PipelineListItem.fromUpstreamMonitoringJSON(pipeline)) + response.map(pipeline => PipelineListItem.fromUpstreamMonitoringJSON(pipeline)) ) .catch(() => []); } diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/upgrade_failure/index.js b/x-pack/plugins/logstash/public/services/pipeline/index.js similarity index 81% rename from x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/upgrade_failure/index.js rename to x-pack/plugins/logstash/public/services/pipeline/index.js index 3a9a6b860c51f..70d228b34860b 100755 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/upgrade_failure/index.js +++ b/x-pack/plugins/logstash/public/services/pipeline/index.js @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -import './upgrade_failure'; +export { PipelineService } from './pipeline_service'; diff --git a/x-pack/plugins/logstash/public/services/pipeline/pipeline_service.js b/x-pack/plugins/logstash/public/services/pipeline/pipeline_service.js new file mode 100755 index 0000000000000..7c3e18e745d82 --- /dev/null +++ b/x-pack/plugins/logstash/public/services/pipeline/pipeline_service.js @@ -0,0 +1,40 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ROUTES } from '../../../common/constants'; +import { Pipeline } from '../../models/pipeline'; + +export class PipelineService { + constructor(http, pipelinesService) { + this.http = http; + this.pipelinesService = pipelinesService; + } + + loadPipeline(id) { + return this.http.get(`${ROUTES.API_ROOT}/pipeline/${id}`).then(response => { + return Pipeline.fromUpstreamJSON(response); + }); + } + + savePipeline(pipelineModel) { + return this.http + .put(`${ROUTES.API_ROOT}/pipeline/${pipelineModel.id}`, { + body: JSON.stringify(pipelineModel.upstreamJSON), + }) + .catch(e => { + throw e.message; + }); + } + + deletePipeline(id) { + return this.http + .delete(`${ROUTES.API_ROOT}/pipeline/${id}`) + .then(() => this.pipelinesService.addToRecentlyDeleted(id)) + .catch(e => { + throw e.message; + }); + } +} diff --git a/x-pack/plugins/logstash/public/services/pipelines/index.js b/x-pack/plugins/logstash/public/services/pipelines/index.js new file mode 100755 index 0000000000000..a932dd4b951f4 --- /dev/null +++ b/x-pack/plugins/logstash/public/services/pipelines/index.js @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { PipelinesService } from './pipelines_service'; diff --git a/x-pack/plugins/logstash/public/services/pipelines/pipelines_service.js b/x-pack/plugins/logstash/public/services/pipelines/pipelines_service.js new file mode 100755 index 0000000000000..00610a23f2717 --- /dev/null +++ b/x-pack/plugins/logstash/public/services/pipelines/pipelines_service.js @@ -0,0 +1,128 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ROUTES, MONITORING } from '../../../common/constants'; +import { PipelineListItem } from '../../models/pipeline_list_item'; + +const RECENTLY_DELETED_PIPELINE_IDS_STORAGE_KEY = 'xpack.logstash.recentlyDeletedPipelines'; + +export class PipelinesService { + constructor(http, monitoringService) { + this.http = http; + this.monitoringService = monitoringService; + } + + getPipelineList() { + return Promise.all([this.getManagementPipelineList(), this.getMonitoringPipelineList()]).then( + ([managementPipelines, monitoringPipelines]) => { + const now = Date.now(); + + // Monitoring will report centrally-managed pipelines as well, including recently-deleted centrally-managed ones. + // If there's a recently-deleted pipeline we're keeping track of BUT monitoring doesn't report it, that means + // it's not running in Logstash any more. So we can stop tracking it as a recently-deleted pipeline. + const monitoringPipelineIds = monitoringPipelines.map(pipeline => pipeline.id); + this.getRecentlyDeleted().forEach(recentlyDeletedPipeline => { + // We don't want to stop tracking the recently-deleted pipeline until Monitoring has had some + // time to report on it. Otherwise, if we stop tracking first, *then* Monitoring reports it, we'll + // still end up showing it in the list until Monitoring stops reporting it. + if (now - recentlyDeletedPipeline.deletedOn < MONITORING.ACTIVE_PIPELINE_RANGE_S * 1000) { + return; + } + + // If Monitoring is still reporting the pipeline, don't stop tracking it yet + if (monitoringPipelineIds.includes(recentlyDeletedPipeline.id)) { + return; + } + + this.removeFromRecentlyDeleted(recentlyDeletedPipeline.id); + }); + + // Merge centrally-managed pipelines with pipelines reported by monitoring. Take care to dedupe + // while merging because monitoring will (rightly) report centrally-managed pipelines as well, + // including recently-deleted ones! + const managementPipelineIds = managementPipelines.map(pipeline => pipeline.id); + return managementPipelines.concat( + monitoringPipelines.filter( + monitoringPipeline => + !managementPipelineIds.includes(monitoringPipeline.id) && + !this.isRecentlyDeleted(monitoringPipeline.id) + ) + ); + } + ); + } + + getManagementPipelineList() { + return this.http.get(`${ROUTES.API_ROOT}/pipelines`).then(response => { + return response.pipelines.map(pipeline => PipelineListItem.fromUpstreamJSON(pipeline)); + }); + } + + getMonitoringPipelineList() { + return this.monitoringService.getPipelineList(); + } + + /** + * Delete a collection of pipelines + * + * @param pipelineIds Array of pipeline IDs + * @return Promise { numSuccesses, numErrors } + */ + deletePipelines(pipelineIds) { + const body = JSON.stringify({ + pipelineIds, + }); + return this.http.post(`${ROUTES.API_ROOT}/pipelines/delete`, { body }).then(response => { + this.addToRecentlyDeleted(...pipelineIds); + return response.results; + }); + } + + addToRecentlyDeleted(...pipelineIds) { + const recentlyDeletedPipelines = this.getRecentlyDeleted(); + const recentlyDeletedPipelineIds = recentlyDeletedPipelines.map(pipeline => pipeline.id); + pipelineIds.forEach(pipelineId => { + if (!recentlyDeletedPipelineIds.includes(pipelineId)) { + recentlyDeletedPipelines.push({ + id: pipelineId, + deletedOn: Date.now(), + }); + } + }); + this.setRecentlyDeleted(recentlyDeletedPipelines); + } + + removeFromRecentlyDeleted(...pipelineIds) { + const recentlyDeletedPipelinesToKeep = this.getRecentlyDeleted().filter( + recentlyDeletedPipeline => !pipelineIds.includes(recentlyDeletedPipeline.id) + ); + this.setRecentlyDeleted(recentlyDeletedPipelinesToKeep); + } + + isRecentlyDeleted(pipelineId) { + return this.getRecentlyDeleted() + .map(pipeline => pipeline.id) + .includes(pipelineId); + } + + getRecentlyDeleted() { + const recentlyDeletedPipelines = window.localStorage.getItem( + RECENTLY_DELETED_PIPELINE_IDS_STORAGE_KEY + ); + if (!recentlyDeletedPipelines) { + return []; + } + + return JSON.parse(recentlyDeletedPipelines); + } + + setRecentlyDeleted(recentlyDeletedPipelineIds) { + window.localStorage.setItem( + RECENTLY_DELETED_PIPELINE_IDS_STORAGE_KEY, + JSON.stringify(recentlyDeletedPipelineIds) + ); + } +} diff --git a/x-pack/legacy/plugins/logstash/common/lib/index.js b/x-pack/plugins/logstash/public/services/upgrade/index.js similarity index 82% rename from x-pack/legacy/plugins/logstash/common/lib/index.js rename to x-pack/plugins/logstash/public/services/upgrade/index.js index 6ed1d24a37791..1c835b11ae423 100755 --- a/x-pack/legacy/plugins/logstash/common/lib/index.js +++ b/x-pack/plugins/logstash/public/services/upgrade/index.js @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { getMoment } from './get_moment'; +export { UpgradeService } from './upgrade_service'; diff --git a/x-pack/plugins/logstash/public/services/upgrade/upgrade_service.js b/x-pack/plugins/logstash/public/services/upgrade/upgrade_service.js new file mode 100755 index 0000000000000..7bd101ebee6b0 --- /dev/null +++ b/x-pack/plugins/logstash/public/services/upgrade/upgrade_service.js @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ROUTES } from '../../../common/constants'; + +export class UpgradeService { + constructor(http) { + this.http = http; + } + + executeUpgrade() { + return this.http + .post(`${ROUTES.API_ROOT}/upgrade`) + .then(response => response.is_upgraded) + .catch(e => { + throw e.message; + }); + } +} diff --git a/x-pack/plugins/logstash/server/routes/pipeline/save.ts b/x-pack/plugins/logstash/server/routes/pipeline/save.ts index 556c281944a85..e484d0e221b6d 100644 --- a/x-pack/plugins/logstash/server/routes/pipeline/save.ts +++ b/x-pack/plugins/logstash/server/routes/pipeline/save.ts @@ -25,7 +25,6 @@ export function registerPipelineSaveRoute(router: IRouter, security?: SecurityPl id: schema.string(), description: schema.string(), pipeline: schema.string(), - username: schema.string(), settings: schema.maybe(schema.object({}, { unknowns: 'allow' })), }), }, diff --git a/x-pack/plugins/maps/common/constants.ts b/x-pack/plugins/maps/common/constants.ts index 1468bf7fdc1f2..a4006732224ce 100644 --- a/x-pack/plugins/maps/common/constants.ts +++ b/x-pack/plugins/maps/common/constants.ts @@ -1,9 +1,3 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License; @@ -46,9 +40,10 @@ export function createMapPath(id: string) { export enum LAYER_TYPE { TILE = 'TILE', VECTOR = 'VECTOR', - VECTOR_TILE = 'VECTOR_TILE', + VECTOR_TILE = 'VECTOR_TILE', // for static display of mvt vector tiles with a mapbox stylesheet. Does not support any ad-hoc configurations. Used for consuming EMS vector tiles. HEATMAP = 'HEATMAP', BLENDED_VECTOR = 'BLENDED_VECTOR', + TILED_VECTOR = 'TILED_VECTOR', // similar to a regular vector-layer, but it consumes the data as .mvt tilea iso GeoJson. It supports similar ad-hoc configurations like a regular vector layer (E.g. using IVectorStyle), although there is some loss of functionality e.g. does not support term joining } export enum SORT_ORDER { @@ -67,12 +62,14 @@ export enum SOURCE_TYPES { KIBANA_TILEMAP = 'KIBANA_TILEMAP', REGIONMAP_FILE = 'REGIONMAP_FILE', GEOJSON_FILE = 'GEOJSON_FILE', + MVT_SINGLE_LAYER = 'MVT_SINGLE_LAYER', } export enum FIELD_ORIGIN { SOURCE = 'source', JOIN = 'join', } +export const JOIN_FIELD_NAME_PREFIX = '__kbnjoin__'; export const SOURCE_DATA_ID_ORIGIN = 'source'; export const META_ID_ORIGIN_SUFFIX = 'meta'; @@ -130,6 +127,7 @@ export enum DRAW_TYPE { POLYGON = 'POLYGON', } +export const AGG_DELIMITER = '_of_'; export enum AGG_TYPE { AVG = 'avg', COUNT = 'count', diff --git a/x-pack/plugins/maps/common/descriptor_types/data_request_descriptor_types.d.ts b/x-pack/plugins/maps/common/descriptor_types/data_request_descriptor_types.d.ts index 26044d28d53a3..e94dc6694b38d 100644 --- a/x-pack/plugins/maps/common/descriptor_types/data_request_descriptor_types.d.ts +++ b/x-pack/plugins/maps/common/descriptor_types/data_request_descriptor_types.d.ts @@ -31,12 +31,12 @@ type ESGeoGridSourceSyncMeta = { requestType: RENDER_AS; }; -export type VectorSourceSyncMeta = ESSearchSourceSyncMeta | ESGeoGridSourceSyncMeta; +export type VectorSourceSyncMeta = ESSearchSourceSyncMeta | ESGeoGridSourceSyncMeta | null; export type VectorSourceRequestMeta = MapFilters & { applyGlobalQuery: boolean; fieldNames: string[]; - geogridPrecision: number; + geogridPrecision?: number; sourceQuery: MapQuery; sourceMeta: VectorSourceSyncMeta; }; diff --git a/x-pack/plugins/maps/common/descriptor_types/descriptor_types.d.ts b/x-pack/plugins/maps/common/descriptor_types/descriptor_types.d.ts index ff285877750c5..f8175b0ed3f10 100644 --- a/x-pack/plugins/maps/common/descriptor_types/descriptor_types.d.ts +++ b/x-pack/plugins/maps/common/descriptor_types/descriptor_types.d.ts @@ -94,6 +94,18 @@ export type XYZTMSSourceDescriptor = AbstractSourceDescriptor & urlTemplate: string; }; +export type TiledSingleLayerVectorSourceDescriptor = AbstractSourceDescriptor & { + urlTemplate: string; + layerName: string; + + // These are the min/max zoom levels of the availability of the a particular layerName in the tileset at urlTemplate. + // These are _not_ the visible zoom-range of the data on a map. + // Tiled data can be displayed at higher levels of zoom than that they are stored in the tileset. + // e.g. EMS basemap data from level 14 is at most detailed resolution and can be displayed at higher levels + minSourceZoom: number; + maxSourceZoom: number; +}; + export type JoinDescriptor = { leftField: string; right: ESTermSourceDescriptor; @@ -107,7 +119,9 @@ export type SourceDescriptor = | ESTermSourceDescriptor | ESSearchSourceDescriptor | ESGeoGridSourceDescriptor - | EMSFileSourceDescriptor; + | EMSFileSourceDescriptor + | ESPewPewSourceDescriptor + | TiledSingleLayerVectorSourceDescriptor; export type LayerDescriptor = { __dataRequests?: DataRequestDescriptor[]; diff --git a/x-pack/plugins/maps/common/get_join_key.ts b/x-pack/plugins/maps/common/get_join_key.ts new file mode 100644 index 0000000000000..f1ee95126b9a9 --- /dev/null +++ b/x-pack/plugins/maps/common/get_join_key.ts @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { AGG_DELIMITER, AGG_TYPE, JOIN_FIELD_NAME_PREFIX } from './constants'; + +// function in common since its needed by migration +export function getJoinAggKey({ + aggType, + aggFieldName, + rightSourceId, +}: { + aggType: AGG_TYPE; + aggFieldName?: string; + rightSourceId: string; +}) { + const metricKey = + aggType !== AGG_TYPE.COUNT ? `${aggType}${AGG_DELIMITER}${aggFieldName}` : aggType; + return `${JOIN_FIELD_NAME_PREFIX}${metricKey}__${rightSourceId}`; +} diff --git a/x-pack/legacy/plugins/maps/common/migrations/add_field_meta_options.js b/x-pack/plugins/maps/common/migrations/add_field_meta_options.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/add_field_meta_options.js rename to x-pack/plugins/maps/common/migrations/add_field_meta_options.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/add_field_meta_options.test.js b/x-pack/plugins/maps/common/migrations/add_field_meta_options.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/add_field_meta_options.test.js rename to x-pack/plugins/maps/common/migrations/add_field_meta_options.test.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.js b/x-pack/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.js rename to x-pack/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.test.js b/x-pack/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.test.js rename to x-pack/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.test.js diff --git a/x-pack/plugins/maps/common/migrations/join_agg_key.test.ts b/x-pack/plugins/maps/common/migrations/join_agg_key.test.ts new file mode 100644 index 0000000000000..d92bf06541433 --- /dev/null +++ b/x-pack/plugins/maps/common/migrations/join_agg_key.test.ts @@ -0,0 +1,140 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { LAYER_TYPE } from '../constants'; +import { migrateJoinAggKey } from './join_agg_key'; + +describe('migrateJoinAggKey', () => { + const joins = [ + { + leftField: 'machine.os', + right: { + id: '9055b4aa-136a-4b6d-90ab-9f94ccfe5eb5', + indexPatternTitle: 'kibana_sample_data_logs', + term: 'machine.os.keyword', + metrics: [ + { + type: 'avg', + field: 'bytes', + }, + { + type: 'count', + }, + ], + whereQuery: { + query: 'bytes > 10000', + language: 'kuery', + }, + indexPatternRefName: 'layer_1_join_0_index_pattern', + }, + }, + { + leftField: 'machine.os', + right: { + id: '9a7f4e71-9500-4512-82f1-b7eaee3d87ff', + indexPatternTitle: 'kibana_sample_data_logs', + term: 'machine.os.keyword', + whereQuery: { + query: 'bytes < 10000', + language: 'kuery', + }, + metrics: [ + { + type: 'avg', + field: 'bytes', + }, + ], + indexPatternRefName: 'layer_1_join_1_index_pattern', + }, + }, + ]; + + test('Should handle missing layerListJSON attribute', () => { + const attributes = { + title: 'my map', + }; + expect(migrateJoinAggKey({ attributes })).toEqual({ + title: 'my map', + }); + }); + + test('Should migrate vector styles from legacy join agg key to new join agg key', () => { + const layerListJSON = JSON.stringify([ + { + type: LAYER_TYPE.VECTOR, + joins, + style: { + properties: { + fillColor: { + type: 'DYNAMIC', + options: { + color: 'Blues', + colorCategory: 'palette_0', + field: { + name: + '__kbnjoin__avg_of_bytes_groupby_kibana_sample_data_logs.machine.os.keyword', + origin: 'join', + }, + fieldMetaOptions: { + isEnabled: true, + sigma: 3, + }, + type: 'ORDINAL', + }, + }, + lineColor: { + type: 'DYNAMIC', + options: { + color: 'Blues', + colorCategory: 'palette_0', + field: { + name: '__kbnjoin__count_groupby_kibana_sample_data_logs.machine.os.keyword', + origin: 'join', + }, + fieldMetaOptions: { + isEnabled: true, + sigma: 3, + }, + type: 'ORDINAL', + }, + }, + lineWidth: { + type: 'DYNAMIC', + options: { + color: 'Blues', + colorCategory: 'palette_0', + field: { + name: 'mySourceField', + origin: 'source', + }, + fieldMetaOptions: { + isEnabled: true, + sigma: 3, + }, + type: 'ORDINAL', + }, + }, + }, + }, + }, + ]); + const attributes = { + title: 'my map', + layerListJSON, + }; + const { layerListJSON: migratedLayerListJSON } = migrateJoinAggKey({ attributes }); + const migratedLayerList = JSON.parse(migratedLayerListJSON!); + expect(migratedLayerList[0].style.properties.fillColor.options.field.name).toBe( + '__kbnjoin__avg_of_bytes__9055b4aa-136a-4b6d-90ab-9f94ccfe5eb5' + ); + expect(migratedLayerList[0].style.properties.lineColor.options.field.name).toBe( + '__kbnjoin__count__9055b4aa-136a-4b6d-90ab-9f94ccfe5eb5' + ); + expect(migratedLayerList[0].style.properties.lineWidth.options.field.name).toBe( + 'mySourceField' + ); + }); +}); diff --git a/x-pack/plugins/maps/common/migrations/join_agg_key.ts b/x-pack/plugins/maps/common/migrations/join_agg_key.ts new file mode 100644 index 0000000000000..97b9ee4692c25 --- /dev/null +++ b/x-pack/plugins/maps/common/migrations/join_agg_key.ts @@ -0,0 +1,121 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import _ from 'lodash'; +import { + AGG_DELIMITER, + AGG_TYPE, + FIELD_ORIGIN, + JOIN_FIELD_NAME_PREFIX, + LAYER_TYPE, + VECTOR_STYLES, +} from '../constants'; +import { getJoinAggKey } from '../get_join_key'; +import { + AggDescriptor, + JoinDescriptor, + LayerDescriptor, + VectorLayerDescriptor, +} from '../descriptor_types'; +import { MapSavedObjectAttributes } from '../map_saved_object_type'; + +const GROUP_BY_DELIMITER = '_groupby_'; + +function getLegacyAggKey({ + aggType, + aggFieldName, + indexPatternTitle, + termFieldName, +}: { + aggType: AGG_TYPE; + aggFieldName?: string; + indexPatternTitle: string; + termFieldName: string; +}): string { + const metricKey = + aggType !== AGG_TYPE.COUNT ? `${aggType}${AGG_DELIMITER}${aggFieldName}` : aggType; + return `${JOIN_FIELD_NAME_PREFIX}${metricKey}${GROUP_BY_DELIMITER}${indexPatternTitle}.${termFieldName}`; +} + +function parseLegacyAggKey(legacyAggKey: string): { aggType: AGG_TYPE; aggFieldName?: string } { + const groupBySplit = legacyAggKey + .substring(JOIN_FIELD_NAME_PREFIX.length) + .split(GROUP_BY_DELIMITER); + const metricKey = groupBySplit[0]; + const metricKeySplit = metricKey.split(AGG_DELIMITER); + return { + aggType: metricKeySplit[0] as AGG_TYPE, + aggFieldName: metricKeySplit.length === 2 ? metricKeySplit[1] : undefined, + }; +} + +export function migrateJoinAggKey({ + attributes, +}: { + attributes: MapSavedObjectAttributes; +}): MapSavedObjectAttributes { + if (!attributes || !attributes.layerListJSON) { + return attributes; + } + + const layerList: LayerDescriptor[] = JSON.parse(attributes.layerListJSON); + layerList.forEach((layerDescriptor: LayerDescriptor) => { + if ( + layerDescriptor.type === LAYER_TYPE.VECTOR || + layerDescriptor.type === LAYER_TYPE.BLENDED_VECTOR + ) { + const vectorLayerDescriptor = layerDescriptor as VectorLayerDescriptor; + + if ( + !vectorLayerDescriptor.style || + !vectorLayerDescriptor.joins || + vectorLayerDescriptor.joins.length === 0 + ) { + return; + } + + const legacyJoinFields = new Map(); + vectorLayerDescriptor.joins.forEach((joinDescriptor: JoinDescriptor) => { + _.get(joinDescriptor, 'right.metrics', []).forEach((aggDescriptor: AggDescriptor) => { + const legacyAggKey = getLegacyAggKey({ + aggType: aggDescriptor.type, + aggFieldName: aggDescriptor.field, + indexPatternTitle: _.get(joinDescriptor, 'right.indexPatternTitle', ''), + termFieldName: _.get(joinDescriptor, 'right.term', ''), + }); + // The legacy getAggKey implemenation has a naming collision bug where + // aggType, aggFieldName, indexPatternTitle, and termFieldName would result in the identical aggKey. + // The VectorStyle implemenation used the first matching join descriptor + // so, in the event of a name collision, the first join descriptor will be used here as well. + if (!legacyJoinFields.has(legacyAggKey)) { + legacyJoinFields.set(legacyAggKey, joinDescriptor); + } + }); + }); + + Object.keys(vectorLayerDescriptor.style.properties).forEach(key => { + const style: any = vectorLayerDescriptor.style!.properties[key as VECTOR_STYLES]; + if (_.get(style, 'options.field.origin') === FIELD_ORIGIN.JOIN) { + const joinDescriptor = legacyJoinFields.get(style.options.field.name); + if (joinDescriptor) { + const { aggType, aggFieldName } = parseLegacyAggKey(style.options.field.name); + // Update legacy join agg key to new join agg key + style.options.field.name = getJoinAggKey({ + aggType, + aggFieldName, + rightSourceId: joinDescriptor.right.id!, + }); + } + } + }); + } + }); + + return { + ...attributes, + layerListJSON: JSON.stringify(layerList), + }; +} diff --git a/x-pack/legacy/plugins/maps/common/migrations/migrate_symbol_style_descriptor.js b/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/migrate_symbol_style_descriptor.js rename to x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/migrate_symbol_style_descriptor.test.js b/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/migrate_symbol_style_descriptor.test.js rename to x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.test.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/move_apply_global_query.js b/x-pack/plugins/maps/common/migrations/move_apply_global_query.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/move_apply_global_query.js rename to x-pack/plugins/maps/common/migrations/move_apply_global_query.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/move_apply_global_query.test.js b/x-pack/plugins/maps/common/migrations/move_apply_global_query.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/move_apply_global_query.test.js rename to x-pack/plugins/maps/common/migrations/move_apply_global_query.test.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/references.js b/x-pack/plugins/maps/common/migrations/references.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/references.js rename to x-pack/plugins/maps/common/migrations/references.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/references.test.js b/x-pack/plugins/maps/common/migrations/references.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/references.test.js rename to x-pack/plugins/maps/common/migrations/references.test.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/scaling_type.test.ts b/x-pack/plugins/maps/common/migrations/scaling_type.test.ts similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/scaling_type.test.ts rename to x-pack/plugins/maps/common/migrations/scaling_type.test.ts diff --git a/x-pack/legacy/plugins/maps/common/migrations/scaling_type.ts b/x-pack/plugins/maps/common/migrations/scaling_type.ts similarity index 93% rename from x-pack/legacy/plugins/maps/common/migrations/scaling_type.ts rename to x-pack/plugins/maps/common/migrations/scaling_type.ts index 551975fbacea5..98a06a764f4ec 100644 --- a/x-pack/legacy/plugins/maps/common/migrations/scaling_type.ts +++ b/x-pack/plugins/maps/common/migrations/scaling_type.ts @@ -7,7 +7,7 @@ import _ from 'lodash'; import { SOURCE_TYPES, SCALING_TYPES } from '../constants'; import { LayerDescriptor, ESSearchSourceDescriptor } from '../descriptor_types'; -import { MapSavedObjectAttributes } from '../../../../../plugins/maps/common/map_saved_object_type'; +import { MapSavedObjectAttributes } from '../map_saved_object_type'; function isEsDocumentSource(layerDescriptor: LayerDescriptor) { const sourceType = _.get(layerDescriptor, 'sourceDescriptor.type'); diff --git a/x-pack/legacy/plugins/maps/common/migrations/top_hits_time_to_sort.js b/x-pack/plugins/maps/common/migrations/top_hits_time_to_sort.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/top_hits_time_to_sort.js rename to x-pack/plugins/maps/common/migrations/top_hits_time_to_sort.js diff --git a/x-pack/legacy/plugins/maps/common/migrations/top_hits_time_to_sort.test.js b/x-pack/plugins/maps/common/migrations/top_hits_time_to_sort.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/common/migrations/top_hits_time_to_sort.test.js rename to x-pack/plugins/maps/common/migrations/top_hits_time_to_sort.test.js diff --git a/x-pack/plugins/maps/kibana.json b/x-pack/plugins/maps/kibana.json index b2aec30c113eb..00c5e70ad6b8d 100644 --- a/x-pack/plugins/maps/kibana.json +++ b/x-pack/plugins/maps/kibana.json @@ -3,6 +3,14 @@ "version": "8.0.0", "kibanaVersion": "kibana", "configPath": ["xpack", "maps"], - "requiredPlugins": ["inspector"], + "requiredPlugins": [ + "inspector", + "home", + "data", + "fileUpload", + "uiActions", + "navigation", + "visualizations" + ], "ui": true } diff --git a/x-pack/legacy/plugins/maps/public/_main.scss b/x-pack/plugins/maps/public/_main.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/_main.scss rename to x-pack/plugins/maps/public/_main.scss diff --git a/x-pack/legacy/plugins/maps/public/_mapbox_hacks.scss b/x-pack/plugins/maps/public/_mapbox_hacks.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/_mapbox_hacks.scss rename to x-pack/plugins/maps/public/_mapbox_hacks.scss diff --git a/x-pack/plugins/maps/public/actions/map_actions.js b/x-pack/plugins/maps/public/actions/map_actions.js index 13cb3d5f89860..572385d628b16 100644 --- a/x-pack/plugins/maps/public/actions/map_actions.js +++ b/x-pack/plugins/maps/public/actions/map_actions.js @@ -4,6 +4,37 @@ * you may not use this file except in compliance with the Elastic License. */ +import _ from 'lodash'; +import turf from 'turf'; +import turfBooleanContains from '@turf/boolean-contains'; +import uuid from 'uuid/v4'; +import { + getLayerList, + getLayerListRaw, + getDataFilters, + getSelectedLayerId, + getMapReady, + getWaitingForMapReadyLayerListRaw, + getTransientLayerId, + getOpenTooltips, + getQuery, + getDataRequestDescriptor, +} from '../selectors/map_selectors'; + +import { FLYOUT_STATE } from '../reducers/ui'; +import { + cancelRequest, + registerCancelCallback, + unregisterCancelCallback, + getEventHandlers, +} from '../reducers/non_serializable_instances'; +import { updateFlyout } from './ui_actions'; +import { + FEATURE_ID_PROPERTY_NAME, + LAYER_TYPE, + SOURCE_DATA_ID_ORIGIN, +} from '../../common/constants'; + export const SET_SELECTED_LAYER = 'SET_SELECTED_LAYER'; export const SET_TRANSIENT_LAYER = 'SET_TRANSIENT_LAYER'; export const UPDATE_LAYER_ORDER = 'UPDATE_LAYER_ORDER'; @@ -45,3 +76,897 @@ export const HIDE_TOOLBAR_OVERLAY = 'HIDE_TOOLBAR_OVERLAY'; export const HIDE_LAYER_CONTROL = 'HIDE_LAYER_CONTROL'; export const HIDE_VIEW_CONTROL = 'HIDE_VIEW_CONTROL'; export const SET_WAITING_FOR_READY_HIDDEN_LAYERS = 'SET_WAITING_FOR_READY_HIDDEN_LAYERS'; + +function getLayerLoadingCallbacks(dispatch, getState, layerId) { + return { + startLoading: (dataId, requestToken, meta) => + dispatch(startDataLoad(layerId, dataId, requestToken, meta)), + stopLoading: (dataId, requestToken, data, meta) => + dispatch(endDataLoad(layerId, dataId, requestToken, data, meta)), + onLoadError: (dataId, requestToken, errorMessage) => + dispatch(onDataLoadError(layerId, dataId, requestToken, errorMessage)), + updateSourceData: newData => { + dispatch(updateSourceDataRequest(layerId, newData)); + }, + isRequestStillActive: (dataId, requestToken) => { + const dataRequest = getDataRequestDescriptor(getState(), layerId, dataId); + if (!dataRequest) { + return false; + } + return dataRequest.dataRequestToken === requestToken; + }, + registerCancelCallback: (requestToken, callback) => + dispatch(registerCancelCallback(requestToken, callback)), + }; +} + +function getLayerById(layerId, state) { + return getLayerList(state).find(layer => { + return layerId === layer.getId(); + }); +} + +async function syncDataForAllLayers(dispatch, getState, dataFilters) { + const state = getState(); + const layerList = getLayerList(state); + const syncs = layerList.map(layer => { + const loadingFunctions = getLayerLoadingCallbacks(dispatch, getState, layer.getId()); + return layer.syncData({ ...loadingFunctions, dataFilters }); + }); + await Promise.all(syncs); +} + +export function cancelAllInFlightRequests() { + return (dispatch, getState) => { + getLayerList(getState()).forEach(layer => { + dispatch(clearDataRequests(layer)); + }); + }; +} + +function clearDataRequests(layer) { + return dispatch => { + layer.getInFlightRequestTokens().forEach(requestToken => { + dispatch(cancelRequest(requestToken)); + }); + dispatch({ + type: UPDATE_LAYER_PROP, + id: layer.getId(), + propName: '__dataRequests', + newValue: [], + }); + }; +} + +export function setMapInitError(errorMessage) { + return { + type: SET_MAP_INIT_ERROR, + errorMessage, + }; +} + +export function trackCurrentLayerState(layerId) { + return { + type: TRACK_CURRENT_LAYER_STATE, + layerId: layerId, + }; +} + +export function rollbackToTrackedLayerStateForSelectedLayer() { + return async (dispatch, getState) => { + const layerId = getSelectedLayerId(getState()); + await dispatch({ + type: ROLLBACK_TO_TRACKED_LAYER_STATE, + layerId: layerId, + }); + + // Ensure updateStyleMeta is triggered + // syncDataForLayer may not trigger endDataLoad if no re-fetch is required + dispatch(updateStyleMeta(layerId)); + + dispatch(syncDataForLayer(layerId)); + }; +} + +export function removeTrackedLayerStateForSelectedLayer() { + return (dispatch, getState) => { + const layerId = getSelectedLayerId(getState()); + dispatch({ + type: REMOVE_TRACKED_LAYER_STATE, + layerId: layerId, + }); + }; +} + +export function replaceLayerList(newLayerList) { + return (dispatch, getState) => { + const isMapReady = getMapReady(getState()); + if (!isMapReady) { + dispatch({ + type: CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST, + }); + } else { + getLayerListRaw(getState()).forEach(({ id }) => { + dispatch(removeLayerFromLayerList(id)); + }); + } + + newLayerList.forEach(layerDescriptor => { + dispatch(addLayer(layerDescriptor)); + }); + }; +} + +export function cloneLayer(layerId) { + return async (dispatch, getState) => { + const layer = getLayerById(layerId, getState()); + if (!layer) { + return; + } + + const clonedDescriptor = await layer.cloneDescriptor(); + dispatch(addLayer(clonedDescriptor)); + }; +} + +export function addLayer(layerDescriptor) { + return (dispatch, getState) => { + const isMapReady = getMapReady(getState()); + if (!isMapReady) { + dispatch({ + type: ADD_WAITING_FOR_MAP_READY_LAYER, + layer: layerDescriptor, + }); + return; + } + + dispatch({ + type: ADD_LAYER, + layer: layerDescriptor, + }); + dispatch(syncDataForLayer(layerDescriptor.id)); + }; +} + +// Do not use when rendering a map. Method exists to enable selectors for getLayerList when +// rendering is not needed. +export function addLayerWithoutDataSync(layerDescriptor) { + return { + type: ADD_LAYER, + layer: layerDescriptor, + }; +} + +function setLayerDataLoadErrorStatus(layerId, errorMessage) { + return dispatch => { + dispatch({ + type: SET_LAYER_ERROR_STATUS, + isInErrorState: errorMessage !== null, + layerId, + errorMessage, + }); + }; +} + +export function cleanTooltipStateForLayer(layerId, layerFeatures = []) { + return (dispatch, getState) => { + let featuresRemoved = false; + const openTooltips = getOpenTooltips(getState()) + .map(tooltipState => { + const nextFeatures = tooltipState.features.filter(tooltipFeature => { + if (tooltipFeature.layerId !== layerId) { + // feature from another layer, keep it + return true; + } + + // Keep feature if it is still in layer + return layerFeatures.some(layerFeature => { + return layerFeature.properties[FEATURE_ID_PROPERTY_NAME] === tooltipFeature.id; + }); + }); + + if (tooltipState.features.length !== nextFeatures.length) { + featuresRemoved = true; + } + + return { ...tooltipState, features: nextFeatures }; + }) + .filter(tooltipState => { + return tooltipState.features.length > 0; + }); + + if (featuresRemoved) { + dispatch({ + type: SET_OPEN_TOOLTIPS, + openTooltips, + }); + } + }; +} + +export function setLayerVisibility(layerId, makeVisible) { + return async (dispatch, getState) => { + //if the current-state is invisible, we also want to sync data + //e.g. if a layer was invisible at start-up, it won't have any data loaded + const layer = getLayerById(layerId, getState()); + + // If the layer visibility is already what we want it to be, do nothing + if (!layer || layer.isVisible() === makeVisible) { + return; + } + + if (!makeVisible) { + dispatch(cleanTooltipStateForLayer(layerId)); + } + + await dispatch({ + type: SET_LAYER_VISIBILITY, + layerId, + visibility: makeVisible, + }); + if (makeVisible) { + dispatch(syncDataForLayer(layerId)); + } + }; +} + +export function toggleLayerVisible(layerId) { + return async (dispatch, getState) => { + const layer = getLayerById(layerId, getState()); + if (!layer) { + return; + } + const makeVisible = !layer.isVisible(); + + dispatch(setLayerVisibility(layerId, makeVisible)); + }; +} + +export function setSelectedLayer(layerId) { + return async (dispatch, getState) => { + const oldSelectedLayer = getSelectedLayerId(getState()); + if (oldSelectedLayer) { + await dispatch(rollbackToTrackedLayerStateForSelectedLayer()); + } + if (layerId) { + dispatch(trackCurrentLayerState(layerId)); + } + dispatch({ + type: SET_SELECTED_LAYER, + selectedLayerId: layerId, + }); + }; +} + +export function removeTransientLayer() { + return async (dispatch, getState) => { + const transientLayerId = getTransientLayerId(getState()); + if (transientLayerId) { + await dispatch(removeLayerFromLayerList(transientLayerId)); + await dispatch(setTransientLayer(null)); + } + }; +} + +export function setTransientLayer(layerId) { + return { + type: SET_TRANSIENT_LAYER, + transientLayerId: layerId, + }; +} + +export function clearTransientLayerStateAndCloseFlyout() { + return async dispatch => { + await dispatch(updateFlyout(FLYOUT_STATE.NONE)); + await dispatch(setSelectedLayer(null)); + await dispatch(removeTransientLayer()); + }; +} + +export function updateLayerOrder(newLayerOrder) { + return { + type: UPDATE_LAYER_ORDER, + newLayerOrder, + }; +} + +export function mapReady() { + return (dispatch, getState) => { + dispatch({ + type: MAP_READY, + }); + + getWaitingForMapReadyLayerListRaw(getState()).forEach(layerDescriptor => { + dispatch(addLayer(layerDescriptor)); + }); + + dispatch({ + type: CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST, + }); + }; +} + +export function mapDestroyed() { + return { + type: MAP_DESTROYED, + }; +} + +export function mapExtentChanged(newMapConstants) { + return async (dispatch, getState) => { + const state = getState(); + const dataFilters = getDataFilters(state); + const { extent, zoom: newZoom } = newMapConstants; + const { buffer, zoom: currentZoom } = dataFilters; + + if (extent) { + let doesBufferContainExtent = false; + if (buffer) { + const bufferGeometry = turf.bboxPolygon([ + buffer.minLon, + buffer.minLat, + buffer.maxLon, + buffer.maxLat, + ]); + const extentGeometry = turf.bboxPolygon([ + extent.minLon, + extent.minLat, + extent.maxLon, + extent.maxLat, + ]); + + doesBufferContainExtent = turfBooleanContains(bufferGeometry, extentGeometry); + } + + if (!doesBufferContainExtent || currentZoom !== newZoom) { + const scaleFactor = 0.5; // TODO put scale factor in store and fetch with selector + const width = extent.maxLon - extent.minLon; + const height = extent.maxLat - extent.minLat; + dataFilters.buffer = { + minLon: extent.minLon - width * scaleFactor, + minLat: extent.minLat - height * scaleFactor, + maxLon: extent.maxLon + width * scaleFactor, + maxLat: extent.maxLat + height * scaleFactor, + }; + } + } + + dispatch({ + type: MAP_EXTENT_CHANGED, + mapState: { + ...dataFilters, + ...newMapConstants, + }, + }); + const newDataFilters = { ...dataFilters, ...newMapConstants }; + await syncDataForAllLayers(dispatch, getState, newDataFilters); + }; +} + +export function closeOnClickTooltip(tooltipId) { + return (dispatch, getState) => { + dispatch({ + type: SET_OPEN_TOOLTIPS, + openTooltips: getOpenTooltips(getState()).filter(({ id }) => { + return tooltipId !== id; + }), + }); + }; +} + +export function openOnClickTooltip(tooltipState) { + return (dispatch, getState) => { + const openTooltips = getOpenTooltips(getState()).filter(({ features, location, isLocked }) => { + return ( + isLocked && + !_.isEqual(location, tooltipState.location) && + !_.isEqual(features, tooltipState.features) + ); + }); + + openTooltips.push({ + ...tooltipState, + isLocked: true, + id: uuid(), + }); + + dispatch({ + type: SET_OPEN_TOOLTIPS, + openTooltips, + }); + }; +} + +export function closeOnHoverTooltip() { + return (dispatch, getState) => { + if (getOpenTooltips(getState()).length) { + dispatch({ + type: SET_OPEN_TOOLTIPS, + openTooltips: [], + }); + } + }; +} + +export function openOnHoverTooltip(tooltipState) { + return { + type: SET_OPEN_TOOLTIPS, + openTooltips: [ + { + ...tooltipState, + isLocked: false, + id: uuid(), + }, + ], + }; +} + +export function setMouseCoordinates({ lat, lon }) { + let safeLon = lon; + if (lon > 180) { + const overlapWestOfDateLine = lon - 180; + safeLon = -180 + overlapWestOfDateLine; + } else if (lon < -180) { + const overlapEastOfDateLine = Math.abs(lon) - 180; + safeLon = 180 - overlapEastOfDateLine; + } + + return { + type: SET_MOUSE_COORDINATES, + lat, + lon: safeLon, + }; +} + +export function clearMouseCoordinates() { + return { type: CLEAR_MOUSE_COORDINATES }; +} + +export function disableScrollZoom() { + return { type: SET_SCROLL_ZOOM, scrollZoom: false }; +} + +export function fitToLayerExtent(layerId) { + return async function(dispatch, getState) { + const targetLayer = getLayerById(layerId, getState()); + + if (targetLayer) { + const dataFilters = getDataFilters(getState()); + const bounds = await targetLayer.getBounds(dataFilters); + if (bounds) { + await dispatch(setGotoWithBounds(bounds)); + } + } + }; +} + +export function setGotoWithBounds(bounds) { + return { + type: SET_GOTO, + bounds: bounds, + }; +} + +export function setGotoWithCenter({ lat, lon, zoom }) { + return { + type: SET_GOTO, + center: { lat, lon, zoom }, + }; +} + +export function clearGoto() { + return { type: CLEAR_GOTO }; +} + +export function startDataLoad(layerId, dataId, requestToken, meta = {}) { + return (dispatch, getState) => { + const layer = getLayerById(layerId, getState()); + if (layer) { + dispatch(cancelRequest(layer.getPrevRequestToken(dataId))); + } + + const eventHandlers = getEventHandlers(getState()); + if (eventHandlers && eventHandlers.onDataLoad) { + eventHandlers.onDataLoad({ + layerId, + dataId, + }); + } + + dispatch({ + meta, + type: LAYER_DATA_LOAD_STARTED, + layerId, + dataId, + requestToken, + }); + }; +} + +export function updateSourceDataRequest(layerId, newData) { + return dispatch => { + dispatch({ + type: UPDATE_SOURCE_DATA_REQUEST, + dataId: SOURCE_DATA_ID_ORIGIN, + layerId, + newData, + }); + + dispatch(updateStyleMeta(layerId)); + }; +} + +export function endDataLoad(layerId, dataId, requestToken, data, meta) { + return async (dispatch, getState) => { + dispatch(unregisterCancelCallback(requestToken)); + + const features = data && data.features ? data.features : []; + + const eventHandlers = getEventHandlers(getState()); + if (eventHandlers && eventHandlers.onDataLoadEnd) { + const layer = getLayerById(layerId, getState()); + const resultMeta = {}; + if (layer && layer.getType() === LAYER_TYPE.VECTOR) { + resultMeta.featuresCount = features.length; + } + + eventHandlers.onDataLoadEnd({ + layerId, + dataId, + resultMeta, + }); + } + + dispatch(cleanTooltipStateForLayer(layerId, features)); + dispatch({ + type: LAYER_DATA_LOAD_ENDED, + layerId, + dataId, + data, + meta, + requestToken, + }); + + //Clear any data-load errors when there is a succesful data return. + //Co this on end-data-load iso at start-data-load to avoid blipping the error status between true/false. + //This avoids jitter in the warning icon of the TOC when the requests continues to return errors. + dispatch(setLayerDataLoadErrorStatus(layerId, null)); + + dispatch(updateStyleMeta(layerId)); + }; +} + +export function onDataLoadError(layerId, dataId, requestToken, errorMessage) { + return async (dispatch, getState) => { + dispatch(unregisterCancelCallback(requestToken)); + + const eventHandlers = getEventHandlers(getState()); + if (eventHandlers && eventHandlers.onDataLoadError) { + eventHandlers.onDataLoadError({ + layerId, + dataId, + errorMessage, + }); + } + + dispatch(cleanTooltipStateForLayer(layerId)); + dispatch({ + type: LAYER_DATA_LOAD_ERROR, + data: null, + layerId, + dataId, + requestToken, + }); + + dispatch(setLayerDataLoadErrorStatus(layerId, errorMessage)); + }; +} + +export function updateSourceProp(layerId, propName, value, newLayerType) { + return async dispatch => { + dispatch({ + type: UPDATE_SOURCE_PROP, + layerId, + propName, + value, + }); + if (newLayerType) { + dispatch(updateLayerType(layerId, newLayerType)); + } + await dispatch(clearMissingStyleProperties(layerId)); + dispatch(syncDataForLayer(layerId)); + }; +} + +function updateLayerType(layerId, newLayerType) { + return (dispatch, getState) => { + const layer = getLayerById(layerId, getState()); + if (!layer || layer.getType() === newLayerType) { + return; + } + dispatch(clearDataRequests(layer)); + dispatch({ + type: UPDATE_LAYER_PROP, + id: layerId, + propName: 'type', + newValue: newLayerType, + }); + }; +} + +export function syncDataForLayer(layerId) { + return async (dispatch, getState) => { + const targetLayer = getLayerById(layerId, getState()); + if (targetLayer) { + const dataFilters = getDataFilters(getState()); + const loadingFunctions = getLayerLoadingCallbacks(dispatch, getState, layerId); + await targetLayer.syncData({ + ...loadingFunctions, + dataFilters, + }); + } + }; +} + +export function updateLayerLabel(id, newLabel) { + return { + type: UPDATE_LAYER_PROP, + id, + propName: 'label', + newValue: newLabel, + }; +} + +export function updateLayerMinZoom(id, minZoom) { + return { + type: UPDATE_LAYER_PROP, + id, + propName: 'minZoom', + newValue: minZoom, + }; +} + +export function updateLayerMaxZoom(id, maxZoom) { + return { + type: UPDATE_LAYER_PROP, + id, + propName: 'maxZoom', + newValue: maxZoom, + }; +} + +export function updateLayerAlpha(id, alpha) { + return { + type: UPDATE_LAYER_PROP, + id, + propName: 'alpha', + newValue: alpha, + }; +} + +export function setLayerQuery(id, query) { + return dispatch => { + dispatch({ + type: UPDATE_LAYER_PROP, + id, + propName: 'query', + newValue: query, + }); + + dispatch(syncDataForLayer(id)); + }; +} + +export function removeSelectedLayer() { + return (dispatch, getState) => { + const state = getState(); + const layerId = getSelectedLayerId(state); + dispatch(removeLayer(layerId)); + }; +} + +export function removeLayer(layerId) { + return async (dispatch, getState) => { + const state = getState(); + const selectedLayerId = getSelectedLayerId(state); + if (layerId === selectedLayerId) { + dispatch(updateFlyout(FLYOUT_STATE.NONE)); + await dispatch(setSelectedLayer(null)); + } + dispatch(removeLayerFromLayerList(layerId)); + }; +} + +function removeLayerFromLayerList(layerId) { + return (dispatch, getState) => { + const layerGettingRemoved = getLayerById(layerId, getState()); + if (!layerGettingRemoved) { + return; + } + + layerGettingRemoved.getInFlightRequestTokens().forEach(requestToken => { + dispatch(cancelRequest(requestToken)); + }); + dispatch(cleanTooltipStateForLayer(layerId)); + layerGettingRemoved.destroy(); + dispatch({ + type: REMOVE_LAYER, + id: layerId, + }); + }; +} + +export function setQuery({ query, timeFilters, filters = [], refresh = false }) { + function generateQueryTimestamp() { + return new Date().toISOString(); + } + return async (dispatch, getState) => { + const prevQuery = getQuery(getState()); + const prevTriggeredAt = + prevQuery && prevQuery.queryLastTriggeredAt + ? prevQuery.queryLastTriggeredAt + : generateQueryTimestamp(); + + dispatch({ + type: SET_QUERY, + timeFilters, + query: { + ...query, + // ensure query changes to trigger re-fetch when "Refresh" clicked + queryLastTriggeredAt: refresh ? generateQueryTimestamp() : prevTriggeredAt, + }, + filters, + }); + + const dataFilters = getDataFilters(getState()); + await syncDataForAllLayers(dispatch, getState, dataFilters); + }; +} + +export function setRefreshConfig({ isPaused, interval }) { + return { + type: SET_REFRESH_CONFIG, + isPaused, + interval, + }; +} + +export function triggerRefreshTimer() { + return async (dispatch, getState) => { + dispatch({ + type: TRIGGER_REFRESH_TIMER, + }); + + const dataFilters = getDataFilters(getState()); + await syncDataForAllLayers(dispatch, getState, dataFilters); + }; +} + +export function clearMissingStyleProperties(layerId) { + return async (dispatch, getState) => { + const targetLayer = getLayerById(layerId, getState()); + if (!targetLayer) { + return; + } + + const style = targetLayer.getCurrentStyle(); + if (!style) { + return; + } + + const nextFields = await targetLayer.getFields(); //take into account all fields, since labels can be driven by any field (source or join) + const { hasChanges, nextStyleDescriptor } = style.getDescriptorWithMissingStylePropsRemoved( + nextFields + ); + if (hasChanges) { + dispatch(updateLayerStyle(layerId, nextStyleDescriptor)); + } + }; +} + +export function updateLayerStyle(layerId, styleDescriptor) { + return dispatch => { + dispatch({ + type: UPDATE_LAYER_STYLE, + layerId, + style: { + ...styleDescriptor, + }, + }); + + // Ensure updateStyleMeta is triggered + // syncDataForLayer may not trigger endDataLoad if no re-fetch is required + dispatch(updateStyleMeta(layerId)); + + // Style update may require re-fetch, for example ES search may need to retrieve field used for dynamic styling + dispatch(syncDataForLayer(layerId)); + }; +} + +export function updateStyleMeta(layerId) { + return async (dispatch, getState) => { + const layer = getLayerById(layerId, getState()); + if (!layer) { + return; + } + const sourceDataRequest = layer.getSourceDataRequest(); + const style = layer.getCurrentStyle(); + if (!style || !sourceDataRequest) { + return; + } + const styleMeta = await style.pluckStyleMetaFromSourceDataRequest(sourceDataRequest); + dispatch({ + type: SET_LAYER_STYLE_META, + layerId, + styleMeta, + }); + }; +} + +export function updateLayerStyleForSelectedLayer(styleDescriptor) { + return (dispatch, getState) => { + const selectedLayerId = getSelectedLayerId(getState()); + if (!selectedLayerId) { + return; + } + dispatch(updateLayerStyle(selectedLayerId, styleDescriptor)); + }; +} + +export function setJoinsForLayer(layer, joins) { + return async dispatch => { + await dispatch({ + type: SET_JOINS, + layer: layer, + joins: joins, + }); + + await dispatch(clearMissingStyleProperties(layer.getId())); + dispatch(syncDataForLayer(layer.getId())); + }; +} + +export function updateDrawState(drawState) { + return dispatch => { + if (drawState !== null) { + dispatch({ type: SET_OPEN_TOOLTIPS, openTooltips: [] }); // tooltips just get in the way + } + dispatch({ + type: UPDATE_DRAW_STATE, + drawState: drawState, + }); + }; +} + +export function disableInteractive() { + return { type: SET_INTERACTIVE, disableInteractive: true }; +} + +export function disableTooltipControl() { + return { type: DISABLE_TOOLTIP_CONTROL, disableTooltipControl: true }; +} + +export function hideToolbarOverlay() { + return { type: HIDE_TOOLBAR_OVERLAY, hideToolbarOverlay: true }; +} + +export function hideLayerControl() { + return { type: HIDE_LAYER_CONTROL, hideLayerControl: true }; +} +export function hideViewControl() { + return { type: HIDE_VIEW_CONTROL, hideViewControl: true }; +} + +export function setHiddenLayers(hiddenLayerIds) { + return (dispatch, getState) => { + const isMapReady = getMapReady(getState()); + + if (!isMapReady) { + dispatch({ type: SET_WAITING_FOR_READY_HIDDEN_LAYERS, hiddenLayerIds }); + } else { + getLayerListRaw(getState()).forEach(layer => + dispatch(setLayerVisibility(layer.id, !hiddenLayerIds.includes(layer.id))) + ); + } + }; +} diff --git a/x-pack/legacy/plugins/maps/public/actions/map_actions.test.js b/x-pack/plugins/maps/public/actions/map_actions.test.js similarity index 98% rename from x-pack/legacy/plugins/maps/public/actions/map_actions.test.js rename to x-pack/plugins/maps/public/actions/map_actions.test.js index 7e2a3c827fa88..c280b8af7ab80 100644 --- a/x-pack/legacy/plugins/maps/public/actions/map_actions.test.js +++ b/x-pack/plugins/maps/public/actions/map_actions.test.js @@ -5,7 +5,7 @@ */ jest.mock('../selectors/map_selectors', () => ({})); -jest.mock('../../../../../plugins/maps/public/kibana_services', () => ({})); +jest.mock('../kibana_services', () => ({})); import { mapExtentChanged, setMouseCoordinates } from './map_actions'; diff --git a/x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts b/x-pack/plugins/maps/public/actions/ui_actions.d.ts similarity index 54% rename from x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts rename to x-pack/plugins/maps/public/actions/ui_actions.d.ts index 233918847de08..e087dc70256f0 100644 --- a/x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts +++ b/x-pack/plugins/maps/public/actions/ui_actions.d.ts @@ -6,6 +6,17 @@ import { AnyAction } from 'redux'; +export const UPDATE_FLYOUT: string; +export const CLOSE_SET_VIEW: string; +export const OPEN_SET_VIEW: string; +export const SET_IS_LAYER_TOC_OPEN: string; +export const SET_FULL_SCREEN: string; +export const SET_READ_ONLY: string; +export const SET_OPEN_TOC_DETAILS: string; +export const SHOW_TOC_DETAILS: string; +export const HIDE_TOC_DETAILS: string; +export const UPDATE_INDEXING_STAGE: string; + export function setOpenTOCDetails(layerIds?: string[]): AnyAction; export function setIsLayerTOCOpen(open: boolean): AnyAction; diff --git a/x-pack/plugins/maps/public/actions/ui_actions.js b/x-pack/plugins/maps/public/actions/ui_actions.js index 59ae56c15056a..77fdf6b0f12d2 100644 --- a/x-pack/plugins/maps/public/actions/ui_actions.js +++ b/x-pack/plugins/maps/public/actions/ui_actions.js @@ -14,3 +14,73 @@ export const SET_OPEN_TOC_DETAILS = 'SET_OPEN_TOC_DETAILS'; export const SHOW_TOC_DETAILS = 'SHOW_TOC_DETAILS'; export const HIDE_TOC_DETAILS = 'HIDE_TOC_DETAILS'; export const UPDATE_INDEXING_STAGE = 'UPDATE_INDEXING_STAGE'; + +export function exitFullScreen() { + return { + type: SET_FULL_SCREEN, + isFullScreen: false, + }; +} + +export function updateFlyout(display) { + return { + type: UPDATE_FLYOUT, + display, + }; +} +export function closeSetView() { + return { + type: CLOSE_SET_VIEW, + }; +} +export function openSetView() { + return { + type: OPEN_SET_VIEW, + }; +} +export function setIsLayerTOCOpen(isLayerTOCOpen) { + return { + type: SET_IS_LAYER_TOC_OPEN, + isLayerTOCOpen, + }; +} +export function enableFullScreen() { + return { + type: SET_FULL_SCREEN, + isFullScreen: true, + }; +} +export function setReadOnly(isReadOnly) { + return { + type: SET_READ_ONLY, + isReadOnly, + }; +} + +export function setOpenTOCDetails(layerIds) { + return { + type: SET_OPEN_TOC_DETAILS, + layerIds, + }; +} + +export function showTOCDetails(layerId) { + return { + type: SHOW_TOC_DETAILS, + layerId, + }; +} + +export function hideTOCDetails(layerId) { + return { + type: HIDE_TOC_DETAILS, + layerId, + }; +} + +export function updateIndexingStage(stage) { + return { + type: UPDATE_INDEXING_STAGE, + stage, + }; +} diff --git a/x-pack/legacy/plugins/maps/public/angular/get_initial_layers.d.ts b/x-pack/plugins/maps/public/angular/get_initial_layers.d.ts similarity index 100% rename from x-pack/legacy/plugins/maps/public/angular/get_initial_layers.d.ts rename to x-pack/plugins/maps/public/angular/get_initial_layers.d.ts diff --git a/x-pack/plugins/maps/public/angular/get_initial_layers.js b/x-pack/plugins/maps/public/angular/get_initial_layers.js new file mode 100644 index 0000000000000..1eb5dac309f28 --- /dev/null +++ b/x-pack/plugins/maps/public/angular/get_initial_layers.js @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import _ from 'lodash'; +// Import each layer type, even those not used, to init in registry + +import '../layers/sources/wms_source'; + +import '../layers/sources/ems_file_source'; + +import '../layers/sources/es_search_source'; + +import '../layers/sources/es_pew_pew_source/es_pew_pew_source'; + +import '../layers/sources/kibana_regionmap_source'; + +import '../layers/sources/es_geo_grid_source'; + +import '../layers/sources/xyz_tms_source'; + +import { KibanaTilemapSource } from '../layers/sources/kibana_tilemap_source'; + +import { EMSTMSSource } from '../layers/sources/ems_tms_source'; + +import { getInjectedVarFunc } from '../kibana_services'; + +import { getKibanaTileMap } from '../meta'; + +export function getInitialLayers(layerListJSON, initialLayers = []) { + if (layerListJSON) { + return JSON.parse(layerListJSON); + } + + const tilemapSourceFromKibana = getKibanaTileMap(); + if (_.get(tilemapSourceFromKibana, 'url')) { + const sourceDescriptor = KibanaTilemapSource.createDescriptor(); + const source = new KibanaTilemapSource(sourceDescriptor); + const layer = source.createDefaultLayer(); + return [layer.toLayerDescriptor(), ...initialLayers]; + } + + const isEmsEnabled = getInjectedVarFunc()('isEmsEnabled', true); + if (isEmsEnabled) { + const descriptor = EMSTMSSource.createDescriptor({ isAutoSelect: true }); + const source = new EMSTMSSource(descriptor); + const layer = source.createDefaultLayer(); + return [layer.toLayerDescriptor(), ...initialLayers]; + } + + return initialLayers; +} diff --git a/x-pack/legacy/plugins/maps/public/angular/get_initial_layers.test.js b/x-pack/plugins/maps/public/angular/get_initial_layers.test.js similarity index 80% rename from x-pack/legacy/plugins/maps/public/angular/get_initial_layers.test.js rename to x-pack/plugins/maps/public/angular/get_initial_layers.test.js index 8c9185a16ea0e..f41ed26b2a05d 100644 --- a/x-pack/legacy/plugins/maps/public/angular/get_initial_layers.test.js +++ b/x-pack/plugins/maps/public/angular/get_initial_layers.test.js @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../../../plugins/maps/public/meta', () => { +jest.mock('../meta', () => { return {}; }); -jest.mock('../../../../../plugins/maps/public/kibana_services'); +jest.mock('../kibana_services'); import { getInitialLayers } from './get_initial_layers'; @@ -15,8 +15,7 @@ const layerListNotProvided = undefined; describe('Saved object has layer list', () => { beforeEach(() => { - require('../../../../../plugins/maps/public/kibana_services').getInjectedVarFunc = () => - jest.fn(); + require('../kibana_services').getInjectedVarFunc = () => jest.fn(); }); it('Should get initial layers from saved object', () => { @@ -33,7 +32,7 @@ describe('Saved object has layer list', () => { describe('kibana.yml configured with map.tilemap.url', () => { beforeAll(() => { - require('../../../../../plugins/maps/public/meta').getKibanaTileMap = () => { + require('../meta').getKibanaTileMap = () => { return { url: 'myTileUrl', }; @@ -63,10 +62,10 @@ describe('kibana.yml configured with map.tilemap.url', () => { describe('EMS is enabled', () => { beforeAll(() => { - require('../../../../../plugins/maps/public/meta').getKibanaTileMap = () => { + require('../meta').getKibanaTileMap = () => { return null; }; - require('../../../../../plugins/maps/public/kibana_services').getInjectedVarFunc = () => key => { + require('../kibana_services').getInjectedVarFunc = () => key => { switch (key) { case 'emsTileLayerId': return { @@ -107,11 +106,11 @@ describe('EMS is enabled', () => { describe('EMS is not enabled', () => { beforeAll(() => { - require('../../../../../plugins/maps/public/meta').getKibanaTileMap = () => { + require('../meta').getKibanaTileMap = () => { return null; }; - require('../../../../../plugins/maps/public/kibana_services').getInjectedVarFunc = () => key => { + require('../kibana_services').getInjectedVarFunc = () => key => { switch (key) { case 'isEmsEnabled': return false; diff --git a/x-pack/legacy/plugins/maps/public/angular/get_initial_query.js b/x-pack/plugins/maps/public/angular/get_initial_query.js similarity index 82% rename from x-pack/legacy/plugins/maps/public/angular/get_initial_query.js rename to x-pack/plugins/maps/public/angular/get_initial_query.js index c50ecb2b05dc0..4f61142413671 100644 --- a/x-pack/legacy/plugins/maps/public/angular/get_initial_query.js +++ b/x-pack/plugins/maps/public/angular/get_initial_query.js @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getUiSettings } from '../../../../../plugins/maps/public/kibana_services'; +import { getUiSettings } from '../kibana_services'; export function getInitialQuery({ mapStateJSON, appState = {}, userQueryLanguage }) { const settings = getUiSettings(); diff --git a/x-pack/legacy/plugins/maps/public/angular/get_initial_refresh_config.js b/x-pack/plugins/maps/public/angular/get_initial_refresh_config.js similarity index 84% rename from x-pack/legacy/plugins/maps/public/angular/get_initial_refresh_config.js rename to x-pack/plugins/maps/public/angular/get_initial_refresh_config.js index 8735d45debfc4..f13e435cd1d5c 100644 --- a/x-pack/legacy/plugins/maps/public/angular/get_initial_refresh_config.js +++ b/x-pack/plugins/maps/public/angular/get_initial_refresh_config.js @@ -3,8 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getUiSettings } from '../../../../../plugins/maps/public/kibana_services'; + +import { getUiSettings } from '../kibana_services'; export function getInitialRefreshConfig({ mapStateJSON, globalState = {} }) { const uiSettings = getUiSettings(); diff --git a/x-pack/legacy/plugins/maps/public/angular/get_initial_time_filters.js b/x-pack/plugins/maps/public/angular/get_initial_time_filters.js similarity index 80% rename from x-pack/legacy/plugins/maps/public/angular/get_initial_time_filters.js rename to x-pack/plugins/maps/public/angular/get_initial_time_filters.js index 74fbf603e99f5..75d9f0e95ccf0 100644 --- a/x-pack/legacy/plugins/maps/public/angular/get_initial_time_filters.js +++ b/x-pack/plugins/maps/public/angular/get_initial_time_filters.js @@ -3,8 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getUiSettings } from '../../../../../plugins/maps/public/kibana_services'; + +import { getUiSettings } from '../kibana_services'; export function getInitialTimeFilters({ mapStateJSON, globalState = {} }) { if (mapStateJSON) { diff --git a/x-pack/legacy/plugins/maps/public/angular/listing_ng_wrapper.html b/x-pack/plugins/maps/public/angular/listing_ng_wrapper.html similarity index 100% rename from x-pack/legacy/plugins/maps/public/angular/listing_ng_wrapper.html rename to x-pack/plugins/maps/public/angular/listing_ng_wrapper.html diff --git a/x-pack/legacy/plugins/maps/public/angular/map.html b/x-pack/plugins/maps/public/angular/map.html similarity index 100% rename from x-pack/legacy/plugins/maps/public/angular/map.html rename to x-pack/plugins/maps/public/angular/map.html diff --git a/x-pack/legacy/plugins/maps/public/angular/services/gis_map_saved_object_loader.js b/x-pack/plugins/maps/public/angular/services/gis_map_saved_object_loader.js similarity index 79% rename from x-pack/legacy/plugins/maps/public/angular/services/gis_map_saved_object_loader.js rename to x-pack/plugins/maps/public/angular/services/gis_map_saved_object_loader.js index 710997a9c0d7f..2dcec35960b08 100644 --- a/x-pack/legacy/plugins/maps/public/angular/services/gis_map_saved_object_loader.js +++ b/x-pack/plugins/maps/public/angular/services/gis_map_saved_object_loader.js @@ -6,15 +6,14 @@ import _ from 'lodash'; import { createSavedGisMapClass } from './saved_gis_map'; -import { SavedObjectLoader } from '../../../../../../../src/plugins/saved_objects/public'; +import { SavedObjectLoader } from '../../../../../../src/plugins/saved_objects/public'; import { getCoreChrome, getSavedObjectsClient, getIndexPatternService, getCoreOverlays, getData, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../../plugins/maps/public/kibana_services'; +} from '../../kibana_services'; export const getMapsSavedObjectLoader = _.once(function() { const services = { diff --git a/x-pack/legacy/plugins/maps/public/angular/services/saved_gis_map.js b/x-pack/plugins/maps/public/angular/services/saved_gis_map.js similarity index 88% rename from x-pack/legacy/plugins/maps/public/angular/services/saved_gis_map.js rename to x-pack/plugins/maps/public/angular/services/saved_gis_map.js index 990a0613da681..1c47e0ab7dc2a 100644 --- a/x-pack/legacy/plugins/maps/public/angular/services/saved_gis_map.js +++ b/x-pack/plugins/maps/public/angular/services/saved_gis_map.js @@ -5,7 +5,7 @@ */ import _ from 'lodash'; -import { createSavedObjectClass } from '../../../../../../../src/plugins/saved_objects/public'; +import { createSavedObjectClass } from '../../../../../../src/plugins/saved_objects/public'; import { getTimeFilters, getMapZoom, @@ -17,10 +17,10 @@ import { getFilters, } from '../../selectors/map_selectors'; import { getIsLayerTOCOpen, getOpenTOCDetails } from '../../selectors/ui_selectors'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { convertMapExtentToPolygon } from '../../../../../../plugins/maps/public/elasticsearch_geo_utils'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { copyPersistentState } from '../../../../../../plugins/maps/public/reducers/util'; + +import { convertMapExtentToPolygon } from '../../elasticsearch_geo_utils'; + +import { copyPersistentState } from '../../reducers/util'; import { extractReferences, injectReferences } from '../../../common/migrations/references'; import { MAP_SAVED_OBJECT_TYPE } from '../../../common/constants'; diff --git a/x-pack/legacy/plugins/maps/public/components/__snapshots__/geometry_filter_form.test.js.snap b/x-pack/plugins/maps/public/components/__snapshots__/geometry_filter_form.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/__snapshots__/geometry_filter_form.test.js.snap rename to x-pack/plugins/maps/public/components/__snapshots__/geometry_filter_form.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/components/__snapshots__/layer_toc_actions.test.js.snap b/x-pack/plugins/maps/public/components/__snapshots__/layer_toc_actions.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/__snapshots__/layer_toc_actions.test.js.snap rename to x-pack/plugins/maps/public/components/__snapshots__/layer_toc_actions.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/components/_geometry_filter.scss b/x-pack/plugins/maps/public/components/_geometry_filter.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/_geometry_filter.scss rename to x-pack/plugins/maps/public/components/_geometry_filter.scss diff --git a/x-pack/plugins/maps/public/components/_index.scss b/x-pack/plugins/maps/public/components/_index.scss new file mode 100644 index 0000000000000..161b3fefdb8f9 --- /dev/null +++ b/x-pack/plugins/maps/public/components/_index.scss @@ -0,0 +1,3 @@ +@import 'metric_editors'; +@import './geometry_filter'; +@import 'tooltip_selector'; diff --git a/x-pack/legacy/plugins/maps/public/components/_metric_editors.scss b/x-pack/plugins/maps/public/components/_metric_editors.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/_metric_editors.scss rename to x-pack/plugins/maps/public/components/_metric_editors.scss diff --git a/x-pack/legacy/plugins/maps/public/components/_tooltip_selector.scss b/x-pack/plugins/maps/public/components/_tooltip_selector.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/_tooltip_selector.scss rename to x-pack/plugins/maps/public/components/_tooltip_selector.scss diff --git a/x-pack/legacy/plugins/maps/public/components/distance_filter_form.tsx b/x-pack/plugins/maps/public/components/distance_filter_form.tsx similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/distance_filter_form.tsx rename to x-pack/plugins/maps/public/components/distance_filter_form.tsx diff --git a/x-pack/legacy/plugins/maps/public/components/geo_field_with_index.ts b/x-pack/plugins/maps/public/components/geo_field_with_index.ts similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/geo_field_with_index.ts rename to x-pack/plugins/maps/public/components/geo_field_with_index.ts diff --git a/x-pack/legacy/plugins/maps/public/components/geometry_filter_form.js b/x-pack/plugins/maps/public/components/geometry_filter_form.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/geometry_filter_form.js rename to x-pack/plugins/maps/public/components/geometry_filter_form.js diff --git a/x-pack/legacy/plugins/maps/public/components/geometry_filter_form.test.js b/x-pack/plugins/maps/public/components/geometry_filter_form.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/geometry_filter_form.test.js rename to x-pack/plugins/maps/public/components/geometry_filter_form.test.js diff --git a/x-pack/legacy/plugins/maps/public/components/global_filter_checkbox.js b/x-pack/plugins/maps/public/components/global_filter_checkbox.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/global_filter_checkbox.js rename to x-pack/plugins/maps/public/components/global_filter_checkbox.js diff --git a/x-pack/legacy/plugins/maps/public/components/layer_toc_actions.js b/x-pack/plugins/maps/public/components/layer_toc_actions.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/layer_toc_actions.js rename to x-pack/plugins/maps/public/components/layer_toc_actions.js diff --git a/x-pack/legacy/plugins/maps/public/components/layer_toc_actions.test.js b/x-pack/plugins/maps/public/components/layer_toc_actions.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/layer_toc_actions.test.js rename to x-pack/plugins/maps/public/components/layer_toc_actions.test.js diff --git a/x-pack/legacy/plugins/maps/public/components/map_listing.js b/x-pack/plugins/maps/public/components/map_listing.js similarity index 98% rename from x-pack/legacy/plugins/maps/public/components/map_listing.js rename to x-pack/plugins/maps/public/components/map_listing.js index ef1d524cb91dd..ee10fe30130f3 100644 --- a/x-pack/legacy/plugins/maps/public/components/map_listing.js +++ b/x-pack/plugins/maps/public/components/map_listing.js @@ -7,8 +7,8 @@ import React from 'react'; import PropTypes from 'prop-types'; import _ from 'lodash'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getToasts } from '../../../../../plugins/maps/public/kibana_services'; + +import { getToasts } from '../kibana_services'; import { EuiTitle, EuiFieldSearch, diff --git a/x-pack/legacy/plugins/maps/public/components/multi_index_geo_field_select.tsx b/x-pack/plugins/maps/public/components/multi_index_geo_field_select.tsx similarity index 100% rename from x-pack/legacy/plugins/maps/public/components/multi_index_geo_field_select.tsx rename to x-pack/plugins/maps/public/components/multi_index_geo_field_select.tsx diff --git a/x-pack/plugins/maps/public/connected_components/_index.scss b/x-pack/plugins/maps/public/connected_components/_index.scss new file mode 100644 index 0000000000000..83042ae1d586c --- /dev/null +++ b/x-pack/plugins/maps/public/connected_components/_index.scss @@ -0,0 +1,6 @@ +@import 'gis_map/gis_map'; +@import 'layer_addpanel/source_select/index'; +@import 'layer_panel/index'; +@import 'widget_overlay/index'; +@import 'toolbar_overlay/index'; +@import 'map/features_tooltip/index'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/gis_map/_gis_map.scss b/x-pack/plugins/maps/public/connected_components/gis_map/_gis_map.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/gis_map/_gis_map.scss rename to x-pack/plugins/maps/public/connected_components/gis_map/_gis_map.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.d.ts b/x-pack/plugins/maps/public/connected_components/gis_map/index.d.ts similarity index 73% rename from x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.d.ts rename to x-pack/plugins/maps/public/connected_components/gis_map/index.d.ts index 8689d88297171..92d92dfbd142d 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.d.ts +++ b/x-pack/plugins/maps/public/connected_components/gis_map/index.d.ts @@ -6,8 +6,8 @@ import React from 'react'; import { Filter } from 'src/plugins/data/public'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { RenderToolTipContent } from '../../../../../../plugins/maps/public/layers/tooltips/tooltip_property'; + +import { RenderToolTipContent } from '../../layers/tooltips/tooltip_property'; export const GisMap: React.ComponentType<{ addFilters: ((filters: Filter[]) => void) | null; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.js b/x-pack/plugins/maps/public/connected_components/gis_map/index.js similarity index 85% rename from x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.js rename to x-pack/plugins/maps/public/connected_components/gis_map/index.js index 2d8265bae9387..c825fdab75ca7 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.js +++ b/x-pack/plugins/maps/public/connected_components/gis_map/index.js @@ -6,8 +6,8 @@ import { connect } from 'react-redux'; import { GisMap } from './view'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { FLYOUT_STATE } from '../../../../../../plugins/maps/public/reducers/ui'; + +import { FLYOUT_STATE } from '../../reducers/ui'; import { exitFullScreen } from '../../actions/ui_actions'; import { getFlyoutDisplay, getIsFullScreen } from '../../selectors/ui_selectors'; import { triggerRefreshTimer, cancelAllInFlightRequests } from '../../actions/map_actions'; @@ -18,8 +18,8 @@ import { getQueryableUniqueIndexPatternIds, isToolbarOverlayHidden, } from '../../selectors/map_selectors'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getCoreChrome } from '../../../../../../plugins/maps/public/kibana_services'; + +import { getCoreChrome } from '../../kibana_services'; function mapStateToProps(state = {}) { const flyoutDisplay = getFlyoutDisplay(state); diff --git a/x-pack/legacy/plugins/maps/public/connected_components/gis_map/view.js b/x-pack/plugins/maps/public/connected_components/gis_map/view.js similarity index 92% rename from x-pack/legacy/plugins/maps/public/connected_components/gis_map/view.js rename to x-pack/plugins/maps/public/connected_components/gis_map/view.js index 06097ebea1900..28ad12133d611 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/gis_map/view.js +++ b/x-pack/plugins/maps/public/connected_components/gis_map/view.js @@ -7,17 +7,16 @@ import _ from 'lodash'; import React, { Component } from 'react'; import { MBMapContainer } from '../map/mb'; -import { WidgetOverlay } from '../widget_overlay/index'; -import { ToolbarOverlay } from '../toolbar_overlay/index'; -import { LayerPanel } from '../layer_panel/index'; -import { AddLayerPanel } from '../layer_addpanel/index'; +import { WidgetOverlay } from '../widget_overlay'; +import { ToolbarOverlay } from '../toolbar_overlay'; +import { LayerPanel } from '../layer_panel'; +import { AddLayerPanel } from '../layer_addpanel'; import { EuiFlexGroup, EuiFlexItem, EuiCallOut } from '@elastic/eui'; -import { ExitFullScreenButton } from '../../../../../../../src/plugins/kibana_react/public'; +import { ExitFullScreenButton } from '../../../../../../src/plugins/kibana_react/public'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getIndexPatternsFromIds } from '../../../../../../plugins/maps/public/index_pattern_util'; +import { getIndexPatternsFromIds } from '../../index_pattern_util'; import { ES_GEO_FIELD_TYPE } from '../../../common/constants'; -import { indexPatterns as indexPatternsUtils } from '../../../../../../../src/plugins/data/public'; +import { indexPatterns as indexPatternsUtils } from '../../../../../../src/plugins/data/public'; import { i18n } from '@kbn/i18n'; import uuid from 'uuid/v4'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/flyout_footer/index.js b/x-pack/plugins/maps/public/connected_components/layer_addpanel/flyout_footer/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/flyout_footer/index.js rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/flyout_footer/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/flyout_footer/view.js b/x-pack/plugins/maps/public/connected_components/layer_addpanel/flyout_footer/view.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/flyout_footer/view.js rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/flyout_footer/view.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js b/x-pack/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js similarity index 76% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js index e8192795f98ae..bff235a7d27fc 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js +++ b/x-pack/plugins/maps/public/connected_components/layer_addpanel/import_editor/index.js @@ -6,10 +6,10 @@ import { connect } from 'react-redux'; import { ImportEditor } from './view'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getInspectorAdapters } from '../../../../../../../plugins/maps/public/reducers/non_serializable_instances'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { INDEXING_STAGE } from '../../../../../../../plugins/maps/public/reducers/ui'; + +import { getInspectorAdapters } from '../../../reducers/non_serializable_instances'; + +import { INDEXING_STAGE } from '../../../reducers/ui'; import { updateIndexingStage } from '../../../actions/ui_actions'; import { getIndexingStage } from '../../../selectors/ui_selectors'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/view.js b/x-pack/plugins/maps/public/connected_components/layer_addpanel/import_editor/view.js similarity index 89% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/view.js rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/import_editor/view.js index cb20d80733c33..a4fa0d492bf3f 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/import_editor/view.js +++ b/x-pack/plugins/maps/public/connected_components/layer_addpanel/import_editor/view.js @@ -7,8 +7,8 @@ import React, { Fragment } from 'react'; import { EuiSpacer, EuiPanel, EuiButtonEmpty } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { uploadLayerWizardConfig } from '../../../../../../../plugins/maps/public/layers/sources/client_file_source'; + +import { uploadLayerWizardConfig } from '../../../layers/sources/client_file_source'; export const ImportEditor = ({ clearSource, isIndexingTriggered, ...props }) => { const editorProperties = getEditorProperties({ isIndexingTriggered, ...props }); diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/index.js b/x-pack/plugins/maps/public/connected_components/layer_addpanel/index.js similarity index 85% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/index.js rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/index.js index c4e2fa5169b0f..24c1f5ced4fe6 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/index.js +++ b/x-pack/plugins/maps/public/connected_components/layer_addpanel/index.js @@ -6,13 +6,13 @@ import { connect } from 'react-redux'; import { AddLayerPanel } from './view'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { FLYOUT_STATE, INDEXING_STAGE } from '../../../../../../plugins/maps/public/reducers/ui'; + +import { FLYOUT_STATE, INDEXING_STAGE } from '../../reducers/ui'; import { updateFlyout, updateIndexingStage } from '../../actions/ui_actions'; import { getFlyoutDisplay, getIndexingStage } from '../../selectors/ui_selectors'; import { getMapColors } from '../../selectors/map_selectors'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getInspectorAdapters } from '../../../../../../plugins/maps/public/reducers/non_serializable_instances'; + +import { getInspectorAdapters } from '../../reducers/non_serializable_instances'; import { setTransientLayer, addLayer, diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js b/x-pack/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js similarity index 75% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js index 553e54ee89766..8937f32d3bf05 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js +++ b/x-pack/plugins/maps/public/connected_components/layer_addpanel/source_editor/index.js @@ -6,8 +6,8 @@ import { connect } from 'react-redux'; import { SourceEditor } from './view'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getInspectorAdapters } from '../../../../../../../plugins/maps/public/reducers/non_serializable_instances'; + +import { getInspectorAdapters } from '../../../reducers/non_serializable_instances'; function mapStateToProps(state = {}) { return { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_editor/view.js b/x-pack/plugins/maps/public/connected_components/layer_addpanel/source_editor/view.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_editor/view.js rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/source_editor/view.js diff --git a/x-pack/plugins/maps/public/connected_components/layer_addpanel/source_select/_index.scss b/x-pack/plugins/maps/public/connected_components/layer_addpanel/source_select/_index.scss new file mode 100644 index 0000000000000..8ae6970315e13 --- /dev/null +++ b/x-pack/plugins/maps/public/connected_components/layer_addpanel/source_select/_index.scss @@ -0,0 +1 @@ +@import 'source_select'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_select/_source_select.scss b/x-pack/plugins/maps/public/connected_components/layer_addpanel/source_select/_source_select.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_select/_source_select.scss rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/source_select/_source_select.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_select/source_select.js b/x-pack/plugins/maps/public/connected_components/layer_addpanel/source_select/source_select.js similarity index 90% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_select/source_select.js rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/source_select/source_select.js index 67cc17ebaa224..80b05a0fd015b 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/source_select/source_select.js +++ b/x-pack/plugins/maps/public/connected_components/layer_addpanel/source_select/source_select.js @@ -5,8 +5,8 @@ */ import React, { Fragment } from 'react'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getLayerWizards } from '../../../../../../../plugins/maps/public/layers/layer_wizard_registry'; + +import { getLayerWizards } from '../../../layers/layer_wizard_registry'; import { EuiTitle, EuiSpacer, EuiCard, EuiIcon } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import _ from 'lodash'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/view.js b/x-pack/plugins/maps/public/connected_components/layer_addpanel/view.js similarity index 98% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/view.js rename to x-pack/plugins/maps/public/connected_components/layer_addpanel/view.js index a54df69471aa0..92fcf01f3901f 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/view.js +++ b/x-pack/plugins/maps/public/connected_components/layer_addpanel/view.js @@ -63,13 +63,13 @@ export class AddLayerPanel extends Component { return; } - const style = + const styleDescriptor = this.state.layer && this.state.layer.getCurrentStyle() ? this.state.layer.getCurrentStyle().getDescriptor() : null; const layerInitProps = { ...options, - style: style, + style: styleDescriptor, }; const newLayer = source.createDefaultLayer(layerInitProps, this.props.mapColors); if (!this._isMounted) { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/__snapshots__/view.test.js.snap b/x-pack/plugins/maps/public/connected_components/layer_panel/__snapshots__/view.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/__snapshots__/view.test.js.snap rename to x-pack/plugins/maps/public/connected_components/layer_panel/__snapshots__/view.test.js.snap diff --git a/x-pack/plugins/maps/public/connected_components/layer_panel/_index.scss b/x-pack/plugins/maps/public/connected_components/layer_panel/_index.scss new file mode 100644 index 0000000000000..41b4826a02c67 --- /dev/null +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/_index.scss @@ -0,0 +1,4 @@ +@import 'layer_panel'; +@import 'filter_editor/filter_editor'; +@import 'join_editor/resources/join'; +@import 'style_settings/style_settings'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/_layer_panel.scss b/x-pack/plugins/maps/public/connected_components/layer_panel/_layer_panel.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/_layer_panel.scss rename to x-pack/plugins/maps/public/connected_components/layer_panel/_layer_panel.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/_filter_editor.scss b/x-pack/plugins/maps/public/connected_components/layer_panel/filter_editor/_filter_editor.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/_filter_editor.scss rename to x-pack/plugins/maps/public/connected_components/layer_panel/filter_editor/_filter_editor.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js b/x-pack/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js similarity index 96% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js index 40fdac38493d4..fba2ec05d0b1d 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/filter_editor/filter_editor.js @@ -20,12 +20,7 @@ import { import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -import { - getIndexPatternService, - getUiSettings, - getData, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../../../plugins/maps/public/kibana_services'; +import { getIndexPatternService, getUiSettings, getData } from '../../../kibana_services'; import { GlobalFilterCheckbox } from '../../../components/global_filter_checkbox'; export class FilterEditor extends Component { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/index.js b/x-pack/plugins/maps/public/connected_components/layer_panel/filter_editor/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/filter_editor/index.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/filter_editor/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js b/x-pack/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js similarity index 89% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js index 287f0019f18ec..621ce209eb982 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/flyout_footer/index.js @@ -6,8 +6,8 @@ import { connect } from 'react-redux'; import { FlyoutFooter } from './view'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { FLYOUT_STATE } from '../../../../../../../plugins/maps/public/reducers/ui'; + +import { FLYOUT_STATE } from '../../../reducers/ui'; import { updateFlyout } from '../../../actions/ui_actions'; import { hasDirtyState } from '../../../selectors/map_selectors'; import { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/flyout_footer/view.js b/x-pack/plugins/maps/public/connected_components/layer_panel/flyout_footer/view.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/flyout_footer/view.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/flyout_footer/view.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/index.js b/x-pack/plugins/maps/public/connected_components/layer_panel/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/index.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/index.js b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/index.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/__snapshots__/metrics_expression.test.js.snap b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/__snapshots__/metrics_expression.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/__snapshots__/metrics_expression.test.js.snap rename to x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/__snapshots__/metrics_expression.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/_join.scss b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/_join.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/_join.scss rename to x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/_join.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join.js b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join.js similarity index 95% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join.js index 9c4e1cfdb5467..0d26354e2449b 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join.js @@ -13,9 +13,9 @@ import { MetricsExpression } from './metrics_expression'; import { WhereExpression } from './where_expression'; import { GlobalFilterCheckbox } from '../../../../components/global_filter_checkbox'; -import { indexPatterns } from '../../../../../../../../../src/plugins/data/public'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getIndexPatternService } from '../../../../../../../../plugins/maps/public/kibana_services'; +import { indexPatterns } from '../../../../../../../../src/plugins/data/public'; + +import { getIndexPatternService } from '../../../../kibana_services'; export class Join extends Component { state = { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js similarity index 93% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js index 73600c81d221e..12ca2f3c514a0 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/join_expression.js @@ -16,16 +16,15 @@ import { EuiFormHelpText, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { SingleFieldSelect } from '../../../../../../../../plugins/maps/public/components/single_field_select'; + +import { SingleFieldSelect } from '../../../../components/single_field_select'; import { FormattedMessage } from '@kbn/i18n/react'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getTermsFields } from '../../../../../../../../plugins/maps/public/index_pattern_util'; + +import { getTermsFields } from '../../../../index_pattern_util'; import { getIndexPatternService, getIndexPatternSelectComponent, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../../../../plugins/maps/public/kibana_services'; +} from '../../../../kibana_services'; export class JoinExpression extends Component { state = { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.js b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.js similarity index 95% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.js index c6a79a398f9af..8c83743ac4c96 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.js @@ -14,8 +14,8 @@ import { EuiFormErrorText, EuiFormHelpText, } from '@elastic/eui'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { MetricsEditor } from '../../../../../../../../plugins/maps/public/components/metrics_editor'; + +import { MetricsEditor } from '../../../../components/metrics_editor'; import { FormattedMessage } from '@kbn/i18n/react'; import { AGG_TYPE } from '../../../../../common/constants'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.test.js b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.test.js similarity index 92% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.test.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.test.js index d8bf862249448..3cd8a3c42879a 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.test.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/metrics_expression.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../../../../../../plugins/maps/public/components/metric_editor', () => ({ +jest.mock('../../../../components/metric_editor', () => ({ MetricsEditor: () => { return
mockMetricsEditor
; }, diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js similarity index 94% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js index 54ec0ac46fa3d..7c9b4f7b7b9a4 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/resources/where_expression.js @@ -8,11 +8,7 @@ import React, { Component } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiButton, EuiPopover, EuiExpression, EuiFormHelpText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { - getUiSettings, - getData, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../../../../plugins/maps/public/kibana_services'; +import { getUiSettings, getData } from '../../../../kibana_services'; export class WhereExpression extends Component { state = { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/view.js b/x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/view.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/join_editor/view.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/join_editor/view.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_errors/__snapshots__/layer_errors.test.js.snap b/x-pack/plugins/maps/public/connected_components/layer_panel/layer_errors/__snapshots__/layer_errors.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_errors/__snapshots__/layer_errors.test.js.snap rename to x-pack/plugins/maps/public/connected_components/layer_panel/layer_errors/__snapshots__/layer_errors.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_errors/index.js b/x-pack/plugins/maps/public/connected_components/layer_panel/layer_errors/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_errors/index.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/layer_errors/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_errors/layer_errors.js b/x-pack/plugins/maps/public/connected_components/layer_panel/layer_errors/layer_errors.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_errors/layer_errors.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/layer_errors/layer_errors.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_errors/layer_errors.test.js b/x-pack/plugins/maps/public/connected_components/layer_panel/layer_errors/layer_errors.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_errors/layer_errors.test.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/layer_errors/layer_errors.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_settings/index.js b/x-pack/plugins/maps/public/connected_components/layer_panel/layer_settings/index.js similarity index 90% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_settings/index.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/layer_settings/index.js index 73c98db8e429d..e2f22c584d3b3 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_settings/index.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/layer_settings/index.js @@ -13,10 +13,13 @@ import { updateLayerMinZoom, updateLayerAlpha, } from '../../../actions/map_actions'; +import { MAX_ZOOM } from '../../../../common/constants'; function mapStateToProps(state = {}) { const selectedLayer = getSelectedLayer(state); return { + minVisibilityZoom: selectedLayer.getMinSourceZoom(), + maxVisibilityZoom: MAX_ZOOM, alpha: selectedLayer.getAlpha(), label: selectedLayer.getLabel(), layerId: selectedLayer.getId(), diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_settings/layer_settings.js b/x-pack/plugins/maps/public/connected_components/layer_panel/layer_settings/layer_settings.js similarity index 84% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_settings/layer_settings.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/layer_settings/layer_settings.js index bd27450943638..168c735ab7a6c 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_settings/layer_settings.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/layer_settings/layer_settings.js @@ -8,13 +8,10 @@ import React, { Fragment } from 'react'; import { EuiTitle, EuiPanel, EuiFormRow, EuiFieldText, EuiSpacer } from '@elastic/eui'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { ValidatedRange } from '../../../../../../../plugins/maps/public/components/validated_range'; +import { ValidatedRange } from '../../../components/validated_range'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { ValidatedDualRange } from '../../../../../../../../src/plugins/kibana_react/public'; -import { MAX_ZOOM, MIN_ZOOM } from '../../../../common/constants'; - +import { ValidatedDualRange } from '../../../../../../../src/plugins/kibana_react/public'; export function LayerSettings(props) { const onLabelChange = event => { const label = event.target.value; @@ -22,8 +19,8 @@ export function LayerSettings(props) { }; const onZoomChange = ([min, max]) => { - props.updateMinZoom(props.layerId, Math.max(MIN_ZOOM, parseInt(min, 10))); - props.updateMaxZoom(props.layerId, Math.min(MAX_ZOOM, parseInt(max, 10))); + props.updateMinZoom(props.layerId, Math.max(props.minVisibilityZoom, parseInt(min, 10))); + props.updateMaxZoom(props.layerId, Math.min(props.maxVisibilityZoom, parseInt(max, 10))); }; const onAlphaChange = alpha => { @@ -38,8 +35,8 @@ export function LayerSettings(props) { defaultMessage: 'Visibility', })} formRowDisplay="columnCompressed" - min={MIN_ZOOM} - max={MAX_ZOOM} + min={props.minVisibilityZoom} + max={props.maxVisibilityZoom} value={[props.minZoom, props.maxZoom]} showInput="inputWithPopover" showRange diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/style_settings/_style_settings.scss b/x-pack/plugins/maps/public/connected_components/layer_panel/style_settings/_style_settings.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/style_settings/_style_settings.scss rename to x-pack/plugins/maps/public/connected_components/layer_panel/style_settings/_style_settings.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/style_settings/index.js b/x-pack/plugins/maps/public/connected_components/layer_panel/style_settings/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/style_settings/index.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/style_settings/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/style_settings/style_settings.js b/x-pack/plugins/maps/public/connected_components/layer_panel/style_settings/style_settings.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/style_settings/style_settings.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/style_settings/style_settings.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.js b/x-pack/plugins/maps/public/connected_components/layer_panel/view.js similarity index 95% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/view.js index 2521318f0b3c9..f8b7c417e67fd 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.js +++ b/x-pack/plugins/maps/public/connected_components/layer_panel/view.js @@ -28,10 +28,10 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; -import { Storage } from '../../../../../../../src/plugins/kibana_utils/public'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getData, getCore } from '../../../../../../plugins/maps/public/kibana_services'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; +import { Storage } from '../../../../../../src/plugins/kibana_utils/public'; + +import { getData, getCore } from '../../kibana_services'; const localStorage = new Storage(window.localStorage); diff --git a/x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.test.js b/x-pack/plugins/maps/public/connected_components/layer_panel/view.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/layer_panel/view.test.js rename to x-pack/plugins/maps/public/connected_components/layer_panel/view.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/__snapshots__/feature_properties.test.js.snap b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/__snapshots__/feature_properties.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/__snapshots__/feature_properties.test.js.snap rename to x-pack/plugins/maps/public/connected_components/map/features_tooltip/__snapshots__/feature_properties.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/__snapshots__/tooltip_header.test.js.snap b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/__snapshots__/tooltip_header.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/__snapshots__/tooltip_header.test.js.snap rename to x-pack/plugins/maps/public/connected_components/map/features_tooltip/__snapshots__/tooltip_header.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/_index.scss b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/_index.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/_index.scss rename to x-pack/plugins/maps/public/connected_components/map/features_tooltip/_index.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/feature_geometry_filter_form.js b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/feature_geometry_filter_form.js similarity index 92% rename from x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/feature_geometry_filter_form.js rename to x-pack/plugins/maps/public/connected_components/map/features_tooltip/feature_geometry_filter_form.js index 15824b82965e8..b103fb43af97c 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/feature_geometry_filter_form.js +++ b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/feature_geometry_filter_form.js @@ -8,12 +8,12 @@ import React, { Component, Fragment } from 'react'; import { EuiIcon } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { createSpatialFilterWithGeometry } from '../../../../../../../plugins/maps/public/elasticsearch_geo_utils'; + +import { createSpatialFilterWithGeometry } from '../../../elasticsearch_geo_utils'; import { GEO_JSON_TYPE } from '../../../../common/constants'; import { GeometryFilterForm } from '../../../components/geometry_filter_form'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { UrlOverflowService } from '../../../../../../../../src/plugins/kibana_legacy/public'; + +import { UrlOverflowService } from '../../../../../../../src/plugins/kibana_legacy/public'; import rison from 'rison-node'; // over estimated and imprecise value to ensure filter has additional room for any meta keys added when filter is mapped. diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/feature_properties.js b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/feature_properties.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/feature_properties.js rename to x-pack/plugins/maps/public/connected_components/map/features_tooltip/feature_properties.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/feature_properties.test.js b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/feature_properties.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/feature_properties.test.js rename to x-pack/plugins/maps/public/connected_components/map/features_tooltip/feature_properties.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/features_tooltip.js b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/features_tooltip.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/features_tooltip.js rename to x-pack/plugins/maps/public/connected_components/map/features_tooltip/features_tooltip.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/tooltip_header.js b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/tooltip_header.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/tooltip_header.js rename to x-pack/plugins/maps/public/connected_components/map/features_tooltip/tooltip_header.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/tooltip_header.test.js b/x-pack/plugins/maps/public/connected_components/map/features_tooltip/tooltip_header.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/features_tooltip/tooltip_header.test.js rename to x-pack/plugins/maps/public/connected_components/map/features_tooltip/tooltip_header.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/draw_control/draw_circle.ts b/x-pack/plugins/maps/public/connected_components/map/mb/draw_control/draw_circle.ts similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/draw_control/draw_circle.ts rename to x-pack/plugins/maps/public/connected_components/map/mb/draw_control/draw_circle.ts diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/draw_control/draw_control.js b/x-pack/plugins/maps/public/connected_components/map/mb/draw_control/draw_control.js similarity index 96% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/draw_control/draw_control.js rename to x-pack/plugins/maps/public/connected_components/map/mb/draw_control/draw_control.js index cc0e665525036..d20faa39d6492 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/draw_control/draw_control.js +++ b/x-pack/plugins/maps/public/connected_components/map/mb/draw_control/draw_control.js @@ -15,8 +15,7 @@ import { createSpatialFilterWithGeometry, getBoundingBoxGeometry, roundCoordinates, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../../../../plugins/maps/public/elasticsearch_geo_utils'; +} from '../../../../elasticsearch_geo_utils'; import { DrawTooltip } from './draw_tooltip'; const mbDrawModes = MapboxDraw.modes; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/draw_control/draw_tooltip.js b/x-pack/plugins/maps/public/connected_components/map/mb/draw_control/draw_tooltip.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/draw_control/draw_tooltip.js rename to x-pack/plugins/maps/public/connected_components/map/mb/draw_control/draw_tooltip.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/draw_control/index.js b/x-pack/plugins/maps/public/connected_components/map/mb/draw_control/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/draw_control/index.js rename to x-pack/plugins/maps/public/connected_components/map/mb/draw_control/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/index.js b/x-pack/plugins/maps/public/connected_components/map/mb/index.js similarity index 91% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/index.js rename to x-pack/plugins/maps/public/connected_components/map/mb/index.js index 350cb7028abee..d864b60eb433b 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/index.js +++ b/x-pack/plugins/maps/public/connected_components/map/mb/index.js @@ -24,8 +24,8 @@ import { isTooltipControlDisabled, isViewControlHidden, } from '../../../selectors/map_selectors'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getInspectorAdapters } from '../../../../../../../plugins/maps/public/reducers/non_serializable_instances'; + +import { getInspectorAdapters } from '../../../reducers/non_serializable_instances'; function mapStateToProps(state = {}) { return { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/mb.utils.test.js b/x-pack/plugins/maps/public/connected_components/map/mb/mb.utils.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/mb.utils.test.js rename to x-pack/plugins/maps/public/connected_components/map/mb/mb.utils.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/__snapshots__/tooltip_control.test.js.snap b/x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/__snapshots__/tooltip_control.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/__snapshots__/tooltip_control.test.js.snap rename to x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/__snapshots__/tooltip_control.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/__snapshots__/tooltip_popover.test.js.snap b/x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/__snapshots__/tooltip_popover.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/__snapshots__/tooltip_popover.test.js.snap rename to x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/__snapshots__/tooltip_popover.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/index.js b/x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/index.js rename to x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_control.js b/x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_control.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_control.js rename to x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_control.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_control.test.js b/x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_control.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_control.test.js rename to x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_control.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_popover.js b/x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_popover.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_popover.js rename to x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_popover.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_popover.test.js b/x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_popover.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_popover.test.js rename to x-pack/plugins/maps/public/connected_components/map/mb/tooltip_control/tooltip_popover.test.js diff --git a/x-pack/plugins/maps/public/connected_components/map/mb/utils.js b/x-pack/plugins/maps/public/connected_components/map/mb/utils.js index 15aacfbf1f38d..7be2cd9e67084 100644 --- a/x-pack/plugins/maps/public/connected_components/map/mb/utils.js +++ b/x-pack/plugins/maps/public/connected_components/map/mb/utils.js @@ -4,8 +4,102 @@ * you may not use this file except in compliance with the Elastic License. */ +import _ from 'lodash'; import { RGBAImage } from './image_utils'; +export function removeOrphanedSourcesAndLayers(mbMap, layerList) { + const mbStyle = mbMap.getStyle(); + + const mbLayerIdsToRemove = []; + mbStyle.layers.forEach(mbLayer => { + const layer = layerList.find(layer => { + return layer.ownsMbLayerId(mbLayer.id); + }); + if (!layer) { + mbLayerIdsToRemove.push(mbLayer.id); + } + }); + mbLayerIdsToRemove.forEach(mbLayerId => mbMap.removeLayer(mbLayerId)); + + const mbSourcesToRemove = []; + for (const mbSourceId in mbStyle.sources) { + if (mbStyle.sources.hasOwnProperty(mbSourceId)) { + const layer = layerList.find(layer => { + return layer.ownsMbSourceId(mbSourceId); + }); + if (!layer) { + mbSourcesToRemove.push(mbSourceId); + } + } + } + mbSourcesToRemove.forEach(mbSourceId => mbMap.removeSource(mbSourceId)); +} + +/** + * This is function assumes only a single layer moved in the layerList, compared to mbMap + * It is optimized to minimize the amount of mbMap.moveLayer calls. + * @param mbMap + * @param layerList + */ +export function syncLayerOrderForSingleLayer(mbMap, layerList) { + if (!layerList || layerList.length === 0) { + return; + } + + const mbLayers = mbMap.getStyle().layers.slice(); + const layerIds = mbLayers.map(mbLayer => { + const layer = layerList.find(layer => layer.ownsMbLayerId(mbLayer.id)); + return layer.getId(); + }); + + const currentLayerOrderLayerIds = _.uniq(layerIds); + + const newLayerOrderLayerIdsUnfiltered = layerList.map(l => l.getId()); + const newLayerOrderLayerIds = newLayerOrderLayerIdsUnfiltered.filter(layerId => + currentLayerOrderLayerIds.includes(layerId) + ); + + let netPos = 0; + let netNeg = 0; + const movementArr = currentLayerOrderLayerIds.reduce((accu, id, idx) => { + const movement = newLayerOrderLayerIds.findIndex(newOId => newOId === id) - idx; + movement > 0 ? netPos++ : movement < 0 && netNeg++; + accu.push({ id, movement }); + return accu; + }, []); + if (netPos === 0 && netNeg === 0) { + return; + } + const movedLayerId = + (netPos >= netNeg && movementArr.find(l => l.movement < 0).id) || + (netPos < netNeg && movementArr.find(l => l.movement > 0).id); + const nextLayerIdx = newLayerOrderLayerIds.findIndex(layerId => layerId === movedLayerId) + 1; + + let nextMbLayerId; + if (nextLayerIdx === newLayerOrderLayerIds.length) { + nextMbLayerId = null; + } else { + const foundLayer = mbLayers.find(({ id: mbLayerId }) => { + const layerId = newLayerOrderLayerIds[nextLayerIdx]; + const layer = layerList.find(layer => layer.getId() === layerId); + return layer.ownsMbLayerId(mbLayerId); + }); + nextMbLayerId = foundLayer.id; + } + + const movedLayer = layerList.find(layer => layer.getId() === movedLayerId); + mbLayers.forEach(({ id: mbLayerId }) => { + if (movedLayer.ownsMbLayerId(mbLayerId)) { + mbMap.moveLayer(mbLayerId, nextMbLayerId); + } + }); +} + +export async function addSpritesheetToMap(json, imgUrl, mbMap) { + const imgData = await loadSpriteSheetImageData(imgUrl); + addSpriteSheetToMapFromImageData(json, imgData, mbMap); +} + function getImageData(img) { const canvas = window.document.createElement('canvas'); const context = canvas.getContext('2d'); diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js b/x-pack/plugins/maps/public/connected_components/map/mb/view.js similarity index 93% rename from x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js rename to x-pack/plugins/maps/public/connected_components/map/mb/view.js index 1fe3d0d493ee7..2d95de184f0f4 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js +++ b/x-pack/plugins/maps/public/connected_components/map/mb/view.js @@ -6,15 +6,20 @@ import _ from 'lodash'; import React from 'react'; -import { ResizeChecker } from '../../../../../../../../src/plugins/kibana_utils/public'; +import { ResizeChecker } from '../../../../../../../src/plugins/kibana_utils/public'; import { syncLayerOrderForSingleLayer, removeOrphanedSourcesAndLayers, addSpritesheetToMap, } from './utils'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getGlyphUrl, isRetina } from '../../../../../../../plugins/maps/public/meta'; -import { DECIMAL_DEGREES_PRECISION, ZOOM_PRECISION } from '../../../../common/constants'; + +import { getGlyphUrl, isRetina } from '../../../meta'; +import { + DECIMAL_DEGREES_PRECISION, + MAX_ZOOM, + MIN_ZOOM, + ZOOM_PRECISION, +} from '../../../../common/constants'; import mapboxgl from 'mapbox-gl/dist/mapbox-gl-csp'; import mbWorkerUrl from '!!file-loader!mapbox-gl/dist/mapbox-gl-csp-worker'; import mbRtlPlugin from '!!file-loader!@mapbox/mapbox-gl-rtl-text/mapbox-gl-rtl-text.min.js'; @@ -23,13 +28,9 @@ import sprites1 from '@elastic/maki/dist/sprite@1.png'; import sprites2 from '@elastic/maki/dist/sprite@2.png'; import { DrawControl } from './draw_control'; import { TooltipControl } from './tooltip_control'; -import { - clampToLatBounds, - clampToLonBounds, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../../../plugins/maps/public/elasticsearch_geo_utils'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getInjectedVarFunc } from '../../../../../../../plugins/maps/public/kibana_services'; +import { clampToLatBounds, clampToLonBounds } from '../../../elasticsearch_geo_utils'; + +import { getInjectedVarFunc } from '../../../kibana_services'; mapboxgl.workerUrl = mbWorkerUrl; mapboxgl.setRTLTextPlugin(mbRtlPlugin); @@ -132,6 +133,8 @@ export class MBMapContainer extends React.Component { scrollZoom: this.props.scrollZoom, preserveDrawingBuffer: getInjectedVarFunc()('preserveDrawingBuffer', false), interactive: !this.props.disableInteractive, + minZoom: MIN_ZOOM, + maxZoom: MAX_ZOOM, }; const initialView = _.get(this.props.goto, 'center'); if (initialView) { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/_index.scss b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/_index.scss similarity index 93% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/_index.scss rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/_index.scss index 01aea403b27f0..2754a3e204263 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/_index.scss +++ b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/_index.scss @@ -1,4 +1,4 @@ -@import './tools_control/index'; +@import 'tools_control/index'; .mapToolbarOverlay { position: absolute; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/index.js b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/index.js rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/set_view_control/index.js b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/set_view_control/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/set_view_control/index.js rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/set_view_control/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/set_view_control/set_view_control.js b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/set_view_control/set_view_control.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/set_view_control/set_view_control.js rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/set_view_control/set_view_control.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/toolbar_overlay.js b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/toolbar_overlay.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/toolbar_overlay.js rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/toolbar_overlay.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/__snapshots__/tools_control.test.js.snap b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/__snapshots__/tools_control.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/__snapshots__/tools_control.test.js.snap rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/__snapshots__/tools_control.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/_index.scss b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/_index.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/_index.scss rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/_index.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/index.js b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/index.js rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/tools_control.js b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/tools_control.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/tools_control.js rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/tools_control.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/tools_control.test.js b/x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/tools_control.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/toolbar_overlay/tools_control/tools_control.test.js rename to x-pack/plugins/maps/public/connected_components/toolbar_overlay/tools_control/tools_control.test.js diff --git a/x-pack/plugins/maps/public/connected_components/widget_overlay/_index.scss b/x-pack/plugins/maps/public/connected_components/widget_overlay/_index.scss new file mode 100644 index 0000000000000..5e5086bed2763 --- /dev/null +++ b/x-pack/plugins/maps/public/connected_components/widget_overlay/_index.scss @@ -0,0 +1,6 @@ +@import 'mixins'; + +@import 'widget_overlay'; +@import 'attribution_control/attribution_control'; +@import 'layer_control/index'; +@import 'view_control/view_control'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/_mixins.scss b/x-pack/plugins/maps/public/connected_components/widget_overlay/_mixins.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/_mixins.scss rename to x-pack/plugins/maps/public/connected_components/widget_overlay/_mixins.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/_widget_overlay.scss b/x-pack/plugins/maps/public/connected_components/widget_overlay/_widget_overlay.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/_widget_overlay.scss rename to x-pack/plugins/maps/public/connected_components/widget_overlay/_widget_overlay.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/__snapshots__/view.test.js.snap b/x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/__snapshots__/view.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/__snapshots__/view.test.js.snap rename to x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/__snapshots__/view.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/_attribution_control.scss b/x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/_attribution_control.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/_attribution_control.scss rename to x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/_attribution_control.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/index.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/index.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.test.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.test.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/attribution_control/view.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/index.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/index.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/__snapshots__/view.test.js.snap b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/__snapshots__/view.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/__snapshots__/view.test.js.snap rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/__snapshots__/view.test.js.snap diff --git a/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/_index.scss b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/_index.scss new file mode 100644 index 0000000000000..9a3e3a45d6c4e --- /dev/null +++ b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/_index.scss @@ -0,0 +1,2 @@ +@import 'layer_control'; +@import 'layer_toc/toc_entry/toc_entry'; diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/_layer_control.scss b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/_layer_control.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/_layer_control.scss rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/_layer_control.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js similarity index 90% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js index 04de5f71f5bfc..8780bac59e4b7 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js +++ b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/index.js @@ -6,8 +6,8 @@ import { connect } from 'react-redux'; import { LayerControl } from './view'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { FLYOUT_STATE } from '../../../../../../../plugins/maps/public/reducers/ui'; + +import { FLYOUT_STATE } from '../../../reducers/ui'; import { updateFlyout, setIsLayerTOCOpen } from '../../../actions/ui_actions'; import { setSelectedLayer } from '../../../actions/map_actions'; import { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/__snapshots__/view.test.js.snap b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/__snapshots__/view.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/__snapshots__/view.test.js.snap rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/__snapshots__/view.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/index.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/index.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/__snapshots__/view.test.js.snap b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/__snapshots__/view.test.js.snap similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/__snapshots__/view.test.js.snap rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/__snapshots__/view.test.js.snap diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/_toc_entry.scss b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/_toc_entry.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/_toc_entry.scss rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/_toc_entry.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js similarity index 93% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js index 588445d0b4992..ca3c6d325687d 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js +++ b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/index.js @@ -7,8 +7,8 @@ import _ from 'lodash'; import { connect } from 'react-redux'; import { TOCEntry } from './view'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { FLYOUT_STATE } from '../../../../../../../../../plugins/maps/public/reducers/ui'; + +import { FLYOUT_STATE } from '../../../../../reducers/ui'; import { updateFlyout, hideTOCDetails, showTOCDetails } from '../../../../../actions/ui_actions'; import { getIsReadOnly, getOpenTOCDetails } from '../../../../../selectors/ui_selectors'; import { diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/view.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/view.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/view.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/view.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/view.test.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/view.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/view.test.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/layer_toc/view.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/view.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/view.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/view.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/view.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/view.test.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/view.test.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/layer_control/view.test.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/layer_control/view.test.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/view_control/_view_control.scss b/x-pack/plugins/maps/public/connected_components/widget_overlay/view_control/_view_control.scss similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/view_control/_view_control.scss rename to x-pack/plugins/maps/public/connected_components/widget_overlay/view_control/_view_control.scss diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/view_control/index.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/view_control/index.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/view_control/index.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/view_control/index.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/view_control/view_control.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/view_control/view_control.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/view_control/view_control.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/view_control/view_control.js diff --git a/x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/widget_overlay.js b/x-pack/plugins/maps/public/connected_components/widget_overlay/widget_overlay.js similarity index 100% rename from x-pack/legacy/plugins/maps/public/connected_components/widget_overlay/widget_overlay.js rename to x-pack/plugins/maps/public/connected_components/widget_overlay/widget_overlay.js diff --git a/x-pack/plugins/maps/public/elasticsearch_geo_utils.js b/x-pack/plugins/maps/public/elasticsearch_geo_utils.js index 617cf537fd5c3..417c5d84f8916 100644 --- a/x-pack/plugins/maps/public/elasticsearch_geo_utils.js +++ b/x-pack/plugins/maps/public/elasticsearch_geo_utils.js @@ -64,7 +64,7 @@ function ensureGeometryType(type, expectedTypes) { * @param {string} geoFieldType Geometry field type ["geo_point", "geo_shape"] * @returns {number} */ -export function hitsToGeoJson(hits, flattenHit, geoFieldName, geoFieldType) { +export function hitsToGeoJson(hits, flattenHit, geoFieldName, geoFieldType, epochMillisFields) { const features = []; const tmpGeometriesAccumulator = []; @@ -80,6 +80,16 @@ export function hitsToGeoJson(hits, flattenHit, geoFieldName, geoFieldType) { geoShapeToGeometry(properties[geoFieldName], tmpGeometriesAccumulator); } + // There is a bug in Elasticsearch API where epoch_millis are returned as a string instead of a number + // https://github.com/elastic/elasticsearch/issues/50622 + // Convert these field values to integers. + for (let i = 0; i < epochMillisFields.length; i++) { + const fieldName = epochMillisFields[i]; + if (typeof properties[fieldName] === 'string') { + properties[fieldName] = parseInt(properties[fieldName]); + } + } + // don't include geometry field value in properties delete properties[geoFieldName]; diff --git a/x-pack/plugins/maps/public/elasticsearch_geo_utils.test.js b/x-pack/plugins/maps/public/elasticsearch_geo_utils.test.js index 5db7556be4639..fc02e19173843 100644 --- a/x-pack/plugins/maps/public/elasticsearch_geo_utils.test.js +++ b/x-pack/plugins/maps/public/elasticsearch_geo_utils.test.js @@ -66,7 +66,7 @@ describe('hitsToGeoJson', () => { }, }, ]; - const geojson = hitsToGeoJson(hits, flattenHitMock, geoFieldName, 'geo_point'); + const geojson = hitsToGeoJson(hits, flattenHitMock, geoFieldName, 'geo_point', []); expect(geojson.type).toBe('FeatureCollection'); expect(geojson.features.length).toBe(2); expect(geojson.features[0]).toEqual({ @@ -94,7 +94,7 @@ describe('hitsToGeoJson', () => { _source: {}, }, ]; - const geojson = hitsToGeoJson(hits, flattenHitMock, geoFieldName, 'geo_point'); + const geojson = hitsToGeoJson(hits, flattenHitMock, geoFieldName, 'geo_point', []); expect(geojson.type).toBe('FeatureCollection'); expect(geojson.features.length).toBe(1); }); @@ -111,7 +111,7 @@ describe('hitsToGeoJson', () => { }, }, ]; - const geojson = hitsToGeoJson(hits, flattenHitMock, geoFieldName, 'geo_point'); + const geojson = hitsToGeoJson(hits, flattenHitMock, geoFieldName, 'geo_point', []); expect(geojson.features.length).toBe(1); const feature = geojson.features[0]; expect(feature.properties.myField).toBe(8); @@ -128,7 +128,7 @@ describe('hitsToGeoJson', () => { }, }, ]; - const geojson = hitsToGeoJson(hits, flattenHitMock, geoFieldName, 'geo_point'); + const geojson = hitsToGeoJson(hits, flattenHitMock, geoFieldName, 'geo_point', []); expect(geojson.type).toBe('FeatureCollection'); expect(geojson.features.length).toBe(2); expect(geojson.features[0]).toEqual({ @@ -159,6 +159,23 @@ describe('hitsToGeoJson', () => { }); }); + it('Should convert epoch_millis value from string to integer', () => { + const hits = [ + { + _id: 'doc1', + _index: 'index1', + _source: { + [geoFieldName]: '20,100', + myDateField: '1587156257081', + }, + }, + ]; + const geojson = hitsToGeoJson(hits, flattenHitMock, geoFieldName, 'geo_point', ['myDateField']); + expect(geojson.type).toBe('FeatureCollection'); + expect(geojson.features.length).toBe(1); + expect(geojson.features[0].properties.myDateField).toBe(1587156257081); + }); + describe('dot in geoFieldName', () => { const indexPatternMock = { fields: { @@ -184,7 +201,7 @@ describe('hitsToGeoJson', () => { }, }, ]; - const geojson = hitsToGeoJson(hits, indexPatternFlattenHit, 'my.location', 'geo_point'); + const geojson = hitsToGeoJson(hits, indexPatternFlattenHit, 'my.location', 'geo_point', []); expect(geojson.features[0].geometry).toEqual({ coordinates: [100, 20], type: 'Point', @@ -199,7 +216,7 @@ describe('hitsToGeoJson', () => { }, }, ]; - const geojson = hitsToGeoJson(hits, indexPatternFlattenHit, 'my.location', 'geo_point'); + const geojson = hitsToGeoJson(hits, indexPatternFlattenHit, 'my.location', 'geo_point', []); expect(geojson.features[0].geometry).toEqual({ coordinates: [100, 20], type: 'Point', diff --git a/x-pack/legacy/plugins/maps/public/embeddable/README.md b/x-pack/plugins/maps/public/embeddable/README.md similarity index 100% rename from x-pack/legacy/plugins/maps/public/embeddable/README.md rename to x-pack/plugins/maps/public/embeddable/README.md diff --git a/x-pack/legacy/plugins/maps/public/embeddable/index.ts b/x-pack/plugins/maps/public/embeddable/index.ts similarity index 100% rename from x-pack/legacy/plugins/maps/public/embeddable/index.ts rename to x-pack/plugins/maps/public/embeddable/index.ts diff --git a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.tsx b/x-pack/plugins/maps/public/embeddable/map_embeddable.tsx similarity index 90% rename from x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.tsx rename to x-pack/plugins/maps/public/embeddable/map_embeddable.tsx index b8e4c84ad56a1..dbd48d614e99b 100644 --- a/x-pack/legacy/plugins/maps/public/embeddable/map_embeddable.tsx +++ b/x-pack/plugins/maps/public/embeddable/map_embeddable.tsx @@ -9,8 +9,6 @@ import React from 'react'; import { Provider } from 'react-redux'; import { render, unmountComponentAtNode } from 'react-dom'; import 'mapbox-gl/dist/mapbox-gl.css'; - -import { I18nContext } from 'ui/i18n'; import { Subscription } from 'rxjs'; import { Unsubscribe } from 'redux'; import { @@ -18,8 +16,8 @@ import { IContainer, EmbeddableInput, EmbeddableOutput, -} from '../../../../../../src/plugins/embeddable/public'; -import { APPLY_FILTER_TRIGGER } from '../../../../../../src/plugins/ui_actions/public'; +} from '../../../../../src/plugins/embeddable/public'; +import { APPLY_FILTER_TRIGGER } from '../../../../../src/plugins/ui_actions/public'; import { esFilters, IIndexPattern, @@ -27,11 +25,9 @@ import { Filter, Query, RefreshInterval, -} from '../../../../../../src/plugins/data/public'; - +} from '../../../../../src/plugins/data/public'; import { GisMap } from '../connected_components/gis_map'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { createMapStore, MapStore } from '../../../../../plugins/maps/public/reducers/store'; +import { createMapStore, MapStore } from '../reducers/store'; import { setGotoWithCenter, replaceLayerList, @@ -45,21 +41,18 @@ import { hideViewControl, setHiddenLayers, } from '../actions/map_actions'; -import { MapCenterAndZoom } from '../../../../../plugins/maps/common/descriptor_types'; +import { MapCenterAndZoom } from '../../common/descriptor_types'; import { setReadOnly, setIsLayerTOCOpen, setOpenTOCDetails } from '../actions/ui_actions'; import { getIsLayerTOCOpen, getOpenTOCDetails } from '../selectors/ui_selectors'; import { getInspectorAdapters, setEventHandlers, EventHandlers, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../plugins/maps/public/reducers/non_serializable_instances'; +} from '../reducers/non_serializable_instances'; import { getMapCenter, getMapZoom, getHiddenLayerIds } from '../selectors/map_selectors'; import { MAP_SAVED_OBJECT_TYPE } from '../../common/constants'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { RenderToolTipContent } from '../../../../../plugins/maps/public/layers/tooltips/tooltip_property'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getUiActions } from '../../../../../plugins/maps/public/kibana_services'; +import { RenderToolTipContent } from '../layers/tooltips/tooltip_property'; +import { getUiActions, getCoreI18n } from '../kibana_services'; interface MapEmbeddableConfig { editUrl?: string; @@ -247,6 +240,8 @@ export class MapEmbeddable extends Embeddable diff --git a/x-pack/plugins/maps/public/embeddable/map_embeddable_factory.ts b/x-pack/plugins/maps/public/embeddable/map_embeddable_factory.ts new file mode 100644 index 0000000000000..a99fe63c5f386 --- /dev/null +++ b/x-pack/plugins/maps/public/embeddable/map_embeddable_factory.ts @@ -0,0 +1,136 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import _ from 'lodash'; +import { i18n } from '@kbn/i18n'; +import { IIndexPattern } from 'src/plugins/data/public'; +// @ts-ignore +import { getMapsSavedObjectLoader } from '../angular/services/gis_map_saved_object_loader'; +import { MapEmbeddable, MapEmbeddableInput } from './map_embeddable'; +import { getIndexPatternService, getHttp, getMapsCapabilities } from '../kibana_services'; +import { + EmbeddableFactoryDefinition, + IContainer, +} from '../../../../../src/plugins/embeddable/public'; + +import { createMapPath, MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants'; + +import { createMapStore } from '../reducers/store'; +import { addLayerWithoutDataSync } from '../actions/map_actions'; +import { getQueryableUniqueIndexPatternIds } from '../selectors/map_selectors'; +import { getInitialLayers } from '../angular/get_initial_layers'; +import { mergeInputWithSavedMap } from './merge_input_with_saved_map'; + +export class MapEmbeddableFactory implements EmbeddableFactoryDefinition { + type = MAP_SAVED_OBJECT_TYPE; + savedObjectMetaData = { + name: i18n.translate('xpack.maps.mapSavedObjectLabel', { + defaultMessage: 'Map', + }), + type: MAP_SAVED_OBJECT_TYPE, + getIconForSavedObject: () => APP_ICON, + }; + + async isEditable() { + return getMapsCapabilities().save as boolean; + } + + // Not supported yet for maps types. + canCreateNew() { + return false; + } + + getDisplayName() { + return i18n.translate('xpack.maps.embeddableDisplayName', { + defaultMessage: 'map', + }); + } + + async _getIndexPatterns(layerList: unknown[]): Promise { + // Need to extract layerList from store to get queryable index pattern ids + const store = createMapStore(); + let queryableIndexPatternIds; + try { + layerList.forEach((layerDescriptor: unknown) => { + store.dispatch(addLayerWithoutDataSync(layerDescriptor)); + }); + queryableIndexPatternIds = getQueryableUniqueIndexPatternIds(store.getState()); + } catch (error) { + throw new Error( + i18n.translate('xpack.maps.mapEmbeddableFactory.invalidLayerList', { + defaultMessage: 'Unable to load map, malformed layer list', + }) + ); + } + + const promises = queryableIndexPatternIds.map(async indexPatternId => { + try { + return await getIndexPatternService().get(indexPatternId); + } catch (error) { + // Unable to load index pattern, better to not throw error so map embeddable can render + // Error will be surfaced by map embeddable since it too will be unable to locate the index pattern + return null; + } + }); + const indexPatterns = await Promise.all(promises); + return _.compact(indexPatterns) as IIndexPattern[]; + } + + async _fetchSavedMap(savedObjectId: string) { + const savedObjectLoader = getMapsSavedObjectLoader(); + return await savedObjectLoader.get(savedObjectId); + } + + createFromSavedObject = async ( + savedObjectId: string, + input: MapEmbeddableInput, + parent?: IContainer + ) => { + const savedMap = await this._fetchSavedMap(savedObjectId); + const layerList = getInitialLayers(savedMap.layerListJSON); + const indexPatterns = await this._getIndexPatterns(layerList); + + const embeddable = new MapEmbeddable( + { + layerList, + title: savedMap.title, + editUrl: getHttp().basePath.prepend(createMapPath(savedObjectId)), + indexPatterns, + editable: await this.isEditable(), + }, + input, + parent + ); + + try { + embeddable.updateInput(mergeInputWithSavedMap(input, savedMap)); + } catch (error) { + throw new Error( + i18n.translate('xpack.maps.mapEmbeddableFactory.invalidSavedObject', { + defaultMessage: 'Unable to load map, malformed saved object', + }) + ); + } + + return embeddable; + }; + + create = async (input: MapEmbeddableInput, parent?: IContainer) => { + const layerList = getInitialLayers(); + const indexPatterns = await this._getIndexPatterns(layerList); + + return new MapEmbeddable( + { + layerList, + title: input.title ?? '', + indexPatterns, + editable: false, + }, + input, + parent + ); + }; +} diff --git a/x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.d.ts b/x-pack/plugins/maps/public/embeddable/merge_input_with_saved_map.d.ts similarity index 100% rename from x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.d.ts rename to x-pack/plugins/maps/public/embeddable/merge_input_with_saved_map.d.ts diff --git a/x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.js b/x-pack/plugins/maps/public/embeddable/merge_input_with_saved_map.js similarity index 89% rename from x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.js rename to x-pack/plugins/maps/public/embeddable/merge_input_with_saved_map.js index 8e3e0a9168e30..d91c91b3b223c 100644 --- a/x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.js +++ b/x-pack/plugins/maps/public/embeddable/merge_input_with_saved_map.js @@ -5,8 +5,8 @@ */ import _ from 'lodash'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { DEFAULT_IS_LAYER_TOC_OPEN } from '../../../../../plugins/maps/public/reducers/ui'; + +import { DEFAULT_IS_LAYER_TOC_OPEN } from '../reducers/ui'; const MAP_EMBEDDABLE_INPUT_KEYS = [ 'hideFilterActions', diff --git a/x-pack/legacy/plugins/maps/public/feature_catalogue_entry.ts b/x-pack/plugins/maps/public/feature_catalogue_entry.ts similarity index 89% rename from x-pack/legacy/plugins/maps/public/feature_catalogue_entry.ts rename to x-pack/plugins/maps/public/feature_catalogue_entry.ts index fdda76b4e1212..6c2579bd3e4e2 100644 --- a/x-pack/legacy/plugins/maps/public/feature_catalogue_entry.ts +++ b/x-pack/plugins/maps/public/feature_catalogue_entry.ts @@ -6,7 +6,7 @@ import { i18n } from '@kbn/i18n'; import { APP_ID, APP_ICON } from '../common/constants'; import { getAppTitle } from '../common/i18n_getters'; -import { FeatureCatalogueCategory } from '../../../../../src/plugins/home/public'; +import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; export const featureCatalogueEntry = { id: APP_ID, diff --git a/x-pack/legacy/plugins/maps/public/help_menu_util.js b/x-pack/plugins/maps/public/help_menu_util.js similarity index 81% rename from x-pack/legacy/plugins/maps/public/help_menu_util.js rename to x-pack/plugins/maps/public/help_menu_util.js index 70b9340b562cd..053caf6688309 100644 --- a/x-pack/legacy/plugins/maps/public/help_menu_util.js +++ b/x-pack/plugins/maps/public/help_menu_util.js @@ -3,8 +3,8 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getDocLinks, getCoreChrome } from '../../../../plugins/maps/public/kibana_services'; + +import { getDocLinks, getCoreChrome } from './kibana_services'; export function addHelpMenuToAppChrome() { const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = getDocLinks(); diff --git a/x-pack/legacy/plugins/maps/public/icon.svg b/x-pack/plugins/maps/public/icon.svg similarity index 100% rename from x-pack/legacy/plugins/maps/public/icon.svg rename to x-pack/plugins/maps/public/icon.svg diff --git a/x-pack/plugins/maps/public/index.scss b/x-pack/plugins/maps/public/index.scss new file mode 100644 index 0000000000000..8b2f6d3cb6156 --- /dev/null +++ b/x-pack/plugins/maps/public/index.scss @@ -0,0 +1,17 @@ +/* GIS plugin styles */ + +// Import the EUI global scope so we can use EUI constants +@import 'src/legacy/ui/public/styles/_styling_constants'; + +// Prefix all styles with "map" to avoid conflicts. +// Examples +// mapChart +// mapChart__legend +// mapChart__legend--small +// mapChart__legend-isLoading + +@import 'main'; +@import 'mapbox_hacks'; +@import 'connected_components/index'; +@import 'components/index'; +@import 'layers/index'; diff --git a/x-pack/plugins/maps/public/kibana_services.js b/x-pack/plugins/maps/public/kibana_services.js index 2a79314380330..dcbd54a09381f 100644 --- a/x-pack/plugins/maps/public/kibana_services.js +++ b/x-pack/plugins/maps/public/kibana_services.js @@ -38,7 +38,9 @@ export const getFileUploadComponent = () => { }; let getInjectedVar; -export const setInjectedVarFunc = getInjectedVarFunc => (getInjectedVar = getInjectedVarFunc); +export const setInjectedVarFunc = getInjectedVarFunc => { + getInjectedVar = getInjectedVarFunc; +}; export const getInjectedVarFunc = () => getInjectedVar; let uiSettings; diff --git a/x-pack/plugins/maps/public/layers/joins/inner_join.test.js b/x-pack/plugins/maps/public/layers/joins/inner_join.test.js index 65c37860ffa18..f197a67becfae 100644 --- a/x-pack/plugins/maps/public/layers/joins/inner_join.test.js +++ b/x-pack/plugins/maps/public/layers/joins/inner_join.test.js @@ -35,7 +35,7 @@ const leftJoin = new InnerJoin( }, mockSource ); -const COUNT_PROPERTY_NAME = '__kbnjoin__count_groupby_kibana_sample_data_logs.geo.dest'; +const COUNT_PROPERTY_NAME = '__kbnjoin__count__d3625663-5b34-4d50-a784-0d743f676a0c'; describe('joinPropertiesToFeature', () => { it('Should add join property to features in feature collection', () => { diff --git a/x-pack/plugins/maps/public/layers/layer.d.ts b/x-pack/plugins/maps/public/layers/layer.d.ts index 8fb69734d3d06..e8fc5d473626c 100644 --- a/x-pack/plugins/maps/public/layers/layer.d.ts +++ b/x-pack/plugins/maps/public/layers/layer.d.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { LayerDescriptor, MapExtent, MapFilters } from '../../common/descriptor_types'; +import { LayerDescriptor, MapExtent, MapFilters, MapQuery } from '../../common/descriptor_types'; import { ISource } from './sources/source'; import { DataRequest } from './util/data_request'; import { SyncContext } from '../actions/map_actions'; @@ -17,6 +17,11 @@ export interface ILayer { getSource(): ISource; getSourceForEditing(): ISource; syncData(syncContext: SyncContext): Promise; + isVisible(): boolean; + showAtZoomLevel(zoomLevel: number): boolean; + getMinZoom(): number; + getMaxZoom(): number; + getMinSourceZoom(): number; } export interface ILayerArguments { @@ -35,4 +40,12 @@ export class AbstractLayer implements ILayer { getSource(): ISource; getSourceForEditing(): ISource; syncData(syncContext: SyncContext): Promise; + isVisible(): boolean; + showAtZoomLevel(zoomLevel: number): boolean; + getMinZoom(): number; + getMaxZoom(): number; + getMinSourceZoom(): number; + getQuery(): MapQuery; + _removeStaleMbSourcesAndLayers(mbMap: unknown): void; + _requiresPrevSourceCleanup(mbMap: unknown): boolean; } diff --git a/x-pack/plugins/maps/public/layers/layer.js b/x-pack/plugins/maps/public/layers/layer.js index 26bce872b3c2c..9362ce2c028e6 100644 --- a/x-pack/plugins/maps/public/layers/layer.js +++ b/x-pack/plugins/maps/public/layers/layer.js @@ -14,7 +14,7 @@ import { SOURCE_DATA_ID_ORIGIN, } from '../../common/constants'; import uuid from 'uuid/v4'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths + import { copyPersistentState } from '../reducers/util.js'; import { i18n } from '@kbn/i18n'; @@ -141,7 +141,8 @@ export class AbstractLayer { defaultMessage: `Layer is hidden.`, }); } else if (!this.showAtZoomLevel(zoomLevel)) { - const { minZoom, maxZoom } = this.getZoomConfig(); + const minZoom = this.getMinZoom(); + const maxZoom = this.getMaxZoom(); icon = ; tooltipContent = i18n.translate('xpack.maps.layer.zoomFeedbackTooltip', { defaultMessage: `Layer is visible between zoom levels {minZoom} and {maxZoom}.`, @@ -203,7 +204,7 @@ export class AbstractLayer { } showAtZoomLevel(zoom) { - return zoom >= this._descriptor.minZoom && zoom <= this._descriptor.maxZoom; + return zoom >= this.getMinZoom() && zoom <= this.getMaxZoom(); } getMinZoom() { @@ -214,6 +215,30 @@ export class AbstractLayer { return this._descriptor.maxZoom; } + getMinSourceZoom() { + return this._source.getMinZoom(); + } + + _requiresPrevSourceCleanup() { + return false; + } + + _removeStaleMbSourcesAndLayers(mbMap) { + if (this._requiresPrevSourceCleanup(mbMap)) { + const mbStyle = mbMap.getStyle(); + mbStyle.layers.forEach(mbLayer => { + if (this.ownsMbLayerId(mbLayer.id)) { + mbMap.removeLayer(mbLayer.id); + } + }); + Object.keys(mbStyle.sources).some(mbSourceId => { + if (this.ownsMbSourceId(mbSourceId)) { + mbMap.removeSource(mbSourceId); + } + }); + } + } + getAlpha() { return this._descriptor.alpha; } @@ -222,13 +247,6 @@ export class AbstractLayer { return this._descriptor.query; } - getZoomConfig() { - return { - minZoom: this._descriptor.minZoom, - maxZoom: this._descriptor.maxZoom, - }; - } - getCurrentStyle() { return this._style; } diff --git a/x-pack/plugins/maps/public/layers/load_layer_wizards.js b/x-pack/plugins/maps/public/layers/load_layer_wizards.js deleted file mode 100644 index d0169165eaa35..0000000000000 --- a/x-pack/plugins/maps/public/layers/load_layer_wizards.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { registerLayerWizard } from './layer_wizard_registry'; -import { uploadLayerWizardConfig } from './sources/client_file_source'; -import { esDocumentsLayerWizardConfig } from './sources/es_search_source'; -import { clustersLayerWizardConfig, heatmapLayerWizardConfig } from './sources/es_geo_grid_source'; -import { point2PointLayerWizardConfig } from './sources/es_pew_pew_source/es_pew_pew_source'; -import { emsBoundariesLayerWizardConfig } from './sources/ems_file_source'; -import { emsBaseMapLayerWizardConfig } from './sources/ems_tms_source'; -import { kibanaRegionMapLayerWizardConfig } from './sources/kibana_regionmap_source'; -import { kibanaBasemapLayerWizardConfig } from './sources/kibana_tilemap_source'; -import { tmsLayerWizardConfig } from './sources/xyz_tms_source'; -import { wmsLayerWizardConfig } from './sources/wms_source'; - -// Registration order determines display order -registerLayerWizard(uploadLayerWizardConfig); -registerLayerWizard(esDocumentsLayerWizardConfig); -registerLayerWizard(clustersLayerWizardConfig); -registerLayerWizard(heatmapLayerWizardConfig); -registerLayerWizard(point2PointLayerWizardConfig); -registerLayerWizard(emsBoundariesLayerWizardConfig); -registerLayerWizard(emsBaseMapLayerWizardConfig); -registerLayerWizard(kibanaRegionMapLayerWizardConfig); -registerLayerWizard(kibanaBasemapLayerWizardConfig); -registerLayerWizard(tmsLayerWizardConfig); -registerLayerWizard(wmsLayerWizardConfig); diff --git a/x-pack/plugins/maps/public/layers/load_layer_wizards.ts b/x-pack/plugins/maps/public/layers/load_layer_wizards.ts new file mode 100644 index 0000000000000..49d128257fe20 --- /dev/null +++ b/x-pack/plugins/maps/public/layers/load_layer_wizards.ts @@ -0,0 +1,66 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { registerLayerWizard } from './layer_wizard_registry'; +// @ts-ignore +import { uploadLayerWizardConfig } from './sources/client_file_source'; +// @ts-ignore +import { esDocumentsLayerWizardConfig } from './sources/es_search_source'; +// @ts-ignore +import { clustersLayerWizardConfig, heatmapLayerWizardConfig } from './sources/es_geo_grid_source'; +// @ts-ignore +import { point2PointLayerWizardConfig } from './sources/es_pew_pew_source/es_pew_pew_source'; +// @ts-ignore +import { emsBoundariesLayerWizardConfig } from './sources/ems_file_source'; +// @ts-ignore +import { emsBaseMapLayerWizardConfig } from './sources/ems_tms_source'; +// @ts-ignore +import { kibanaRegionMapLayerWizardConfig } from './sources/kibana_regionmap_source'; +// @ts-ignore +import { kibanaBasemapLayerWizardConfig } from './sources/kibana_tilemap_source'; +import { tmsLayerWizardConfig } from './sources/xyz_tms_source'; +// @ts-ignore +import { wmsLayerWizardConfig } from './sources/wms_source'; +import { mvtVectorSourceWizardConfig } from './sources/mvt_single_layer_vector_source'; +// @ts-ignore +import { getInjectedVarFunc } from '../kibana_services'; + +// Registration order determines display order +let registered = false; +export function registerLayerWizards() { + if (registered) { + return; + } + // @ts-ignore + registerLayerWizard(uploadLayerWizardConfig); + // @ts-ignore + registerLayerWizard(esDocumentsLayerWizardConfig); + // @ts-ignore + registerLayerWizard(clustersLayerWizardConfig); + // @ts-ignore + registerLayerWizard(heatmapLayerWizardConfig); + // @ts-ignore + registerLayerWizard(point2PointLayerWizardConfig); + // @ts-ignore + registerLayerWizard(emsBoundariesLayerWizardConfig); + // @ts-ignore + registerLayerWizard(emsBaseMapLayerWizardConfig); + // @ts-ignore + registerLayerWizard(kibanaRegionMapLayerWizardConfig); + // @ts-ignore + registerLayerWizard(kibanaBasemapLayerWizardConfig); + registerLayerWizard(tmsLayerWizardConfig); + // @ts-ignore + registerLayerWizard(wmsLayerWizardConfig); + + const getInjectedVar = getInjectedVarFunc(); + if (getInjectedVar && getInjectedVar('enableVectorTiles', false)) { + // eslint-disable-next-line no-console + console.warn('Vector tiles are an experimental feature and should not be used in production.'); + registerLayerWizard(mvtVectorSourceWizardConfig); + } + registered = true; +} diff --git a/x-pack/plugins/maps/public/layers/sources/es_agg_source/es_agg_source.js b/x-pack/plugins/maps/public/layers/sources/es_agg_source/es_agg_source.js index c6197f137f212..58c56fe32f766 100644 --- a/x-pack/plugins/maps/public/layers/sources/es_agg_source/es_agg_source.js +++ b/x-pack/plugins/maps/public/layers/sources/es_agg_source/es_agg_source.js @@ -7,16 +7,14 @@ import { i18n } from '@kbn/i18n'; import { AbstractESSource } from '../es_source'; import { esAggFieldsFactory } from '../../fields/es_agg_field'; - import { + AGG_DELIMITER, AGG_TYPE, COUNT_PROP_LABEL, COUNT_PROP_NAME, FIELD_ORIGIN, } from '../../../../common/constants'; -export const AGG_DELIMITER = '_of_'; - export class AbstractESAggSource extends AbstractESSource { constructor(descriptor, inspectorAdapters) { super(descriptor, inspectorAdapters); diff --git a/x-pack/plugins/maps/public/layers/sources/es_geo_grid_source/es_geo_grid_source.d.ts b/x-pack/plugins/maps/public/layers/sources/es_geo_grid_source/es_geo_grid_source.d.ts index 3f596cea1ae39..96347c444dd5b 100644 --- a/x-pack/plugins/maps/public/layers/sources/es_geo_grid_source/es_geo_grid_source.d.ts +++ b/x-pack/plugins/maps/public/layers/sources/es_geo_grid_source/es_geo_grid_source.d.ts @@ -23,6 +23,7 @@ export class ESGeoGridSource extends AbstractESAggSource { constructor(sourceDescriptor: ESGeoGridSourceDescriptor, inspectorAdapters: unknown); + getFieldNames(): string[]; getGridResolution(): GRID_RESOLUTION; getGeoGridPrecision(zoom: number): number; } diff --git a/x-pack/plugins/maps/public/layers/sources/es_search_source/es_search_source.d.ts b/x-pack/plugins/maps/public/layers/sources/es_search_source/es_search_source.d.ts index 0a4e48a195ec6..c904280a38c85 100644 --- a/x-pack/plugins/maps/public/layers/sources/es_search_source/es_search_source.d.ts +++ b/x-pack/plugins/maps/public/layers/sources/es_search_source/es_search_source.d.ts @@ -9,4 +9,5 @@ import { ESSearchSourceDescriptor } from '../../../../common/descriptor_types'; export class ESSearchSource extends AbstractESSource { constructor(sourceDescriptor: Partial, inspectorAdapters: unknown); + getFieldNames(): string[]; } diff --git a/x-pack/plugins/maps/public/layers/sources/es_search_source/es_search_source.js b/x-pack/plugins/maps/public/layers/sources/es_search_source/es_search_source.js index 96679f0e85941..aaa56b30c735a 100644 --- a/x-pack/plugins/maps/public/layers/sources/es_search_source/es_search_source.js +++ b/x-pack/plugins/maps/public/layers/sources/es_search_source/es_search_source.js @@ -51,7 +51,7 @@ function getDocValueAndSourceFields(indexPattern, fieldNames) { lang: field.lang, }, }; - } else if (field.readFromDocValues) { + } else if (field.type !== ES_GEO_FIELD_TYPE.GEO_SHAPE && field.readFromDocValues) { const docValueField = field.type === 'date' ? { @@ -387,11 +387,21 @@ export class ESSearchSource extends AbstractESSource { }); return properties; }; + const epochMillisFields = searchFilters.fieldNames.filter(fieldName => { + const field = getField(indexPattern, fieldName); + return field.readFromDocValues && field.type === 'date'; + }); let featureCollection; try { const geoField = await this._getGeoField(); - featureCollection = hitsToGeoJson(hits, flattenHit, geoField.name, geoField.type); + featureCollection = hitsToGeoJson( + hits, + flattenHit, + geoField.name, + geoField.type, + epochMillisFields + ); } catch (error) { throw new Error( i18n.translate('xpack.maps.source.esSearch.convertToGeoJsonErrorMsg', { diff --git a/x-pack/plugins/maps/public/layers/sources/es_source/es_source.js b/x-pack/plugins/maps/public/layers/sources/es_source/es_source.js index 3402e367cbd73..9ab87577b7780 100644 --- a/x-pack/plugins/maps/public/layers/sources/es_source/es_source.js +++ b/x-pack/plugins/maps/public/layers/sources/es_source/es_source.js @@ -16,7 +16,7 @@ import { createExtentFilter } from '../../../elasticsearch_geo_utils'; import _ from 'lodash'; import { i18n } from '@kbn/i18n'; import uuid from 'uuid/v4'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths + import { copyPersistentState } from '../../../reducers/util'; import { ES_GEO_FIELD_TYPE } from '../../../../common/constants'; import { DataRequestAbortError } from '../../util/data_request'; diff --git a/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.js b/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.js index 826197cc4fec7..cb07bb0e7d2ed 100644 --- a/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.js +++ b/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.js @@ -7,15 +7,14 @@ import _ from 'lodash'; import { i18n } from '@kbn/i18n'; -import { DEFAULT_MAX_BUCKETS_LIMIT, FIELD_ORIGIN, AGG_TYPE } from '../../../../common/constants'; +import { AGG_TYPE, DEFAULT_MAX_BUCKETS_LIMIT, FIELD_ORIGIN } from '../../../../common/constants'; +import { getJoinAggKey } from '../../../../common/get_join_key'; import { ESDocField } from '../../fields/es_doc_field'; -import { AbstractESAggSource, AGG_DELIMITER } from '../es_agg_source'; +import { AbstractESAggSource } from '../es_agg_source'; import { getField, addFieldToDSL, extractPropertiesFromBucket } from '../../util/es_agg_utils'; const TERMS_AGG_NAME = 'join'; -const FIELD_NAME_PREFIX = '__kbnjoin__'; -const GROUP_BY_DELIMITER = '_groupby_'; const TERMS_BUCKET_KEYS_TO_IGNORE = ['key', 'doc_count']; export function extractPropertiesMap(rawEsData, countPropertyName) { @@ -64,11 +63,11 @@ export class ESTermSource extends AbstractESAggSource { } getAggKey(aggType, fieldName) { - const metricKey = - aggType !== AGG_TYPE.COUNT ? `${aggType}${AGG_DELIMITER}${fieldName}` : aggType; - return `${FIELD_NAME_PREFIX}${metricKey}${GROUP_BY_DELIMITER}${ - this._descriptor.indexPatternTitle - }.${this._termField.getName()}`; + return getJoinAggKey({ + aggType, + aggFieldName: fieldName, + rightSourceId: this._descriptor.id, + }); } getAggLabel(aggType, fieldName) { diff --git a/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.test.js b/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.test.js index b6cd3b670d3ce..14eb39180a6b8 100644 --- a/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.test.js +++ b/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.test.js @@ -32,33 +32,32 @@ const metricExamples = [ describe('getMetricFields', () => { it('should override name and label of count metric', async () => { const source = new ESTermSource({ + id: '1234', indexPatternTitle: indexPatternTitle, term: termFieldName, }); const metrics = source.getMetricFields(); - expect(metrics[0].getName()).toEqual('__kbnjoin__count_groupby_myIndex.myTermField'); + expect(metrics[0].getName()).toEqual('__kbnjoin__count__1234'); expect(await metrics[0].getLabel()).toEqual('Count of myIndex'); }); it('should override name and label of sum metric', async () => { const source = new ESTermSource({ + id: '1234', indexPatternTitle: indexPatternTitle, term: termFieldName, metrics: metricExamples, }); const metrics = source.getMetricFields(); - expect(metrics[0].getName()).toEqual( - '__kbnjoin__sum_of_myFieldGettingSummed_groupby_myIndex.myTermField' - ); + expect(metrics[0].getName()).toEqual('__kbnjoin__sum_of_myFieldGettingSummed__1234'); expect(await metrics[0].getLabel()).toEqual('my custom label'); - expect(metrics[1].getName()).toEqual('__kbnjoin__count_groupby_myIndex.myTermField'); + expect(metrics[1].getName()).toEqual('__kbnjoin__count__1234'); expect(await metrics[1].getLabel()).toEqual('Count of myIndex'); }); }); describe('extractPropertiesMap', () => { - const minPropName = - '__kbnjoin__min_of_avlAirTemp_groupby_kibana_sample_data_ky_avl.kytcCountyNmbr'; + const minPropName = '__kbnjoin__min_of_avlAirTemp__1234'; const responseWithNumberTypes = { aggregations: { join: { @@ -81,7 +80,7 @@ describe('extractPropertiesMap', () => { }, }, }; - const countPropName = '__kbnjoin__count_groupby_kibana_sample_data_ky_avl.kytcCountyNmbr'; + const countPropName = '__kbnjoin__count__1234'; let propertiesMap; beforeAll(() => { diff --git a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/index.ts b/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/index.ts similarity index 74% rename from x-pack/plugins/snapshot_restore/public/application/lib/authorization/index.ts rename to x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/index.ts index 73bbde465146c..89b7e76a7e359 100644 --- a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/index.ts +++ b/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/index.ts @@ -4,4 +4,5 @@ * you may not use this file except in compliance with the Elastic License. */ -export * from './components'; +export * from './mvt_single_layer_vector_source'; +export * from './layer_wizard'; diff --git a/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/layer_wizard.tsx b/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/layer_wizard.tsx new file mode 100644 index 0000000000000..dfdea1489d50c --- /dev/null +++ b/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/layer_wizard.tsx @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; +import React from 'react'; +import { + MVTSingleLayerVectorSourceEditor, + MVTSingleLayerVectorSourceConfig, +} from './mvt_single_layer_vector_source_editor'; +import { MVTSingleLayerVectorSource, sourceTitle } from './mvt_single_layer_vector_source'; +import { LayerWizard, RenderWizardArguments } from '../../layer_wizard_registry'; +import { SOURCE_TYPES } from '../../../../common/constants'; + +export const mvtVectorSourceWizardConfig: LayerWizard = { + description: i18n.translate('xpack.maps.source.mvtVectorSourceWizard', { + defaultMessage: 'Vector source wizard', + }), + icon: 'grid', + renderWizard: ({ onPreviewSource, inspectorAdapters }: RenderWizardArguments) => { + const onSourceConfigChange = ({ + urlTemplate, + layerName, + minSourceZoom, + maxSourceZoom, + }: MVTSingleLayerVectorSourceConfig) => { + const sourceDescriptor = MVTSingleLayerVectorSource.createDescriptor({ + urlTemplate, + layerName, + minSourceZoom, + maxSourceZoom, + type: SOURCE_TYPES.MVT_SINGLE_LAYER, + }); + const source = new MVTSingleLayerVectorSource(sourceDescriptor, inspectorAdapters); + onPreviewSource(source); + }; + return ; + }, + title: sourceTitle, +}; diff --git a/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.ts b/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.ts new file mode 100644 index 0000000000000..0bfda6be72203 --- /dev/null +++ b/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source.ts @@ -0,0 +1,175 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; +import uuid from 'uuid/v4'; +import { AbstractSource, ImmutableSourceProperty } from '../source'; +import { TiledVectorLayer } from '../../tiled_vector_layer'; +import { GeoJsonWithMeta, ITiledSingleLayerVectorSource } from '../vector_source'; +import { MAX_ZOOM, MIN_ZOOM, SOURCE_TYPES } from '../../../../common/constants'; +import { VECTOR_SHAPE_TYPES } from '../vector_feature_types'; +import { IField } from '../../fields/field'; +import { registerSource } from '../source_registry'; +import { getDataSourceLabel, getUrlLabel } from '../../../../common/i18n_getters'; +import { + LayerDescriptor, + MapExtent, + TiledSingleLayerVectorSourceDescriptor, + VectorSourceRequestMeta, + VectorSourceSyncMeta, +} from '../../../../common/descriptor_types'; +import { VectorLayerArguments } from '../../vector_layer'; + +export const sourceTitle = i18n.translate( + 'xpack.maps.source.MVTSingleLayerVectorSource.sourceTitle', + { + defaultMessage: 'Vector Tile Layer', + } +); + +export class MVTSingleLayerVectorSource extends AbstractSource + implements ITiledSingleLayerVectorSource { + static createDescriptor({ + urlTemplate, + layerName, + minSourceZoom, + maxSourceZoom, + }: TiledSingleLayerVectorSourceDescriptor) { + return { + type: SOURCE_TYPES.MVT_SINGLE_LAYER, + id: uuid(), + urlTemplate, + layerName, + minSourceZoom: Math.max(MIN_ZOOM, minSourceZoom), + maxSourceZoom: Math.min(MAX_ZOOM, maxSourceZoom), + }; + } + + readonly _descriptor: TiledSingleLayerVectorSourceDescriptor; + + constructor( + sourceDescriptor: TiledSingleLayerVectorSourceDescriptor, + inspectorAdapters?: object + ) { + super(sourceDescriptor, inspectorAdapters); + this._descriptor = sourceDescriptor; + } + + renderSourceSettingsEditor() { + return null; + } + + getFieldNames(): string[] { + return []; + } + + createDefaultLayer(options: LayerDescriptor): TiledVectorLayer { + const layerDescriptor = { + sourceDescriptor: this._descriptor, + ...options, + }; + const normalizedLayerDescriptor = TiledVectorLayer.createDescriptor(layerDescriptor, []); + const vectorLayerArguments: VectorLayerArguments = { + layerDescriptor: normalizedLayerDescriptor, + source: this, + }; + return new TiledVectorLayer(vectorLayerArguments); + } + + getGeoJsonWithMeta( + layerName: 'string', + searchFilters: unknown[], + registerCancelCallback: (callback: () => void) => void + ): Promise { + // todo: remove this method + // This is a consequence of ITiledSingleLayerVectorSource extending IVectorSource. + throw new Error('Does not implement getGeoJsonWithMeta'); + } + + async getFields(): Promise { + return []; + } + + async getImmutableProperties(): Promise { + return [ + { label: getDataSourceLabel(), value: sourceTitle }, + { label: getUrlLabel(), value: this._descriptor.urlTemplate }, + { + label: i18n.translate('xpack.maps.source.MVTSingleLayerVectorSource.layerNameMessage', { + defaultMessage: 'Layer name', + }), + value: this._descriptor.layerName, + }, + { + label: i18n.translate('xpack.maps.source.MVTSingleLayerVectorSource.minZoomMessage', { + defaultMessage: 'Min zoom', + }), + value: this._descriptor.minSourceZoom.toString(), + }, + { + label: i18n.translate('xpack.maps.source.MVTSingleLayerVectorSource.maxZoomMessage', { + defaultMessage: 'Max zoom', + }), + value: this._descriptor.maxSourceZoom.toString(), + }, + ]; + } + + async getDisplayName(): Promise { + return this._descriptor.layerName; + } + + async getUrlTemplateWithMeta() { + return { + urlTemplate: this._descriptor.urlTemplate, + layerName: this._descriptor.layerName, + minSourceZoom: this._descriptor.minSourceZoom, + maxSourceZoom: this._descriptor.maxSourceZoom, + }; + } + + async getSupportedShapeTypes(): Promise { + return [VECTOR_SHAPE_TYPES.POINT, VECTOR_SHAPE_TYPES.LINE, VECTOR_SHAPE_TYPES.POLYGON]; + } + + canFormatFeatureProperties() { + return false; + } + + getMinZoom() { + return this._descriptor.minSourceZoom; + } + + getMaxZoom() { + return this._descriptor.maxSourceZoom; + } + + getBoundsForFilters(searchFilters: VectorSourceRequestMeta): MapExtent { + return { + maxLat: 90, + maxLon: 180, + minLat: -90, + minLon: -180, + }; + } + + getFieldByName(fieldName: string): IField | null { + return null; + } + + getSyncMeta(): VectorSourceSyncMeta { + return null; + } + + getApplyGlobalQuery(): boolean { + return false; + } +} + +registerSource({ + ConstructorFunction: MVTSingleLayerVectorSource, + type: SOURCE_TYPES.MVT_SINGLE_LAYER, +}); diff --git a/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source_editor.tsx b/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source_editor.tsx new file mode 100644 index 0000000000000..7a4b8d43811da --- /dev/null +++ b/x-pack/plugins/maps/public/layers/sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source_editor.tsx @@ -0,0 +1,128 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +/* eslint-disable @typescript-eslint/consistent-type-definitions */ + +import React, { Fragment, Component, ChangeEvent } from 'react'; +import _ from 'lodash'; +import { EuiFieldText, EuiFormRow } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { MAX_ZOOM, MIN_ZOOM } from '../../../../common/constants'; +import { ValidatedDualRange, Value } from '../../../../../../../src/plugins/kibana_react/public'; + +export type MVTSingleLayerVectorSourceConfig = { + urlTemplate: string; + layerName: string; + minSourceZoom: number; + maxSourceZoom: number; +}; + +export interface Props { + onSourceConfigChange: (sourceConfig: MVTSingleLayerVectorSourceConfig) => void; +} + +interface State { + urlTemplate: string; + layerName: string; + minSourceZoom: number; + maxSourceZoom: number; +} + +export class MVTSingleLayerVectorSourceEditor extends Component { + state = { + urlTemplate: '', + layerName: '', + minSourceZoom: MIN_ZOOM, + maxSourceZoom: MAX_ZOOM, + }; + + _sourceConfigChange = _.debounce(() => { + const canPreview = + this.state.urlTemplate.indexOf('{x}') >= 0 && + this.state.urlTemplate.indexOf('{y}') >= 0 && + this.state.urlTemplate.indexOf('{z}') >= 0; + + if (canPreview && this.state.layerName) { + this.props.onSourceConfigChange({ + urlTemplate: this.state.urlTemplate, + layerName: this.state.layerName, + minSourceZoom: this.state.minSourceZoom, + maxSourceZoom: this.state.maxSourceZoom, + }); + } + }, 200); + + _handleUrlTemplateChange = (e: ChangeEvent) => { + const url = e.target.value; + this.setState( + { + urlTemplate: url, + }, + () => this._sourceConfigChange() + ); + }; + + _handleLayerNameInputChange = (e: ChangeEvent) => { + const layerName = e.target.value; + this.setState( + { + layerName, + }, + () => this._sourceConfigChange() + ); + }; + + _handleZoomRangeChange = (e: Value) => { + const minSourceZoom = parseInt(e[0] as string, 10); + const maxSourceZoom = parseInt(e[1] as string, 10); + + if (this.state.minSourceZoom !== minSourceZoom || this.state.maxSourceZoom !== maxSourceZoom) { + this.setState({ minSourceZoom, maxSourceZoom }, () => this._sourceConfigChange()); + } + }; + + render() { + return ( + + + + + + + + + + ); + } +} diff --git a/x-pack/plugins/maps/public/layers/sources/source.d.ts b/x-pack/plugins/maps/public/layers/sources/source.d.ts index a1581b826d9a6..5a01da02adaae 100644 --- a/x-pack/plugins/maps/public/layers/sources/source.d.ts +++ b/x-pack/plugins/maps/public/layers/sources/source.d.ts @@ -19,7 +19,7 @@ export type Attribution = { }; export interface ISource { - createDefaultLayer(): ILayer; + createDefaultLayer(options?: LayerDescriptor): ILayer; destroy(): void; getDisplayName(): Promise; getInspectorAdapters(): object; @@ -31,6 +31,8 @@ export interface ISource { isTimeAware(): Promise; getImmutableProperties(): Promise; getAttributions(): Promise; + getMinZoom(): number; + getMaxZoom(): number; } export class AbstractSource implements ISource { @@ -49,4 +51,6 @@ export class AbstractSource implements ISource { isTimeAware(): Promise; getImmutableProperties(): Promise; getAttributions(): Promise; + getMinZoom(): number; + getMaxZoom(): number; } diff --git a/x-pack/plugins/maps/public/layers/sources/source.js b/x-pack/plugins/maps/public/layers/sources/source.js index 3029a5c091202..fd93daf249b26 100644 --- a/x-pack/plugins/maps/public/layers/sources/source.js +++ b/x-pack/plugins/maps/public/layers/sources/source.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { copyPersistentState } from '../../reducers/util'; +import { MIN_ZOOM, MAX_ZOOM } from '../../../common/constants'; export class AbstractSource { static isIndexingSource = false; @@ -79,7 +79,7 @@ export class AbstractSource { return false; } - isQueryAware() { + async isTimeAware() { return false; } @@ -107,6 +107,14 @@ export class AbstractSource { return []; } + isFilterByMapBounds() { + return false; + } + + isQueryAware() { + return false; + } + getGeoGridPrecision() { return 0; } @@ -140,4 +148,12 @@ export class AbstractSource { async getValueSuggestions(/* field, query */) { return []; } + + getMinZoom() { + return MIN_ZOOM; + } + + getMaxZoom() { + return MAX_ZOOM; + } } diff --git a/x-pack/plugins/maps/public/layers/sources/source_registry.ts b/x-pack/plugins/maps/public/layers/sources/source_registry.ts index d16b16af74e9d..3b334d45092ad 100644 --- a/x-pack/plugins/maps/public/layers/sources/source_registry.ts +++ b/x-pack/plugins/maps/public/layers/sources/source_registry.ts @@ -10,7 +10,7 @@ import { ISource } from './source'; type SourceRegistryEntry = { ConstructorFunction: new ( sourceDescriptor: any, // this is the source-descriptor that corresponds specifically to the particular ISource instance - inspectorAdapters: unknown + inspectorAdapters?: object ) => ISource; type: string; }; diff --git a/x-pack/plugins/maps/public/layers/sources/vector_feature_types.js b/x-pack/plugins/maps/public/layers/sources/vector_feature_types.js deleted file mode 100644 index cc5f30389c4f3..0000000000000 --- a/x-pack/plugins/maps/public/layers/sources/vector_feature_types.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const VECTOR_SHAPE_TYPES = { - POINT: 'POINT', - LINE: 'LINE', - POLYGON: 'POLYGON', -}; diff --git a/x-pack/legacy/plugins/uptime/common/domain_types/monitors.ts b/x-pack/plugins/maps/public/layers/sources/vector_feature_types.ts similarity index 72% rename from x-pack/legacy/plugins/uptime/common/domain_types/monitors.ts rename to x-pack/plugins/maps/public/layers/sources/vector_feature_types.ts index 7f5699eb7e8a4..9f03357e17dad 100644 --- a/x-pack/legacy/plugins/uptime/common/domain_types/monitors.ts +++ b/x-pack/plugins/maps/public/layers/sources/vector_feature_types.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -export interface UMGqlRange { - dateRangeStart: string; - dateRangeEnd: string; +export enum VECTOR_SHAPE_TYPES { + POINT = 'POINT', + LINE = 'LINE', + POLYGON = 'POLYGON', } diff --git a/x-pack/plugins/maps/public/layers/sources/vector_source/vector_source.d.ts b/x-pack/plugins/maps/public/layers/sources/vector_source/vector_source.d.ts index 63429830d9f4f..804915dd73052 100644 --- a/x-pack/plugins/maps/public/layers/sources/vector_source/vector_source.d.ts +++ b/x-pack/plugins/maps/public/layers/sources/vector_source/vector_source.d.ts @@ -14,6 +14,7 @@ import { VectorSourceRequestMeta, VectorSourceSyncMeta, } from '../../../../common/descriptor_types'; +import { VECTOR_SHAPE_TYPES } from '../vector_feature_types'; export type GeoJsonFetchMeta = ESSearchSourceResponseMeta; @@ -31,8 +32,10 @@ export interface IVectorSource extends ISource { ): Promise; getFields(): Promise; - getFieldByName(fieldName: string): IField; + getFieldByName(fieldName: string): IField | null; getSyncMeta(): VectorSourceSyncMeta; + getFieldNames(): string[]; + getApplyGlobalQuery(): boolean; } export class AbstractVectorSource extends AbstractSource implements IVectorSource { @@ -44,6 +47,21 @@ export class AbstractVectorSource extends AbstractSource implements IVectorSourc ): Promise; getFields(): Promise; - getFieldByName(fieldName: string): IField; + getFieldByName(fieldName: string): IField | null; getSyncMeta(): VectorSourceSyncMeta; + getSupportedShapeTypes(): Promise; + canFormatFeatureProperties(): boolean; + getApplyGlobalQuery(): boolean; + getFieldNames(): string[]; +} + +export interface ITiledSingleLayerVectorSource extends IVectorSource { + getUrlTemplateWithMeta(): Promise<{ + layerName: string; + urlTemplate: string; + minSourceZoom: number; + maxSourceZoom: number; + }>; + getMinZoom(): number; + getMaxZoom(): number; } diff --git a/x-pack/plugins/maps/public/layers/sources/vector_source/vector_source.js b/x-pack/plugins/maps/public/layers/sources/vector_source/vector_source.js index bb37175b48655..509584cbc415a 100644 --- a/x-pack/plugins/maps/public/layers/sources/vector_source/vector_source.js +++ b/x-pack/plugins/maps/public/layers/sources/vector_source/vector_source.js @@ -60,6 +60,10 @@ export class AbstractVectorSource extends AbstractSource { throw new Error(`Should implemement ${this.constructor.type} ${this}`); } + getFieldNames() { + return []; + } + /** * Retrieves a field. This may be an existing instance. * @param fieldName diff --git a/x-pack/plugins/maps/public/layers/styles/vector/components/vector_style_editor.js b/x-pack/plugins/maps/public/layers/styles/vector/components/vector_style_editor.js index 6cece5efb3a5d..c46dc2cb4b73e 100644 --- a/x-pack/plugins/maps/public/layers/styles/vector/components/vector_style_editor.js +++ b/x-pack/plugins/maps/public/layers/styles/vector/components/vector_style_editor.js @@ -37,7 +37,7 @@ export class VectorStyleEditor extends Component { defaultDynamicProperties: getDefaultDynamicProperties(), defaultStaticProperties: getDefaultStaticProperties(), supportedFeatures: undefined, - selectedFeatureType: undefined, + selectedFeature: null, }; componentWillUnmount() { @@ -91,18 +91,20 @@ export class VectorStyleEditor extends Component { return; } - let selectedFeature = VECTOR_SHAPE_TYPES.POLYGON; - if (this.props.isPointsOnly) { - selectedFeature = VECTOR_SHAPE_TYPES.POINT; - } else if (this.props.isLinesOnly) { - selectedFeature = VECTOR_SHAPE_TYPES.LINE; + if (!_.isEqual(supportedFeatures, this.state.supportedFeatures)) { + this.setState({ supportedFeatures }); } - if ( - !_.isEqual(supportedFeatures, this.state.supportedFeatures) || - selectedFeature !== this.state.selectedFeature - ) { - this.setState({ supportedFeatures, selectedFeature }); + if (this.state.selectedFeature === null) { + let selectedFeature = VECTOR_SHAPE_TYPES.POLYGON; + if (this.props.isPointsOnly) { + selectedFeature = VECTOR_SHAPE_TYPES.POINT; + } else if (this.props.isLinesOnly) { + selectedFeature = VECTOR_SHAPE_TYPES.LINE; + } + this.setState({ + selectedFeature: selectedFeature, + }); } } diff --git a/x-pack/plugins/maps/public/layers/styles/vector/properties/dynamic_style_property.js b/x-pack/plugins/maps/public/layers/styles/vector/properties/dynamic_style_property.js index ea521f8749d80..8cef78f9a8f21 100644 --- a/x-pack/plugins/maps/public/layers/styles/vector/properties/dynamic_style_property.js +++ b/x-pack/plugins/maps/public/layers/styles/vector/properties/dynamic_style_property.js @@ -279,6 +279,10 @@ export class DynamicStyleProperty extends AbstractStyleProperty { } getNumericalMbFeatureStateValue(value) { + if (typeof value === 'number') { + return value; + } + const valueAsFloat = parseFloat(value); return isNaN(valueAsFloat) ? null : valueAsFloat; } diff --git a/x-pack/plugins/maps/public/layers/styles/vector/vector_style.d.ts b/x-pack/plugins/maps/public/layers/styles/vector/vector_style.d.ts index 77ea44ac26bf9..e010d5ac7d7a3 100644 --- a/x-pack/plugins/maps/public/layers/styles/vector/vector_style.d.ts +++ b/x-pack/plugins/maps/public/layers/styles/vector/vector_style.d.ts @@ -7,17 +7,23 @@ import { IStyleProperty } from './properties/style_property'; import { IDynamicStyleProperty } from './properties/dynamic_style_property'; import { IVectorLayer } from '../../vector_layer'; import { IVectorSource } from '../../sources/vector_source'; -import { VectorStyleDescriptor } from '../../../../common/descriptor_types'; +import { + VectorStyleDescriptor, + VectorStylePropertiesDescriptor, +} from '../../../../common/descriptor_types'; export interface IVectorStyle { getAllStyleProperties(): IStyleProperty[]; getDescriptor(): VectorStyleDescriptor; getDynamicPropertiesArray(): IDynamicStyleProperty[]; + getSourceFieldNames(): string[]; } export class VectorStyle implements IVectorStyle { + static createDescriptor(properties: VectorStylePropertiesDescriptor): VectorStyleDescriptor; + static createDefaultStyleProperties(mapColors: string[]): VectorStylePropertiesDescriptor; constructor(descriptor: VectorStyleDescriptor, source: IVectorSource, layer: IVectorLayer); - + getSourceFieldNames(): string[]; getAllStyleProperties(): IStyleProperty[]; getDescriptor(): VectorStyleDescriptor; getDynamicPropertiesArray(): IDynamicStyleProperty[]; diff --git a/x-pack/plugins/maps/public/layers/tiled_vector_layer.tsx b/x-pack/plugins/maps/public/layers/tiled_vector_layer.tsx new file mode 100644 index 0000000000000..c47cae5641e56 --- /dev/null +++ b/x-pack/plugins/maps/public/layers/tiled_vector_layer.tsx @@ -0,0 +1,170 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React from 'react'; +import { EuiIcon } from '@elastic/eui'; +import { VectorStyle } from './styles/vector/vector_style'; +import { SOURCE_DATA_ID_ORIGIN, LAYER_TYPE } from '../../common/constants'; +import { VectorLayer, VectorLayerArguments } from './vector_layer'; +import { canSkipSourceUpdate } from './util/can_skip_fetch'; +import { ITiledSingleLayerVectorSource } from './sources/vector_source'; +import { SyncContext } from '../actions/map_actions'; +import { ISource } from './sources/source'; +import { VectorLayerDescriptor, VectorSourceRequestMeta } from '../../common/descriptor_types'; +import { MVTSingleLayerVectorSourceConfig } from './sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source_editor'; + +export class TiledVectorLayer extends VectorLayer { + static type = LAYER_TYPE.TILED_VECTOR; + + static createDescriptor( + descriptor: VectorLayerDescriptor, + mapColors: string[] + ): VectorLayerDescriptor { + const layerDescriptor = super.createDescriptor(descriptor, mapColors); + layerDescriptor.type = TiledVectorLayer.type; + + if (!layerDescriptor.style) { + const styleProperties = VectorStyle.createDefaultStyleProperties(mapColors); + layerDescriptor.style = VectorStyle.createDescriptor(styleProperties); + } + + return layerDescriptor; + } + + readonly _source: ITiledSingleLayerVectorSource; // downcast to the more specific type + + constructor({ layerDescriptor, source }: VectorLayerArguments) { + super({ layerDescriptor, source }); + this._source = source as ITiledSingleLayerVectorSource; + } + + getCustomIconAndTooltipContent() { + return { + icon: , + }; + } + + async _syncMVTUrlTemplate({ startLoading, stopLoading, onLoadError, dataFilters }: SyncContext) { + const requestToken: symbol = Symbol(`layer-${this.getId()}-${SOURCE_DATA_ID_ORIGIN}`); + const searchFilters: VectorSourceRequestMeta = this._getSearchFilters( + dataFilters, + this.getSource(), + this._style + ); + const prevDataRequest = this.getSourceDataRequest(); + + const canSkip = await canSkipSourceUpdate({ + source: this._source as ISource, + prevDataRequest, + nextMeta: searchFilters, + }); + if (canSkip) { + return null; + } + + startLoading(SOURCE_DATA_ID_ORIGIN, requestToken, searchFilters); + try { + const templateWithMeta = await this._source.getUrlTemplateWithMeta(); + stopLoading(SOURCE_DATA_ID_ORIGIN, requestToken, templateWithMeta, {}); + } catch (error) { + onLoadError(SOURCE_DATA_ID_ORIGIN, requestToken, error.message); + } + } + + async syncData(syncContext: SyncContext) { + if (!this.isVisible() || !this.showAtZoomLevel(syncContext.dataFilters.zoom)) { + return; + } + + await this._syncSourceStyleMeta(syncContext, this._source, this._style); + await this._syncSourceFormatters(syncContext, this._source, this._style); + await this._syncMVTUrlTemplate(syncContext); + } + + _syncSourceBindingWithMb(mbMap: unknown) { + // @ts-ignore + const mbSource = mbMap.getSource(this.getId()); + if (!mbSource) { + const sourceDataRequest = this.getSourceDataRequest(); + if (!sourceDataRequest) { + // this is possible if the layer was invisible at startup. + // the actions will not perform any data=syncing as an optimization when a layer is invisible + // when turning the layer back into visible, it's possible the url has not been resovled yet. + return; + } + + const sourceMeta: MVTSingleLayerVectorSourceConfig | null = sourceDataRequest.getData() as MVTSingleLayerVectorSourceConfig; + if (!sourceMeta) { + return; + } + + const sourceId = this.getId(); + + // @ts-ignore + mbMap.addSource(sourceId, { + type: 'vector', + tiles: [sourceMeta.urlTemplate], + minzoom: sourceMeta.minSourceZoom, + maxzoom: sourceMeta.maxSourceZoom, + }); + } + } + + _syncStylePropertiesWithMb(mbMap: unknown) { + // @ts-ignore + const mbSource = mbMap.getSource(this.getId()); + if (!mbSource) { + return; + } + + const sourceDataRequest = this.getSourceDataRequest(); + if (!sourceDataRequest) { + return; + } + const sourceMeta: MVTSingleLayerVectorSourceConfig = sourceDataRequest.getData() as MVTSingleLayerVectorSourceConfig; + + this._setMbPointsProperties(mbMap, sourceMeta.layerName); + this._setMbLinePolygonProperties(mbMap, sourceMeta.layerName); + } + + _requiresPrevSourceCleanup(mbMap: unknown): boolean { + // @ts-ignore + const mbTileSource = mbMap.getSource(this.getId()); + if (!mbTileSource) { + return false; + } + const dataRequest = this.getSourceDataRequest(); + if (!dataRequest) { + return false; + } + const tiledSourceMeta: MVTSingleLayerVectorSourceConfig | null = dataRequest.getData() as MVTSingleLayerVectorSourceConfig; + if ( + mbTileSource.tiles[0] === tiledSourceMeta.urlTemplate && + mbTileSource.minzoom === tiledSourceMeta.minSourceZoom && + mbTileSource.maxzoom === tiledSourceMeta.maxSourceZoom + ) { + // TileURL and zoom-range captures all the state. If this does not change, no updates are required. + return false; + } + + return true; + } + + syncLayerWithMB(mbMap: unknown) { + this._removeStaleMbSourcesAndLayers(mbMap); + this._syncSourceBindingWithMb(mbMap); + this._syncStylePropertiesWithMb(mbMap); + } + + getJoins() { + return []; + } + + getMinZoom() { + // higher resolution vector tiles cannot be displayed at lower-res + return Math.max(this._source.getMinZoom(), super.getMinZoom()); + } +} diff --git a/x-pack/plugins/maps/public/layers/vector_layer.d.ts b/x-pack/plugins/maps/public/layers/vector_layer.d.ts index 88b1a1ce8535e..3d5b8054ff3fd 100644 --- a/x-pack/plugins/maps/public/layers/vector_layer.d.ts +++ b/x-pack/plugins/maps/public/layers/vector_layer.d.ts @@ -9,6 +9,7 @@ import { AbstractLayer } from './layer'; import { IVectorSource } from './sources/vector_source'; import { MapFilters, + LayerDescriptor, VectorLayerDescriptor, VectorSourceRequestMeta, } from '../../common/descriptor_types'; @@ -20,7 +21,7 @@ import { SyncContext } from '../actions/map_actions'; type VectorLayerArguments = { source: IVectorSource; - joins: IJoin[]; + joins?: IJoin[]; layerDescriptor: VectorLayerDescriptor; }; @@ -28,11 +29,12 @@ export interface IVectorLayer extends ILayer { getFields(): Promise; getStyleEditorFields(): Promise; getValidJoins(): IJoin[]; + getSource(): IVectorSource; } export class VectorLayer extends AbstractLayer implements IVectorLayer { static createDescriptor( - options: Partial, + options: Partial, mapColors?: string[] ): VectorLayerDescriptor; @@ -40,14 +42,30 @@ export class VectorLayer extends AbstractLayer implements IVectorLayer { protected readonly _style: IVectorStyle; constructor(options: VectorLayerArguments); - + getLayerTypeIconName(): string; getFields(): Promise; getStyleEditorFields(): Promise; getValidJoins(): IJoin[]; + _syncSourceStyleMeta( + syncContext: SyncContext, + source: IVectorSource, + style: IVectorStyle + ): Promise; + _syncSourceFormatters( + syncContext: SyncContext, + source: IVectorSource, + style: IVectorStyle + ): Promise; + syncLayerWithMB(mbMap: unknown): void; _getSearchFilters( dataFilters: MapFilters, source: IVectorSource, style: IVectorStyle ): VectorSourceRequestMeta; _syncData(syncContext: SyncContext, source: IVectorSource, style: IVectorStyle): Promise; + ownsMbSourceId(sourceId: string): boolean; + ownsMbLayerId(sourceId: string): boolean; + _setMbPointsProperties(mbMap: unknown, mvtSourceLayer?: string): void; + _setMbLinePolygonProperties(mbMap: unknown, mvtSourceLayer?: string): void; + getSource(): IVectorSource; } diff --git a/x-pack/plugins/maps/public/layers/vector_layer.js b/x-pack/plugins/maps/public/layers/vector_layer.js index d606420909281..c5947a63587ea 100644 --- a/x-pack/plugins/maps/public/layers/vector_layer.js +++ b/x-pack/plugins/maps/public/layers/vector_layer.js @@ -641,7 +641,7 @@ export class VectorLayer extends AbstractLayer { } } - _setMbPointsProperties(mbMap) { + _setMbPointsProperties(mbMap, mvtSourceLayer) { const pointLayerId = this._getMbPointLayerId(); const symbolLayerId = this._getMbSymbolLayerId(); const pointLayer = mbMap.getLayer(pointLayerId); @@ -658,7 +658,7 @@ export class VectorLayer extends AbstractLayer { if (symbolLayer) { mbMap.setLayoutProperty(symbolLayerId, 'visibility', 'none'); } - this._setMbCircleProperties(mbMap); + this._setMbCircleProperties(mbMap, mvtSourceLayer); } else { markerLayerId = symbolLayerId; textLayerId = symbolLayerId; @@ -666,7 +666,7 @@ export class VectorLayer extends AbstractLayer { mbMap.setLayoutProperty(pointLayerId, 'visibility', 'none'); mbMap.setLayoutProperty(this._getMbTextLayerId(), 'visibility', 'none'); } - this._setMbSymbolProperties(mbMap); + this._setMbSymbolProperties(mbMap, mvtSourceLayer); } this.syncVisibilityWithMb(mbMap, markerLayerId); @@ -677,27 +677,36 @@ export class VectorLayer extends AbstractLayer { } } - _setMbCircleProperties(mbMap) { + _setMbCircleProperties(mbMap, mvtSourceLayer) { const sourceId = this.getId(); const pointLayerId = this._getMbPointLayerId(); const pointLayer = mbMap.getLayer(pointLayerId); if (!pointLayer) { - mbMap.addLayer({ + const mbLayer = { id: pointLayerId, type: 'circle', source: sourceId, paint: {}, - }); + }; + + if (mvtSourceLayer) { + mbLayer['source-layer'] = mvtSourceLayer; + } + mbMap.addLayer(mbLayer); } const textLayerId = this._getMbTextLayerId(); const textLayer = mbMap.getLayer(textLayerId); if (!textLayer) { - mbMap.addLayer({ + const mbLayer = { id: textLayerId, type: 'symbol', source: sourceId, - }); + }; + if (mvtSourceLayer) { + mbLayer['source-layer'] = mvtSourceLayer; + } + mbMap.addLayer(mbLayer); } const filterExpr = getPointFilterExpression(this._hasJoins()); @@ -719,17 +728,21 @@ export class VectorLayer extends AbstractLayer { }); } - _setMbSymbolProperties(mbMap) { + _setMbSymbolProperties(mbMap, mvtSourceLayer) { const sourceId = this.getId(); const symbolLayerId = this._getMbSymbolLayerId(); const symbolLayer = mbMap.getLayer(symbolLayerId); if (!symbolLayer) { - mbMap.addLayer({ + const mbLayer = { id: symbolLayerId, type: 'symbol', source: sourceId, - }); + }; + if (mvtSourceLayer) { + mbLayer['source-layer'] = mvtSourceLayer; + } + mbMap.addLayer(mbLayer); } const filterExpr = getPointFilterExpression(this._hasJoins()); @@ -750,26 +763,34 @@ export class VectorLayer extends AbstractLayer { }); } - _setMbLinePolygonProperties(mbMap) { + _setMbLinePolygonProperties(mbMap, mvtSourceLayer) { const sourceId = this.getId(); const fillLayerId = this._getMbPolygonLayerId(); const lineLayerId = this._getMbLineLayerId(); const hasJoins = this._hasJoins(); if (!mbMap.getLayer(fillLayerId)) { - mbMap.addLayer({ + const mbLayer = { id: fillLayerId, type: 'fill', source: sourceId, paint: {}, - }); + }; + if (mvtSourceLayer) { + mbLayer['source-layer'] = mvtSourceLayer; + } + mbMap.addLayer(mbLayer); } if (!mbMap.getLayer(lineLayerId)) { - mbMap.addLayer({ + const mbLayer = { id: lineLayerId, type: 'line', source: sourceId, paint: {}, - }); + }; + if (mvtSourceLayer) { + mbLayer['source-layer'] = mvtSourceLayer; + } + mbMap.addLayer(mbLayer); } this.getCurrentStyle().setMBPaintProperties({ alpha: this.getAlpha(), diff --git a/x-pack/plugins/maps/public/layers/vector_tile_layer.js b/x-pack/plugins/maps/public/layers/vector_tile_layer.js index 44987fd3e78f0..c620ec6c56dc3 100644 --- a/x-pack/plugins/maps/public/layers/vector_tile_layer.js +++ b/x-pack/plugins/maps/public/layers/vector_tile_layer.js @@ -161,19 +161,7 @@ export class VectorTileLayer extends TileLayer { return; } - if (this._requiresPrevSourceCleanup(mbMap)) { - const mbStyle = mbMap.getStyle(); - mbStyle.layers.forEach(mbLayer => { - if (this.ownsMbLayerId(mbLayer.id)) { - mbMap.removeLayer(mbLayer.id); - } - }); - Object.keys(mbStyle.sources).some(mbSourceId => { - if (this.ownsMbSourceId(mbSourceId)) { - mbMap.removeSource(mbSourceId); - } - }); - } + this._removeStaleMbSourcesAndLayers(mbMap); let initialBootstrapCompleted = false; const sourceIds = Object.keys(vectorStyle.sources); diff --git a/x-pack/plugins/maps/public/maps_vis_type_alias.js b/x-pack/plugins/maps/public/maps_vis_type_alias.js new file mode 100644 index 0000000000000..85613f4608c6f --- /dev/null +++ b/x-pack/plugins/maps/public/maps_vis_type_alias.js @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; +import { APP_ID, APP_ICON, MAP_BASE_URL } from '../common/constants'; +import { getInjectedVarFunc, getVisualizations } from './kibana_services'; + +export function getMapsVisTypeAlias() { + const showMapVisualizationTypes = getInjectedVarFunc()('showMapVisualizationTypes', false); + if (!showMapVisualizationTypes) { + getVisualizations().hideTypes(['region_map', 'tile_map']); + } + + const description = i18n.translate('xpack.maps.visTypeAlias.description', { + defaultMessage: 'Create and style maps with multiple layers and indices.', + }); + + const legacyMapVisualizationWarning = i18n.translate( + 'xpack.maps.visTypeAlias.legacyMapVizWarning', + { + defaultMessage: `Use the Maps app instead of Coordinate Map and Region Map. +The Maps app offers more functionality and is easier to use.`, + } + ); + + return { + aliasUrl: MAP_BASE_URL, + name: APP_ID, + title: i18n.translate('xpack.maps.visTypeAlias.title', { + defaultMessage: 'Maps', + }), + description: showMapVisualizationTypes + ? `${description} ${legacyMapVisualizationWarning}` + : description, + icon: APP_ICON, + stage: 'production', + }; +} diff --git a/x-pack/plugins/maps/public/plugin.ts b/x-pack/plugins/maps/public/plugin.ts index 649627690ec9a..0b076621326ce 100644 --- a/x-pack/plugins/maps/public/plugin.ts +++ b/x-pack/plugins/maps/public/plugin.ts @@ -33,9 +33,17 @@ import { setVisualizations, // @ts-ignore } from './kibana_services'; +import { featureCatalogueEntry } from './feature_catalogue_entry'; +// @ts-ignore +import { getMapsVisTypeAlias } from './maps_vis_type_alias'; +import { registerLayerWizards } from './layers/load_layer_wizards'; +import { HomePublicPluginSetup } from '../../../../src/plugins/home/public'; +import { VisualizationsSetup } from '../../../../src/plugins/visualizations/public'; export interface MapsPluginSetupDependencies { inspector: InspectorSetupContract; + home: HomePublicPluginSetup; + visualizations: VisualizationsSetup; } // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface MapsPluginStartDependencies {} @@ -72,6 +80,7 @@ export const bindStartCoreAndPlugins = (core: CoreStart, plugins: any) => { setUiActions(plugins.uiActions); setNavigation(plugins.navigation); setCoreI18n(core.i18n); + registerLayerWizards(); }; /** @@ -92,8 +101,15 @@ export class MapsPlugin MapsPluginStartDependencies > { public setup(core: CoreSetup, plugins: MapsPluginSetupDependencies) { - plugins.inspector.registerView(MapView); + const { inspector, home, visualizations } = plugins; + bindSetupCoreAndPlugins(core, plugins); + + inspector.registerView(MapView); + home.featureCatalogue.register(featureCatalogueEntry); + visualizations.registerAlias(getMapsVisTypeAlias()); } - public start(core: CoreStart, plugins: any) {} + public start(core: CoreStart, plugins: any) { + bindStartCoreAndPlugins(core, plugins); + } } diff --git a/x-pack/plugins/maps/public/reducers/ui.ts b/x-pack/plugins/maps/public/reducers/ui.ts index 7429545ec0e46..f577618c74ffe 100644 --- a/x-pack/plugins/maps/public/reducers/ui.ts +++ b/x-pack/plugins/maps/public/reducers/ui.ts @@ -16,7 +16,6 @@ import { SHOW_TOC_DETAILS, HIDE_TOC_DETAILS, UPDATE_INDEXING_STAGE, - // @ts-ignore } from '../actions/ui_actions'; export enum FLYOUT_STATE { diff --git a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.d.ts b/x-pack/plugins/maps/public/selectors/map_selectors.d.ts similarity index 81% rename from x-pack/legacy/plugins/maps/public/selectors/map_selectors.d.ts rename to x-pack/plugins/maps/public/selectors/map_selectors.d.ts index 8c99e0adcc14f..32579d036590e 100644 --- a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.d.ts +++ b/x-pack/plugins/maps/public/selectors/map_selectors.d.ts @@ -6,8 +6,8 @@ import { AnyAction } from 'redux'; import { MapCenter } from '../../common/descriptor_types'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { MapStoreState } from '../../../../../plugins/maps/public/reducers/store'; + +import { MapStoreState } from '../reducers/store'; export function getHiddenLayerIds(state: MapStoreState): string[]; diff --git a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.js b/x-pack/plugins/maps/public/selectors/map_selectors.js similarity index 83% rename from x-pack/legacy/plugins/maps/public/selectors/map_selectors.js rename to x-pack/plugins/maps/public/selectors/map_selectors.js index f350a2c944756..c7073efa96cd5 100644 --- a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.js +++ b/x-pack/plugins/maps/public/selectors/map_selectors.js @@ -6,29 +6,27 @@ import { createSelector } from 'reselect'; import _ from 'lodash'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { TileLayer } from '../../../../../plugins/maps/public/layers/tile_layer'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { VectorTileLayer } from '../../../../../plugins/maps/public/layers/vector_tile_layer'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { VectorLayer } from '../../../../../plugins/maps/public/layers/vector_layer'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { HeatmapLayer } from '../../../../../plugins/maps/public/layers/heatmap_layer'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { BlendedVectorLayer } from '../../../../../plugins/maps/public/layers/blended_vector_layer'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getTimeFilter } from '../../../../../plugins/maps/public/kibana_services'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getInspectorAdapters } from '../../../../../plugins/maps/public/reducers/non_serializable_instances'; -import { - copyPersistentState, - TRACKED_LAYER_DESCRIPTOR, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../plugins/maps/public/reducers/util'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { InnerJoin } from '../../../../../plugins/maps/public/layers/joins/inner_join'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { getSourceByType } from '../../../../../plugins/maps/public/layers/sources/source_registry'; + +import { TileLayer } from '../layers/tile_layer'; + +import { VectorTileLayer } from '../layers/vector_tile_layer'; + +import { VectorLayer } from '../layers/vector_layer'; + +import { HeatmapLayer } from '../layers/heatmap_layer'; + +import { BlendedVectorLayer } from '../layers/blended_vector_layer'; + +import { getTimeFilter } from '../kibana_services'; + +import { getInspectorAdapters } from '../reducers/non_serializable_instances'; +import { TiledVectorLayer } from '../layers/tiled_vector_layer'; + +import { copyPersistentState, TRACKED_LAYER_DESCRIPTOR } from '../reducers/util'; + +import { InnerJoin } from '../layers/joins/inner_join'; + +import { getSourceByType } from '../layers/sources/source_registry'; function createLayerInstance(layerDescriptor, inspectorAdapters) { const source = createSourceInstance(layerDescriptor.sourceDescriptor, inspectorAdapters); @@ -51,6 +49,8 @@ function createLayerInstance(layerDescriptor, inspectorAdapters) { return new HeatmapLayer({ layerDescriptor, source }); case BlendedVectorLayer.type: return new BlendedVectorLayer({ layerDescriptor, source }); + case TiledVectorLayer.type: + return new TiledVectorLayer({ layerDescriptor, source }); default: throw new Error(`Unrecognized layerType ${layerDescriptor.type}`); } diff --git a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.test.js b/x-pack/plugins/maps/public/selectors/map_selectors.test.js similarity index 66% rename from x-pack/legacy/plugins/maps/public/selectors/map_selectors.test.js rename to x-pack/plugins/maps/public/selectors/map_selectors.test.js index b83be301653b8..fec16251914ea 100644 --- a/x-pack/legacy/plugins/maps/public/selectors/map_selectors.test.js +++ b/x-pack/plugins/maps/public/selectors/map_selectors.test.js @@ -4,17 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('../../../../../plugins/maps/public/layers/vector_layer', () => {}); -jest.mock('../../../../../plugins/maps/public/layers/blended_vector_layer', () => {}); -jest.mock('../../../../../plugins/maps/public/layers/heatmap_layer', () => {}); -jest.mock('../../../../../plugins/maps/public/layers/vector_tile_layer', () => {}); -jest.mock('../../../../../plugins/maps/public/layers/joins/inner_join', () => {}); -jest.mock('../../../../../plugins/maps/public/reducers/non_serializable_instances', () => ({ +jest.mock('../layers/vector_layer', () => {}); +jest.mock('../layers/tiled_vector_layer', () => {}); +jest.mock('../layers/blended_vector_layer', () => {}); +jest.mock('../layers/heatmap_layer', () => {}); +jest.mock('../layers/vector_tile_layer', () => {}); +jest.mock('../layers/joins/inner_join', () => {}); +jest.mock('../reducers/non_serializable_instances', () => ({ getInspectorAdapters: () => { return {}; }, })); -jest.mock('../../../../../plugins/maps/public/kibana_services', () => ({ +jest.mock('../kibana_services', () => ({ getTimeFilter: () => ({ getTime: () => { return { diff --git a/x-pack/legacy/plugins/maps/public/selectors/ui_selectors.ts b/x-pack/plugins/maps/public/selectors/ui_selectors.ts similarity index 74% rename from x-pack/legacy/plugins/maps/public/selectors/ui_selectors.ts rename to x-pack/plugins/maps/public/selectors/ui_selectors.ts index fdf2a8ea0e4f3..32d4beeb381d7 100644 --- a/x-pack/legacy/plugins/maps/public/selectors/ui_selectors.ts +++ b/x-pack/plugins/maps/public/selectors/ui_selectors.ts @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { MapStoreState } from '../../../../../plugins/maps/public/reducers/store'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { FLYOUT_STATE, INDEXING_STAGE } from '../../../../../plugins/maps/public/reducers/ui'; +import { MapStoreState } from '../reducers/store'; + +import { FLYOUT_STATE, INDEXING_STAGE } from '../reducers/ui'; export const getFlyoutDisplay = ({ ui }: MapStoreState): FLYOUT_STATE => ui.flyoutDisplay; export const getIsSetViewOpen = ({ ui }: MapStoreState): boolean => ui.isSetViewOpen; diff --git a/x-pack/legacy/plugins/tilemap/README.md b/x-pack/plugins/maps_legacy_licensing/README.md similarity index 100% rename from x-pack/legacy/plugins/tilemap/README.md rename to x-pack/plugins/maps_legacy_licensing/README.md diff --git a/x-pack/plugins/maps_legacy_licensing/kibana.json b/x-pack/plugins/maps_legacy_licensing/kibana.json new file mode 100644 index 0000000000000..e98c33d21ec40 --- /dev/null +++ b/x-pack/plugins/maps_legacy_licensing/kibana.json @@ -0,0 +1,8 @@ +{ + "id": "mapsLegacyLicensing", + "version": "8.0.0", + "kibanaVersion": "kibana", + "server": false, + "ui": true, + "requiredPlugins": ["licensing", "mapsLegacy"] +} diff --git a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/schema.gql.ts b/x-pack/plugins/maps_legacy_licensing/public/index.ts similarity index 68% rename from x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/schema.gql.ts rename to x-pack/plugins/maps_legacy_licensing/public/index.ts index 6af2c8bc8827f..edda6118f92dd 100644 --- a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/schema.gql.ts +++ b/x-pack/plugins/maps_legacy_licensing/public/index.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import gql from 'graphql-tag'; +import { MapsLegacyLicensing } from './plugin'; -export const unsignedIntegerSchema = gql` - scalar UnsignedInteger -`; +export function plugin() { + return new MapsLegacyLicensing(); +} diff --git a/x-pack/plugins/maps_legacy_licensing/public/plugin.ts b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts new file mode 100644 index 0000000000000..69c25efd96e75 --- /dev/null +++ b/x-pack/plugins/maps_legacy_licensing/public/plugin.ts @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; +import { LicensingPluginSetup, ILicense } from '../../licensing/public'; + +/** + * These are the interfaces with your public contracts. You should export these + * for other plugins to use in _their_ `SetupDeps`/`StartDeps` interfaces. + * @public + */ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface MapsLegacyLicensingSetupDependencies { + licensing: LicensingPluginSetup; + mapsLegacy: any; +} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface MapsLegacyLicensingStartDependencies {} + +export type MapsLegacyLicensingSetup = ReturnType; +export type MapsLegacyLicensingStart = ReturnType; + +export class MapsLegacyLicensing + implements Plugin { + public setup(core: CoreSetup, plugins: MapsLegacyLicensingSetupDependencies) { + const { + licensing, + mapsLegacy: { serviceSettings }, + } = plugins; + if (licensing) { + licensing.license$.subscribe((license: ILicense) => { + const { uid, isActive } = license; + if (isActive && license.hasAtLeast('basic')) { + serviceSettings.setQueryParams({ license: uid }); + serviceSettings.disableZoomMessage(); + } else { + serviceSettings.setQueryParams({ license: undefined }); + serviceSettings.enableZoomMessage(); + } + }); + } + } + + public start(core: CoreStart, plugins: MapsLegacyLicensingStartDependencies) {} +} diff --git a/x-pack/plugins/ml/common/util/__tests__/job_utils.js b/x-pack/plugins/ml/common/util/job_utils.test.js similarity index 50% rename from x-pack/plugins/ml/common/util/__tests__/job_utils.js rename to x-pack/plugins/ml/common/util/job_utils.test.js index 60270fd438846..a5df160bdf5ca 100644 --- a/x-pack/plugins/ml/common/util/__tests__/job_utils.js +++ b/x-pack/plugins/ml/common/util/job_utils.test.js @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import expect from '@kbn/expect'; import { calculateDatafeedFrequencyDefaultSeconds, isTimeSeriesViewJob, @@ -20,38 +19,38 @@ import { prefixDatafeedId, getSafeAggregationName, getLatestDataOrBucketTimestamp, -} from '../job_utils'; +} from './job_utils'; describe('ML - job utils', () => { describe('calculateDatafeedFrequencyDefaultSeconds', () => { - it('returns correct frequency for 119', () => { + test('returns correct frequency for 119', () => { const result = calculateDatafeedFrequencyDefaultSeconds(119); - expect(result).to.be(60); + expect(result).toBe(60); }); - it('returns correct frequency for 120', () => { + test('returns correct frequency for 120', () => { const result = calculateDatafeedFrequencyDefaultSeconds(120); - expect(result).to.be(60); + expect(result).toBe(60); }); - it('returns correct frequency for 300', () => { + test('returns correct frequency for 300', () => { const result = calculateDatafeedFrequencyDefaultSeconds(300); - expect(result).to.be(150); + expect(result).toBe(150); }); - it('returns correct frequency for 601', () => { + test('returns correct frequency for 601', () => { const result = calculateDatafeedFrequencyDefaultSeconds(601); - expect(result).to.be(300); + expect(result).toBe(300); }); - it('returns correct frequency for 43200', () => { + test('returns correct frequency for 43200', () => { const result = calculateDatafeedFrequencyDefaultSeconds(43200); - expect(result).to.be(600); + expect(result).toBe(600); }); - it('returns correct frequency for 43201', () => { + test('returns correct frequency for 43201', () => { const result = calculateDatafeedFrequencyDefaultSeconds(43201); - expect(result).to.be(3600); + expect(result).toBe(3600); }); }); describe('isTimeSeriesViewJob', () => { - it('returns true when job has a single detector with a metric function', () => { + test('returns true when job has a single detector with a metric function', () => { const job = { analysis_config: { detectors: [ @@ -64,10 +63,10 @@ describe('ML - job utils', () => { }, }; - expect(isTimeSeriesViewJob(job)).to.be(true); + expect(isTimeSeriesViewJob(job)).toBe(true); }); - it('returns true when job has at least one detector with a metric function', () => { + test('returns true when job has at least one detector with a metric function', () => { const job = { analysis_config: { detectors: [ @@ -86,10 +85,10 @@ describe('ML - job utils', () => { }, }; - expect(isTimeSeriesViewJob(job)).to.be(true); + expect(isTimeSeriesViewJob(job)).toBe(true); }); - it('returns false when job does not have at least one detector with a metric function', () => { + test('returns false when job does not have at least one detector with a metric function', () => { const job = { analysis_config: { detectors: [ @@ -108,10 +107,10 @@ describe('ML - job utils', () => { }, }; - expect(isTimeSeriesViewJob(job)).to.be(false); + expect(isTimeSeriesViewJob(job)).toBe(false); }); - it('returns false when job has a single count by category detector', () => { + test('returns false when job has a single count by category detector', () => { const job = { analysis_config: { detectors: [ @@ -124,7 +123,7 @@ describe('ML - job utils', () => { }, }; - expect(isTimeSeriesViewJob(job)).to.be(false); + expect(isTimeSeriesViewJob(job)).toBe(false); }); }); @@ -171,24 +170,24 @@ describe('ML - job utils', () => { }, }; - it('returns true for a detector with a metric function', () => { - expect(isTimeSeriesViewDetector(job, 0)).to.be(true); + test('returns true for a detector with a metric function', () => { + expect(isTimeSeriesViewDetector(job, 0)).toBe(true); }); - it('returns false for a detector with a non-metric function', () => { - expect(isTimeSeriesViewDetector(job, 1)).to.be(false); + test('returns false for a detector with a non-metric function', () => { + expect(isTimeSeriesViewDetector(job, 1)).toBe(false); }); - it('returns false for a detector using count on an mlcategory field', () => { - expect(isTimeSeriesViewDetector(job, 2)).to.be(false); + test('returns false for a detector using count on an mlcategory field', () => { + expect(isTimeSeriesViewDetector(job, 2)).toBe(false); }); - it('returns false for a detector using a script field as a by field', () => { - expect(isTimeSeriesViewDetector(job, 3)).to.be(false); + test('returns false for a detector using a script field as a by field', () => { + expect(isTimeSeriesViewDetector(job, 3)).toBe(false); }); - it('returns false for a detector using a script field as a metric field_name', () => { - expect(isTimeSeriesViewDetector(job, 4)).to.be(false); + test('returns false for a detector using a script field as a metric field_name', () => { + expect(isTimeSeriesViewDetector(job, 4)).toBe(false); }); }); @@ -233,7 +232,7 @@ describe('ML - job utils', () => { { function: 'time_of_day' }, // 34 { function: 'time_of_week' }, // 35 { function: 'lat_long' }, // 36 - { function: 'mean', field_name: 'NetworkDiff' }, //37 + { function: 'mean', field_name: 'NetworkDiff' }, // 37 ], }, datafeed_config: { @@ -254,48 +253,48 @@ describe('ML - job utils', () => { }, }; - it('returns true for expected detectors', () => { - expect(isSourceDataChartableForDetector(job, 0)).to.be(true); - expect(isSourceDataChartableForDetector(job, 1)).to.be(true); - expect(isSourceDataChartableForDetector(job, 2)).to.be(true); - expect(isSourceDataChartableForDetector(job, 3)).to.be(true); - expect(isSourceDataChartableForDetector(job, 4)).to.be(true); - expect(isSourceDataChartableForDetector(job, 5)).to.be(true); - expect(isSourceDataChartableForDetector(job, 6)).to.be(true); - expect(isSourceDataChartableForDetector(job, 7)).to.be(true); - expect(isSourceDataChartableForDetector(job, 8)).to.be(true); - expect(isSourceDataChartableForDetector(job, 9)).to.be(true); - expect(isSourceDataChartableForDetector(job, 10)).to.be(true); - expect(isSourceDataChartableForDetector(job, 11)).to.be(true); - expect(isSourceDataChartableForDetector(job, 12)).to.be(true); - expect(isSourceDataChartableForDetector(job, 13)).to.be(true); - expect(isSourceDataChartableForDetector(job, 14)).to.be(true); - expect(isSourceDataChartableForDetector(job, 15)).to.be(true); - expect(isSourceDataChartableForDetector(job, 16)).to.be(true); - expect(isSourceDataChartableForDetector(job, 17)).to.be(true); - expect(isSourceDataChartableForDetector(job, 18)).to.be(true); - expect(isSourceDataChartableForDetector(job, 19)).to.be(true); - expect(isSourceDataChartableForDetector(job, 20)).to.be(true); - expect(isSourceDataChartableForDetector(job, 21)).to.be(true); - expect(isSourceDataChartableForDetector(job, 22)).to.be(true); - expect(isSourceDataChartableForDetector(job, 23)).to.be(true); - expect(isSourceDataChartableForDetector(job, 24)).to.be(true); - }); - - it('returns false for expected detectors', () => { - expect(isSourceDataChartableForDetector(job, 25)).to.be(false); - expect(isSourceDataChartableForDetector(job, 26)).to.be(false); - expect(isSourceDataChartableForDetector(job, 27)).to.be(false); - expect(isSourceDataChartableForDetector(job, 28)).to.be(false); - expect(isSourceDataChartableForDetector(job, 29)).to.be(false); - expect(isSourceDataChartableForDetector(job, 30)).to.be(false); - expect(isSourceDataChartableForDetector(job, 31)).to.be(false); - expect(isSourceDataChartableForDetector(job, 32)).to.be(false); - expect(isSourceDataChartableForDetector(job, 33)).to.be(false); - expect(isSourceDataChartableForDetector(job, 34)).to.be(false); - expect(isSourceDataChartableForDetector(job, 35)).to.be(false); - expect(isSourceDataChartableForDetector(job, 36)).to.be(false); - expect(isSourceDataChartableForDetector(job, 37)).to.be(false); + test('returns true for expected detectors', () => { + expect(isSourceDataChartableForDetector(job, 0)).toBe(true); + expect(isSourceDataChartableForDetector(job, 1)).toBe(true); + expect(isSourceDataChartableForDetector(job, 2)).toBe(true); + expect(isSourceDataChartableForDetector(job, 3)).toBe(true); + expect(isSourceDataChartableForDetector(job, 4)).toBe(true); + expect(isSourceDataChartableForDetector(job, 5)).toBe(true); + expect(isSourceDataChartableForDetector(job, 6)).toBe(true); + expect(isSourceDataChartableForDetector(job, 7)).toBe(true); + expect(isSourceDataChartableForDetector(job, 8)).toBe(true); + expect(isSourceDataChartableForDetector(job, 9)).toBe(true); + expect(isSourceDataChartableForDetector(job, 10)).toBe(true); + expect(isSourceDataChartableForDetector(job, 11)).toBe(true); + expect(isSourceDataChartableForDetector(job, 12)).toBe(true); + expect(isSourceDataChartableForDetector(job, 13)).toBe(true); + expect(isSourceDataChartableForDetector(job, 14)).toBe(true); + expect(isSourceDataChartableForDetector(job, 15)).toBe(true); + expect(isSourceDataChartableForDetector(job, 16)).toBe(true); + expect(isSourceDataChartableForDetector(job, 17)).toBe(true); + expect(isSourceDataChartableForDetector(job, 18)).toBe(true); + expect(isSourceDataChartableForDetector(job, 19)).toBe(true); + expect(isSourceDataChartableForDetector(job, 20)).toBe(true); + expect(isSourceDataChartableForDetector(job, 21)).toBe(true); + expect(isSourceDataChartableForDetector(job, 22)).toBe(true); + expect(isSourceDataChartableForDetector(job, 23)).toBe(true); + expect(isSourceDataChartableForDetector(job, 24)).toBe(true); + }); + + test('returns false for expected detectors', () => { + expect(isSourceDataChartableForDetector(job, 25)).toBe(false); + expect(isSourceDataChartableForDetector(job, 26)).toBe(false); + expect(isSourceDataChartableForDetector(job, 27)).toBe(false); + expect(isSourceDataChartableForDetector(job, 28)).toBe(false); + expect(isSourceDataChartableForDetector(job, 29)).toBe(false); + expect(isSourceDataChartableForDetector(job, 30)).toBe(false); + expect(isSourceDataChartableForDetector(job, 31)).toBe(false); + expect(isSourceDataChartableForDetector(job, 32)).toBe(false); + expect(isSourceDataChartableForDetector(job, 33)).toBe(false); + expect(isSourceDataChartableForDetector(job, 34)).toBe(false); + expect(isSourceDataChartableForDetector(job, 35)).toBe(false); + expect(isSourceDataChartableForDetector(job, 36)).toBe(false); + expect(isSourceDataChartableForDetector(job, 37)).toBe(false); }); }); @@ -315,16 +314,16 @@ describe('ML - job utils', () => { }, }; - it('returns false when model plot is not enabled', () => { - expect(isModelPlotChartableForDetector(job1, 0)).to.be(false); + test('returns false when model plot is not enabled', () => { + expect(isModelPlotChartableForDetector(job1, 0)).toBe(false); }); - it('returns true for count detector when model plot is enabled', () => { - expect(isModelPlotChartableForDetector(job2, 0)).to.be(true); + test('returns true for count detector when model plot is enabled', () => { + expect(isModelPlotChartableForDetector(job2, 0)).toBe(true); }); - it('returns true for info_content detector when model plot is enabled', () => { - expect(isModelPlotChartableForDetector(job2, 1)).to.be(true); + test('returns true for info_content detector when model plot is enabled', () => { + expect(isModelPlotChartableForDetector(job2, 1)).toBe(true); }); }); @@ -359,39 +358,29 @@ describe('ML - job utils', () => { }, }; - it('returns empty array for a detector with no partitioning fields', () => { + test('returns empty array for a detector with no partitioning fields', () => { const resp = getPartitioningFieldNames(job, 0); - expect(resp).to.be.an('array'); - expect(resp).to.be.empty(); + expect(resp).toEqual([]); }); - it('returns expected array for a detector with a partition field', () => { + test('returns expected array for a detector with a partition field', () => { const resp = getPartitioningFieldNames(job, 1); - expect(resp).to.be.an('array'); - expect(resp).to.have.length(1); - expect(resp).to.contain('clientip'); + expect(resp).toEqual(['clientip']); }); - it('returns expected array for a detector with by and over fields', () => { + test('returns expected array for a detector with by and over fields', () => { const resp = getPartitioningFieldNames(job, 2); - expect(resp).to.be.an('array'); - expect(resp).to.have.length(2); - expect(resp).to.contain('uri'); - expect(resp).to.contain('clientip'); + expect(resp).toEqual(['uri', 'clientip']); }); - it('returns expected array for a detector with partition, by and over fields', () => { + test('returns expected array for a detector with partition, by and over fields', () => { const resp = getPartitioningFieldNames(job, 3); - expect(resp).to.be.an('array'); - expect(resp).to.have.length(3); - expect(resp).to.contain('uri'); - expect(resp).to.contain('clientip'); - expect(resp).to.contain('method'); + expect(resp).toEqual(['method', 'uri', 'clientip']); }); }); describe('isModelPlotEnabled', () => { - it('returns true for a job in which model plot has been enabled', () => { + test('returns true for a job in which model plot has been enabled', () => { const job = { analysis_config: { detectors: [ @@ -407,10 +396,10 @@ describe('ML - job utils', () => { }, }; - expect(isModelPlotEnabled(job, 0)).to.be(true); + expect(isModelPlotEnabled(job, 0)).toBe(true); }); - it('returns expected values for a job in which model plot has been enabled with terms', () => { + test('returns expected values for a job in which model plot has been enabled with terms', () => { const job = { analysis_config: { detectors: [ @@ -433,23 +422,23 @@ describe('ML - job utils', () => { { fieldName: 'country', fieldValue: 'US' }, { fieldName: 'airline', fieldValue: 'AAL' }, ]) - ).to.be(true); - expect(isModelPlotEnabled(job, 0, [{ fieldName: 'country', fieldValue: 'US' }])).to.be(false); + ).toBe(true); + expect(isModelPlotEnabled(job, 0, [{ fieldName: 'country', fieldValue: 'US' }])).toBe(false); expect( isModelPlotEnabled(job, 0, [ { fieldName: 'country', fieldValue: 'GB' }, { fieldName: 'airline', fieldValue: 'AAL' }, ]) - ).to.be(false); + ).toBe(false); expect( isModelPlotEnabled(job, 0, [ { fieldName: 'country', fieldValue: 'JP' }, { fieldName: 'airline', fieldValue: 'JAL' }, ]) - ).to.be(false); + ).toBe(false); }); - it('returns true for jobs in which model plot has not been enabled', () => { + test('returns true for jobs in which model plot has not been enabled', () => { const job1 = { analysis_config: { detectors: [ @@ -466,8 +455,8 @@ describe('ML - job utils', () => { }; const job2 = {}; - expect(isModelPlotEnabled(job1, 0)).to.be(false); - expect(isModelPlotEnabled(job2, 0)).to.be(false); + expect(isModelPlotEnabled(job1, 0)).toBe(false); + expect(isModelPlotEnabled(job2, 0)).toBe(false); }); }); @@ -476,115 +465,115 @@ describe('ML - job utils', () => { job_version: '6.1.1', }; - it('returns true for later job version', () => { - expect(isJobVersionGte(job, '6.1.0')).to.be(true); + test('returns true for later job version', () => { + expect(isJobVersionGte(job, '6.1.0')).toBe(true); }); - it('returns true for equal job version', () => { - expect(isJobVersionGte(job, '6.1.1')).to.be(true); + test('returns true for equal job version', () => { + expect(isJobVersionGte(job, '6.1.1')).toBe(true); }); - it('returns false for earlier job version', () => { - expect(isJobVersionGte(job, '6.1.2')).to.be(false); + test('returns false for earlier job version', () => { + expect(isJobVersionGte(job, '6.1.2')).toBe(false); }); }); describe('mlFunctionToESAggregation', () => { - it('returns correct ES aggregation type for ML function', () => { - expect(mlFunctionToESAggregation('count')).to.be('count'); - expect(mlFunctionToESAggregation('low_count')).to.be('count'); - expect(mlFunctionToESAggregation('high_count')).to.be('count'); - expect(mlFunctionToESAggregation('non_zero_count')).to.be('count'); - expect(mlFunctionToESAggregation('low_non_zero_count')).to.be('count'); - expect(mlFunctionToESAggregation('high_non_zero_count')).to.be('count'); - expect(mlFunctionToESAggregation('distinct_count')).to.be('cardinality'); - expect(mlFunctionToESAggregation('low_distinct_count')).to.be('cardinality'); - expect(mlFunctionToESAggregation('high_distinct_count')).to.be('cardinality'); - expect(mlFunctionToESAggregation('metric')).to.be('avg'); - expect(mlFunctionToESAggregation('mean')).to.be('avg'); - expect(mlFunctionToESAggregation('low_mean')).to.be('avg'); - expect(mlFunctionToESAggregation('high_mean')).to.be('avg'); - expect(mlFunctionToESAggregation('min')).to.be('min'); - expect(mlFunctionToESAggregation('max')).to.be('max'); - expect(mlFunctionToESAggregation('sum')).to.be('sum'); - expect(mlFunctionToESAggregation('low_sum')).to.be('sum'); - expect(mlFunctionToESAggregation('high_sum')).to.be('sum'); - expect(mlFunctionToESAggregation('non_null_sum')).to.be('sum'); - expect(mlFunctionToESAggregation('low_non_null_sum')).to.be('sum'); - expect(mlFunctionToESAggregation('high_non_null_sum')).to.be('sum'); - expect(mlFunctionToESAggregation('rare')).to.be('count'); - expect(mlFunctionToESAggregation('freq_rare')).to.be(null); - expect(mlFunctionToESAggregation('info_content')).to.be(null); - expect(mlFunctionToESAggregation('low_info_content')).to.be(null); - expect(mlFunctionToESAggregation('high_info_content')).to.be(null); - expect(mlFunctionToESAggregation('median')).to.be('percentiles'); - expect(mlFunctionToESAggregation('low_median')).to.be('percentiles'); - expect(mlFunctionToESAggregation('high_median')).to.be('percentiles'); - expect(mlFunctionToESAggregation('varp')).to.be(null); - expect(mlFunctionToESAggregation('low_varp')).to.be(null); - expect(mlFunctionToESAggregation('high_varp')).to.be(null); - expect(mlFunctionToESAggregation('time_of_day')).to.be(null); - expect(mlFunctionToESAggregation('time_of_week')).to.be(null); - expect(mlFunctionToESAggregation('lat_long')).to.be(null); + test('returns correct ES aggregation type for ML function', () => { + expect(mlFunctionToESAggregation('count')).toBe('count'); + expect(mlFunctionToESAggregation('low_count')).toBe('count'); + expect(mlFunctionToESAggregation('high_count')).toBe('count'); + expect(mlFunctionToESAggregation('non_zero_count')).toBe('count'); + expect(mlFunctionToESAggregation('low_non_zero_count')).toBe('count'); + expect(mlFunctionToESAggregation('high_non_zero_count')).toBe('count'); + expect(mlFunctionToESAggregation('distinct_count')).toBe('cardinality'); + expect(mlFunctionToESAggregation('low_distinct_count')).toBe('cardinality'); + expect(mlFunctionToESAggregation('high_distinct_count')).toBe('cardinality'); + expect(mlFunctionToESAggregation('metric')).toBe('avg'); + expect(mlFunctionToESAggregation('mean')).toBe('avg'); + expect(mlFunctionToESAggregation('low_mean')).toBe('avg'); + expect(mlFunctionToESAggregation('high_mean')).toBe('avg'); + expect(mlFunctionToESAggregation('min')).toBe('min'); + expect(mlFunctionToESAggregation('max')).toBe('max'); + expect(mlFunctionToESAggregation('sum')).toBe('sum'); + expect(mlFunctionToESAggregation('low_sum')).toBe('sum'); + expect(mlFunctionToESAggregation('high_sum')).toBe('sum'); + expect(mlFunctionToESAggregation('non_null_sum')).toBe('sum'); + expect(mlFunctionToESAggregation('low_non_null_sum')).toBe('sum'); + expect(mlFunctionToESAggregation('high_non_null_sum')).toBe('sum'); + expect(mlFunctionToESAggregation('rare')).toBe('count'); + expect(mlFunctionToESAggregation('freq_rare')).toBe(null); + expect(mlFunctionToESAggregation('info_content')).toBe(null); + expect(mlFunctionToESAggregation('low_info_content')).toBe(null); + expect(mlFunctionToESAggregation('high_info_content')).toBe(null); + expect(mlFunctionToESAggregation('median')).toBe('percentiles'); + expect(mlFunctionToESAggregation('low_median')).toBe('percentiles'); + expect(mlFunctionToESAggregation('high_median')).toBe('percentiles'); + expect(mlFunctionToESAggregation('varp')).toBe(null); + expect(mlFunctionToESAggregation('low_varp')).toBe(null); + expect(mlFunctionToESAggregation('high_varp')).toBe(null); + expect(mlFunctionToESAggregation('time_of_day')).toBe(null); + expect(mlFunctionToESAggregation('time_of_week')).toBe(null); + expect(mlFunctionToESAggregation('lat_long')).toBe(null); }); }); describe('isJobIdValid', () => { - it('returns true for job id: "good_job-name"', () => { - expect(isJobIdValid('good_job-name')).to.be(true); + test('returns true for job id: "good_job-name"', () => { + expect(isJobIdValid('good_job-name')).toBe(true); }); - it('returns false for job id: "_bad_job-name"', () => { - expect(isJobIdValid('_bad_job-name')).to.be(false); + test('returns false for job id: "_bad_job-name"', () => { + expect(isJobIdValid('_bad_job-name')).toBe(false); }); - it('returns false for job id: "bad_job-name_"', () => { - expect(isJobIdValid('bad_job-name_')).to.be(false); + test('returns false for job id: "bad_job-name_"', () => { + expect(isJobIdValid('bad_job-name_')).toBe(false); }); - it('returns false for job id: "-bad_job-name"', () => { - expect(isJobIdValid('-bad_job-name')).to.be(false); + test('returns false for job id: "-bad_job-name"', () => { + expect(isJobIdValid('-bad_job-name')).toBe(false); }); - it('returns false for job id: "bad_job-name-"', () => { - expect(isJobIdValid('bad_job-name-')).to.be(false); + test('returns false for job id: "bad_job-name-"', () => { + expect(isJobIdValid('bad_job-name-')).toBe(false); }); - it('returns false for job id: "bad&job-name"', () => { - expect(isJobIdValid('bad&job-name')).to.be(false); + test('returns false for job id: "bad&job-name"', () => { + expect(isJobIdValid('bad&job-name')).toBe(false); }); }); describe('ML_MEDIAN_PERCENTS', () => { - it("is '50.0'", () => { - expect(ML_MEDIAN_PERCENTS).to.be('50.0'); + test("is '50.0'", () => { + expect(ML_MEDIAN_PERCENTS).toBe('50.0'); }); }); describe('prefixDatafeedId', () => { - it('returns datafeed-prefix-job from datafeed-job"', () => { - expect(prefixDatafeedId('datafeed-job', 'prefix-')).to.be('datafeed-prefix-job'); + test('returns datafeed-prefix-job from datafeed-job"', () => { + expect(prefixDatafeedId('datafeed-job', 'prefix-')).toBe('datafeed-prefix-job'); }); - it('returns datafeed-prefix-job from job"', () => { - expect(prefixDatafeedId('job', 'prefix-')).to.be('datafeed-prefix-job'); + test('returns datafeed-prefix-job from job"', () => { + expect(prefixDatafeedId('job', 'prefix-')).toBe('datafeed-prefix-job'); }); }); describe('getSafeAggregationName', () => { - it('"foo" should be "foo"', () => { - expect(getSafeAggregationName('foo', 0)).to.be('foo'); + test('"foo" should be "foo"', () => { + expect(getSafeAggregationName('foo', 0)).toBe('foo'); }); - it('"foo.bar" should be "foo.bar"', () => { - expect(getSafeAggregationName('foo.bar', 0)).to.be('foo.bar'); + test('"foo.bar" should be "foo.bar"', () => { + expect(getSafeAggregationName('foo.bar', 0)).toBe('foo.bar'); }); - it('"foo&bar" should be "field_0"', () => { - expect(getSafeAggregationName('foo&bar', 0)).to.be('field_0'); + test('"foo&bar" should be "field_0"', () => { + expect(getSafeAggregationName('foo&bar', 0)).toBe('field_0'); }); }); describe('getLatestDataOrBucketTimestamp', () => { - it('returns expected value when no gap in data at end of bucket processing', () => { - expect(getLatestDataOrBucketTimestamp(1549929594000, 1549928700000)).to.be(1549929594000); + test('returns expected value when no gap in data at end of bucket processing', () => { + expect(getLatestDataOrBucketTimestamp(1549929594000, 1549928700000)).toBe(1549929594000); }); - it('returns expected value when there is a gap in data at end of bucket processing', () => { - expect(getLatestDataOrBucketTimestamp(1549929594000, 1562256600000)).to.be(1562256600000); + test('returns expected value when there is a gap in data at end of bucket processing', () => { + expect(getLatestDataOrBucketTimestamp(1549929594000, 1562256600000)).toBe(1562256600000); }); - it('returns expected value when job has not run', () => { - expect(getLatestDataOrBucketTimestamp(undefined, undefined)).to.be(undefined); + test('returns expected value when job has not run', () => { + expect(getLatestDataOrBucketTimestamp(undefined, undefined)).toBe(undefined); }); }); }); diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/common/analytics.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/common/analytics.ts index 511ebb7e1647a..fb3b2b3519947 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/common/analytics.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/common/analytics.ts @@ -13,7 +13,6 @@ import { ml } from '../../services/ml_api_service'; import { Dictionary } from '../../../../common/types/common'; import { getErrorMessage } from '../../../../common/util/errors'; import { SavedSearchQuery } from '../../contexts/ml'; -import { SortDirection } from '../../components/ml_in_memory_table'; export type IndexName = string; export type IndexPattern = string; @@ -54,12 +53,8 @@ export interface ClassificationAnalysis { } export interface LoadExploreDataArg { - field: string; - direction: SortDirection; + filterByIsTraining?: boolean; searchQuery: SavedSearchQuery; - requiresKeyword?: boolean; - pageIndex?: number; - pageSize?: number; } export const SEARCH_SIZE = 1000; @@ -272,6 +267,11 @@ export const isResultsSearchBoolQuery = (arg: any): arg is ResultsSearchBoolQuer return keys.length === 1 && keys[0] === 'bool'; }; +export const isQueryStringQuery = (arg: any): arg is QueryStringQuery => { + const keys = Object.keys(arg); + return keys.length === 1 && keys[0] === 'query_string'; +}; + export const isRegressionEvaluateResponse = (arg: any): arg is RegressionEvaluateResponse => { const keys = Object.keys(arg); return ( @@ -396,6 +396,10 @@ interface ResultsSearchTermQuery { term: Dictionary; } +interface QueryStringQuery { + query_string: Dictionary; +} + export type ResultsSearchQuery = ResultsSearchBoolQuery | ResultsSearchTermQuery | SavedSearchQuery; export function getEvalQueryBody({ @@ -405,20 +409,44 @@ export function getEvalQueryBody({ ignoreDefaultQuery, }: { resultsField: string; - isTraining: boolean; + isTraining?: boolean; searchQuery?: ResultsSearchQuery; ignoreDefaultQuery?: boolean; }) { - let query: ResultsSearchQuery = { + let query: any; + + const trainingQuery: ResultsSearchQuery = { term: { [`${resultsField}.is_training`]: { value: isTraining } }, }; - if (searchQuery !== undefined && ignoreDefaultQuery === true) { - query = searchQuery; - } else if (searchQuery !== undefined && isResultsSearchBoolQuery(searchQuery)) { - const searchQueryClone = cloneDeep(searchQuery); - searchQueryClone.bool.must.push(query); + const searchQueryClone = cloneDeep(searchQuery); + + if (isResultsSearchBoolQuery(searchQueryClone)) { + if (searchQueryClone.bool.must === undefined) { + searchQueryClone.bool.must = []; + } + + if (isTraining !== undefined) { + searchQueryClone.bool.must.push(trainingQuery); + } + query = searchQueryClone; + } else if (isQueryStringQuery(searchQueryClone)) { + query = { + bool: { + must: [searchQueryClone], + }, + }; + if (isTraining !== undefined) { + query.bool.must.push(trainingQuery); + } + } else { + // Not a bool or string query so we need to create it so can add the trainingQuery + query = { + bool: { + must: isTraining !== undefined ? [trainingQuery] : [], + }, + }; } return query; } @@ -434,7 +462,7 @@ interface EvaluateMetrics { } interface LoadEvalDataConfig { - isTraining: boolean; + isTraining?: boolean; index: string; dependentVariable: string; resultsField: string; @@ -513,7 +541,7 @@ interface TrackTotalHitsSearchResponse { interface LoadDocsCountConfig { ignoreDefaultQuery?: boolean; - isTraining: boolean; + isTraining?: boolean; searchQuery: SavedSearchQuery; resultsField: string; destIndex: string; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/common/fields.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/common/fields.ts index 92d8731959895..f165669bdd674 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/common/fields.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/common/fields.ts @@ -246,8 +246,15 @@ export const getDefaultFieldsFromJobCaps = ( fields: Field[], jobConfig: DataFrameAnalyticsConfig, needsDestIndexFields: boolean -): { selectedFields: Field[]; docFields: Field[]; depVarType?: ES_FIELD_TYPES } => { - const fieldsObj = { selectedFields: [], docFields: [] }; +): { + selectedFields: Field[]; + docFields: Field[]; + depVarType?: ES_FIELD_TYPES; +} => { + const fieldsObj = { + selectedFields: [], + docFields: [], + }; if (fields.length === 0) { return fieldsObj; } @@ -267,38 +274,37 @@ export const getDefaultFieldsFromJobCaps = ( const featureImportanceFields = []; if ((numTopFeatureImportanceValues ?? 0) > 0) { - featureImportanceFields.push( - ...fields.map(d => ({ - id: `${resultsField}.feature_importance.${d.id}`, - name: `${resultsField}.feature_importance.${d.name}`, - type: KBN_FIELD_TYPES.NUMBER, - })) - ); + featureImportanceFields.push({ + id: `${resultsField}.feature_importance`, + name: `${resultsField}.feature_importance`, + type: KBN_FIELD_TYPES.NUMBER, + }); } + let allFields: any = []; // Only need to add these fields if we didn't use dest index pattern to get the fields - const allFields: any = - needsDestIndexFields === true - ? [ - { - id: `${resultsField}.is_training`, - name: `${resultsField}.is_training`, - type: ES_FIELD_TYPES.BOOLEAN, - }, - { id: predictedField, name: predictedField, type }, - ...featureImportanceFields, - ] - : []; - - allFields.push(...fields); + if (needsDestIndexFields === true) { + allFields.push( + { + id: `${resultsField}.is_training`, + name: `${resultsField}.is_training`, + type: ES_FIELD_TYPES.BOOLEAN, + }, + { id: predictedField, name: predictedField, type } + ); + } + + allFields.push(...fields, ...featureImportanceFields); allFields.sort(({ name: a }: { name: string }, { name: b }: { name: string }) => sortRegressionResultsFields(a, b, jobConfig) ); + // Remove feature_importance fields provided by dest index since feature_importance is an array the path is not valid + if (needsDestIndexFields === false) { + allFields = allFields.filter((field: any) => !field.name.includes('.feature_importance.')); + } let selectedFields = allFields.filter( - (field: any) => - field.name === predictedField || - (!field.name.includes('.keyword') && !field.name.includes('.feature_importance.')) + (field: any) => field.name === predictedField || !field.name.includes('.keyword') ); if (selectedFields.length > DEFAULT_REGRESSION_COLUMNS) { diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/classification_exploration_data_grid.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/classification_exploration_data_grid.tsx new file mode 100644 index 0000000000000..424fc002795ca --- /dev/null +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/classification_exploration_data_grid.tsx @@ -0,0 +1,135 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { Dispatch, FC, SetStateAction, useCallback, useMemo } from 'react'; + +import { i18n } from '@kbn/i18n'; + +import { EuiDataGrid, EuiDataGridPaginationProps, EuiDataGridSorting } from '@elastic/eui'; + +import { euiDataGridStyle, euiDataGridToolbarSettings } from '../../../../common'; + +import { mlFieldFormatService } from '../../../../../services/field_format_service'; + +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; + +const PAGE_SIZE_OPTIONS = [5, 10, 25, 50]; + +type Pagination = Pick; +type TableItem = Record; + +interface ExplorationDataGridProps { + colorRange?: (d: number) => string; + columns: any[]; + indexPattern: IndexPattern; + pagination: Pagination; + resultsField: string; + rowCount: number; + selectedFields: string[]; + setPagination: Dispatch>; + setSelectedFields: Dispatch>; + setSortingColumns: Dispatch>; + sortingColumns: EuiDataGridSorting['columns']; + tableItems: TableItem[]; +} + +export const ClassificationExplorationDataGrid: FC = ({ + columns, + indexPattern, + pagination, + resultsField, + rowCount, + selectedFields, + setPagination, + setSelectedFields, + setSortingColumns, + sortingColumns, + tableItems, +}) => { + const renderCellValue = useMemo(() => { + return ({ rowIndex, columnId }: { rowIndex: number; columnId: string; setCellProps: any }) => { + const adjustedRowIndex = rowIndex - pagination.pageIndex * pagination.pageSize; + + const fullItem = tableItems[adjustedRowIndex]; + + if (fullItem === undefined) { + return null; + } + + let format: any; + + if (indexPattern !== undefined) { + format = mlFieldFormatService.getFieldFormatFromIndexPattern(indexPattern, columnId, ''); + } + + const cellValue = + fullItem.hasOwnProperty(columnId) && fullItem[columnId] !== undefined + ? fullItem[columnId] + : null; + + if (format !== undefined) { + return format.convert(cellValue, 'text'); + } + + if (typeof cellValue === 'string' || cellValue === null) { + return cellValue; + } + + if (typeof cellValue === 'boolean') { + return cellValue ? 'true' : 'false'; + } + + if (typeof cellValue === 'object' && cellValue !== null) { + return JSON.stringify(cellValue); + } + + return cellValue; + }; + }, [resultsField, rowCount, tableItems, pagination.pageIndex, pagination.pageSize]); + + const onChangeItemsPerPage = useCallback( + pageSize => { + setPagination(p => { + const pageIndex = Math.floor((p.pageSize * p.pageIndex) / pageSize); + return { pageIndex, pageSize }; + }); + }, + [setPagination] + ); + + const onChangePage = useCallback(pageIndex => setPagination(p => ({ ...p, pageIndex })), [ + setPagination, + ]); + + const onSort = useCallback(sc => setSortingColumns(sc), [setSortingColumns]); + + return ( + + ); +}; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx index 91dae49ba5c49..af90547606f82 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/evaluate_panel.tsx @@ -117,13 +117,7 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery }) const resultsField = jobConfig.dest.results_field; let requiresKeyword = false; - const loadData = async ({ - isTrainingClause, - ignoreDefaultQuery = true, - }: { - isTrainingClause: { query: string; operator: string }; - ignoreDefaultQuery?: boolean; - }) => { + const loadData = async ({ isTraining }: { isTraining: boolean | undefined }) => { setIsLoading(true); try { @@ -134,19 +128,18 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery }) } const evalData = await loadEvalData({ - isTraining: false, + isTraining, index, dependentVariable, resultsField, predictionFieldName, searchQuery, - ignoreDefaultQuery, jobType: ANALYSIS_CONFIG_TYPE.CLASSIFICATION, requiresKeyword, }); const docsCountResp = await loadDocsCount({ - isTraining: false, + isTraining, searchQuery, resultsField, destIndex: jobConfig.dest.index, @@ -225,29 +218,46 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery }) }, [confusionMatrixData]); useEffect(() => { - const hasIsTrainingClause = - isResultsSearchBoolQuery(searchQuery) && - searchQuery.bool.must.filter( - (clause: any) => clause.match && clause.match[`${resultsField}.is_training`] !== undefined - ); - const isTrainingClause = - hasIsTrainingClause && - hasIsTrainingClause[0] && - hasIsTrainingClause[0].match[`${resultsField}.is_training`]; + let isTraining: boolean | undefined; + const query = + isResultsSearchBoolQuery(searchQuery) && (searchQuery.bool.should || searchQuery.bool.filter); - const noTrainingQuery = isTrainingClause === false || isTrainingClause === undefined; + if (query !== undefined && query !== false) { + for (let i = 0; i < query.length; i++) { + const clause = query[i]; - if (noTrainingQuery) { + if (clause.match && clause.match[`${resultsField}.is_training`] !== undefined) { + isTraining = clause.match[`${resultsField}.is_training`]; + break; + } else if ( + clause.bool && + (clause.bool.should !== undefined || clause.bool.filter !== undefined) + ) { + const innerQuery = clause.bool.should || clause.bool.filter; + if (innerQuery !== undefined) { + for (let j = 0; j < innerQuery.length; j++) { + const innerClause = innerQuery[j]; + if ( + innerClause.match && + innerClause.match[`${resultsField}.is_training`] !== undefined + ) { + isTraining = innerClause.match[`${resultsField}.is_training`]; + break; + } + } + } + } + } + } + if (isTraining === undefined) { setDataSubsetTitle(SUBSET_TITLE.ENTIRE); } else { setDataSubsetTitle( - isTrainingClause && isTrainingClause.query === 'true' - ? SUBSET_TITLE.TRAINING - : SUBSET_TITLE.TESTING + isTraining && isTraining === true ? SUBSET_TITLE.TRAINING : SUBSET_TITLE.TESTING ); } - loadData({ isTrainingClause }); + loadData({ isTraining }); }, [JSON.stringify(searchQuery)]); const renderCellValue = ({ diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/results_table.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/results_table.tsx index 9758dd969b443..bf63dfe68fe9e 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/results_table.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/results_table.tsx @@ -4,71 +4,39 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment, FC, useEffect, useState } from 'react'; -import moment from 'moment-timezone'; - +import React, { Fragment, FC, useEffect } from 'react'; import { i18n } from '@kbn/i18n'; import { - EuiBadge, - EuiButtonIcon, EuiCallOut, - EuiCheckbox, EuiFlexGroup, EuiFlexItem, EuiFormRow, EuiPanel, - EuiPopover, - EuiPopoverTitle, EuiProgress, EuiSpacer, EuiText, - EuiToolTip, - Query, } from '@elastic/eui'; -import { Query as QueryType } from '../../../analytics_management/components/analytics_list/common'; -import { ES_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; -import { mlFieldFormatService } from '../../../../../services/field_format_service'; import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; - -import { - ColumnType, - mlInMemoryTableBasicFactory, - OnTableChangeArg, - SortingPropType, - SORT_DIRECTION, -} from '../../../../../components/ml_in_memory_table'; - -import { formatHumanReadableDateTimeSeconds } from '../../../../../util/date_utils'; -import { Field } from '../../../../../../../common/types/fields'; -import { SavedSearchQuery } from '../../../../../contexts/ml'; import { BASIC_NUMERICAL_TYPES, EXTENDED_NUMERICAL_TYPES, - isKeywordAndTextType, sortRegressionResultsFields, } from '../../../../common/fields'; import { - toggleSelectedField, - EsDoc, DataFrameAnalyticsConfig, - EsFieldName, MAX_COLUMNS, - getPredictedFieldName, INDEX_STATUS, SEARCH_SIZE, defaultSearchQuery, - getDependentVar, } from '../../../../common'; import { getTaskStateBadge } from '../../../analytics_management/components/analytics_list/columns'; import { DATA_FRAME_TASK_STATE } from '../../../analytics_management/components/analytics_list/common'; -import { useExploreData, TableItem } from './use_explore_data'; +import { useExploreData } from './use_explore_data'; // TableItem import { ExplorationTitle } from './classification_exploration'; - -const PAGE_SIZE_OPTIONS = [5, 10, 25, 50]; - -const MlInMemoryTableBasic = mlInMemoryTableBasicFactory(); +import { ClassificationExplorationDataGrid } from './classification_exploration_data_grid'; +import { ExplorationQueryBar } from '../exploration_query_bar'; const showingDocs = i18n.translate( 'xpack.ml.dataframe.analytics.classificationExploration.documentsShownHelpText', @@ -94,307 +62,65 @@ interface Props { export const ResultsTable: FC = React.memo( ({ indexPattern, jobConfig, jobStatus, setEvaluateSearchQuery }) => { - const [pageIndex, setPageIndex] = useState(0); - const [pageSize, setPageSize] = useState(25); - const [selectedFields, setSelectedFields] = useState([] as Field[]); - const [docFields, setDocFields] = useState([] as Field[]); - const [depVarType, setDepVarType] = useState(undefined); - const [isColumnsPopoverVisible, setColumnsPopoverVisible] = useState(false); - const [searchQuery, setSearchQuery] = useState(defaultSearchQuery); - const [searchError, setSearchError] = useState(undefined); - const [searchString, setSearchString] = useState(undefined); - - const predictedFieldName = getPredictedFieldName( - jobConfig.dest.results_field, - jobConfig.analysis - ); - - const dependentVariable = getDependentVar(jobConfig.analysis); - - function toggleColumnsPopover() { - setColumnsPopoverVisible(!isColumnsPopoverVisible); - } - - function closeColumnsPopover() { - setColumnsPopoverVisible(false); - } - - function toggleColumn(column: EsFieldName) { - if (tableItems.length > 0 && jobConfig !== undefined) { - // spread to a new array otherwise the component wouldn't re-render - setSelectedFields([ - ...toggleSelectedField(selectedFields, column, jobConfig.dest.results_field, depVarType), - ]); - } - } - const needsDestIndexFields = indexPattern && indexPattern.title === jobConfig.source.index[0]; - + const resultsField = jobConfig.dest.results_field; const { errorMessage, - loadExploreData, - sortField, - sortDirection, - status, - tableItems, - } = useExploreData( - jobConfig, - needsDestIndexFields, + fieldTypes, + pagination, + searchQuery, selectedFields, + rowCount, + setPagination, + setSearchQuery, setSelectedFields, - setDocFields, - setDepVarType - ); + setSortingColumns, + sortingColumns, + status, + tableFields, + tableItems, + } = useExploreData(jobConfig, needsDestIndexFields); - const columns: Array> = selectedFields - .sort(({ name: a }, { name: b }) => sortRegressionResultsFields(a, b, jobConfig)) - .map(field => { - const { type } = field; - let format: any; + useEffect(() => { + setEvaluateSearchQuery(searchQuery); + }, [JSON.stringify(searchQuery)]); - if (indexPattern !== undefined) { - format = mlFieldFormatService.getFieldFormatFromIndexPattern(indexPattern, field.id, ''); - } + const columns = tableFields + .sort((a: any, b: any) => sortRegressionResultsFields(a, b, jobConfig)) + .map((field: any) => { + // Built-in values are ['boolean', 'currency', 'datetime', 'numeric', 'json'] + // To fall back to the default string schema it needs to be undefined. + let schema; + let isSortable = true; + const type = fieldTypes[field]; const isNumber = type !== undefined && (BASIC_NUMERICAL_TYPES.has(type) || EXTENDED_NUMERICAL_TYPES.has(type)); - const column: ColumnType = { - field: field.name, - name: field.name, - sortable: true, - truncateText: true, - }; - - const render = (d: any, fullItem: EsDoc) => { - if (format !== undefined) { - d = format.convert(d, 'text'); - return d; - } - - if (Array.isArray(d) && d.every(item => typeof item === 'string')) { - // If the cells data is an array of strings, return as a comma separated list. - // The list will get limited to 5 items with `…` at the end if there's more in the original array. - return `${d.slice(0, 5).join(', ')}${d.length > 5 ? ', …' : ''}`; - } else if (Array.isArray(d)) { - // If the cells data is an array of e.g. objects, display a 'array' badge with a - // tooltip that explains that this type of field is not supported in this table. - return ( - - - {i18n.translate( - 'xpack.ml.dataframe.analytics.classificationExploration.indexArrayBadgeContent', - { - defaultMessage: 'array', - } - )} - - - ); - } - - return d; - }; - if (isNumber) { - column.dataType = 'number'; - column.render = render; - } else if (typeof type !== 'undefined') { - switch (type) { - case ES_FIELD_TYPES.BOOLEAN: - column.dataType = ES_FIELD_TYPES.BOOLEAN; - column.render = d => (d ? 'true' : 'false'); - break; - case ES_FIELD_TYPES.DATE: - column.align = 'right'; - if (format !== undefined) { - column.render = render; - } else { - column.render = (d: any) => { - if (d !== undefined) { - return formatHumanReadableDateTimeSeconds(moment(d).unix() * 1000); - } - return d; - }; - } - break; - default: - column.render = render; - break; - } - } else { - column.render = render; + schema = 'numeric'; } - return column; - }); - - const docFieldsCount = docFields.length; - - useEffect(() => { - if ( - jobConfig !== undefined && - columns.length > 0 && - selectedFields.length > 0 && - sortField !== undefined && - sortDirection !== undefined && - selectedFields.some(field => field.name === sortField) - ) { - let field = sortField; - // If sorting by predictedField use dependentVar type - if (predictedFieldName === sortField) { - field = dependentVariable; + switch (type) { + case 'date': + schema = 'datetime'; + break; + case 'geo_point': + schema = 'json'; + break; + case 'boolean': + schema = 'boolean'; + break; } - const requiresKeyword = isKeywordAndTextType(field); - - loadExploreData({ - field: sortField, - direction: sortDirection, - searchQuery, - requiresKeyword, - }); - } - }, [JSON.stringify(searchQuery)]); - - useEffect(() => { - // By default set sorting to descending on the prediction field (`_prediction`). - // if that's not available sort ascending on the first column. Check if the current sorting field is still available. - if ( - jobConfig !== undefined && - columns.length > 0 && - selectedFields.length > 0 && - !selectedFields.some(field => field.name === sortField) - ) { - const predictedFieldSelected = selectedFields.some( - field => field.name === predictedFieldName - ); - - // CHECK IF keyword suffix is needed (if predicted field is selected we have to check the dependent variable type) - let sortByField = predictedFieldSelected ? dependentVariable : selectedFields[0].name; - - const requiresKeyword = isKeywordAndTextType(sortByField); - - sortByField = predictedFieldSelected ? predictedFieldName : sortByField; - - const direction = predictedFieldSelected ? SORT_DIRECTION.DESC : SORT_DIRECTION.ASC; - loadExploreData({ field: sortByField, direction, searchQuery, requiresKeyword }); - } - }, [ - jobConfig, - columns.length, - selectedFields.length, - sortField, - sortDirection, - tableItems.length, - ]); - - let sorting: SortingPropType = false; - let onTableChange; - - if (columns.length > 0 && sortField !== '' && sortField !== undefined) { - sorting = { - sort: { - field: sortField, - direction: sortDirection, - }, - }; - - onTableChange = ({ - page = { index: 0, size: 10 }, - sort = { field: sortField, direction: sortDirection }, - }: OnTableChangeArg) => { - const { index, size } = page; - setPageIndex(index); - setPageSize(size); - if (sort.field !== sortField || sort.direction !== sortDirection) { - let field = sort.field; - // If sorting by predictedField use depVar for type check - if (predictedFieldName === sort.field) { - field = dependentVariable; - } - - loadExploreData({ - ...sort, - searchQuery, - requiresKeyword: isKeywordAndTextType(field), - }); + if (field === `${resultsField}.feature_importance`) { + isSortable = false; } - }; - } - const pagination = { - initialPageIndex: pageIndex, - initialPageSize: pageSize, - totalItemCount: tableItems.length, - pageSizeOptions: PAGE_SIZE_OPTIONS, - hidePerPageOptions: false, - }; - - const onQueryChange = ({ query, error }: { query: QueryType; error: any }) => { - if (error) { - setSearchError(error.message); - } else { - try { - const esQueryDsl = Query.toESQuery(query); - setSearchQuery(esQueryDsl); - setSearchString(query.text); - setSearchError(undefined); - // set query for use in evaluate panel - setEvaluateSearchQuery(esQueryDsl); - } catch (e) { - setSearchError(e.toString()); - } - } - }; + return { id: field, schema, isSortable }; + }); - const search = { - onChange: onQueryChange, - defaultQuery: searchString, - box: { - incremental: false, - placeholder: i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.searchBoxPlaceholder', - { - defaultMessage: 'E.g. avg>0.5', - } - ), - }, - filters: [ - { - type: 'field_value_toggle_group', - field: `${jobConfig.dest.results_field}.is_training`, - items: [ - { - value: false, - name: i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.isTestingLabel', - { - defaultMessage: 'Testing', - } - ), - }, - { - value: true, - name: i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.isTrainingLabel', - { - defaultMessage: 'Training', - } - ), - }, - ], - }, - ], - }; + const docFieldsCount = tableFields.length; if (jobConfig === undefined) { return null; @@ -426,11 +152,6 @@ export const ResultsTable: FC = React.memo( ); } - const tableError = - status === INDEX_STATUS.ERROR && errorMessage.includes('parsing_exception') - ? errorMessage - : searchError; - return ( = React.memo( {docFieldsCount > MAX_COLUMNS && ( {i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.fieldSelection', + 'xpack.ml.dataframe.analytics.classificationExploration.fieldSelection', { defaultMessage: '{selectedFieldsLength, number} of {docFieldsCount, number} {docFieldsCount, plural, one {field} other {fields}} selected', @@ -466,52 +187,6 @@ export const ResultsTable: FC = React.memo( )}
- - - - } - isOpen={isColumnsPopoverVisible} - closePopover={closeColumnsPopover} - ownFocus - > - - {i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.selectFieldsPopoverTitle', - { - defaultMessage: 'Select fields', - } - )} - -
- {docFields.map(({ name }) => ( - field.name === name)} - onChange={() => toggleColumn(name)} - disabled={ - selectedFields.some(field => field.name === name) && - selectedFields.length === 1 - } - /> - ))} -
-
-
-
@@ -520,28 +195,39 @@ export const ResultsTable: FC = React.memo( )} {(columns.length > 0 || searchQuery !== defaultSearchQuery) && ( - - - - - - - + + + + + + + + + + + + + + + + )} ); diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/use_explore_data.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/use_explore_data.ts index 6038def592e5c..c8809ca5e471b 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/use_explore_data.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/classification_exploration/use_explore_data.ts @@ -3,87 +3,124 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState, Dispatch, SetStateAction } from 'react'; +import { EuiDataGridPaginationProps, EuiDataGridSorting } from '@elastic/eui'; import { SearchResponse } from 'elasticsearch'; import { cloneDeep } from 'lodash'; -import { SortDirection, SORT_DIRECTION } from '../../../../../components/ml_in_memory_table'; +import { SORT_DIRECTION } from '../../../../../components/ml_in_memory_table'; import { ml } from '../../../../../services/ml_api_service'; import { getNestedProperty } from '../../../../../util/object_utils'; import { newJobCapsService } from '../../../../../services/new_job_capabilities_service'; -import { Field } from '../../../../../../../common/types/fields'; +import { isKeywordAndTextType } from '../../../../common/fields'; +import { Dictionary } from '../../../../../../../common/types/common'; import { ES_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; import { - LoadExploreDataArg, defaultSearchQuery, ResultsSearchQuery, isResultsSearchBoolQuery, + LoadExploreDataArg, } from '../../../../common/analytics'; import { getDefaultFieldsFromJobCaps, + getDependentVar, getFlattenedFields, + getPredictedFieldName, DataFrameAnalyticsConfig, EsFieldName, INDEX_STATUS, - SEARCH_SIZE, - SearchQuery, } from '../../../../common'; +import { SavedSearchQuery } from '../../../../../contexts/ml'; export type TableItem = Record; +type Pagination = Pick; export interface UseExploreDataReturnType { errorMessage: string; - loadExploreData: (arg: LoadExploreDataArg) => void; - sortField: EsFieldName; - sortDirection: SortDirection; + fieldTypes: { [key: string]: ES_FIELD_TYPES }; + pagination: Pagination; + rowCount: number; + searchQuery: SavedSearchQuery; + selectedFields: EsFieldName[]; + setFilterByIsTraining: Dispatch>; + setPagination: Dispatch>; + setSearchQuery: Dispatch>; + setSelectedFields: Dispatch>; + setSortingColumns: Dispatch>; + sortingColumns: EuiDataGridSorting['columns']; status: INDEX_STATUS; + tableFields: string[]; tableItems: TableItem[]; } +type EsSorting = Dictionary<{ + order: 'asc' | 'desc'; +}>; + +// The types specified in `@types/elasticsearch` are out of date and still have `total: number`. +interface SearchResponse7 extends SearchResponse { + hits: SearchResponse['hits'] & { + total: { + value: number; + relation: string; + }; + }; +} + export const useExploreData = ( - jobConfig: DataFrameAnalyticsConfig | undefined, - needsDestIndexFields: boolean, - selectedFields: Field[], - setSelectedFields: React.Dispatch>, - setDocFields: React.Dispatch>, - setDepVarType: React.Dispatch> + jobConfig: DataFrameAnalyticsConfig, + needsDestIndexFields: boolean ): UseExploreDataReturnType => { const [errorMessage, setErrorMessage] = useState(''); const [status, setStatus] = useState(INDEX_STATUS.UNUSED); + + const [selectedFields, setSelectedFields] = useState([] as EsFieldName[]); + const [tableFields, setTableFields] = useState([]); const [tableItems, setTableItems] = useState([]); - const [sortField, setSortField] = useState(''); - const [sortDirection, setSortDirection] = useState(SORT_DIRECTION.ASC); + const [fieldTypes, setFieldTypes] = useState<{ [key: string]: ES_FIELD_TYPES }>({}); + const [rowCount, setRowCount] = useState(0); + + const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 25 }); + const [searchQuery, setSearchQuery] = useState(defaultSearchQuery); + const [filterByIsTraining, setFilterByIsTraining] = useState(undefined); + const [sortingColumns, setSortingColumns] = useState([]); + + const predictedFieldName = getPredictedFieldName( + jobConfig.dest.results_field, + jobConfig.analysis + ); + const dependentVariable = getDependentVar(jobConfig.analysis); const getDefaultSelectedFields = () => { const { fields } = newJobCapsService; - if (selectedFields.length === 0 && jobConfig !== undefined) { - const { - selectedFields: defaultSelected, - docFields, - depVarType, - } = getDefaultFieldsFromJobCaps(fields, jobConfig, needsDestIndexFields); - - setDepVarType(depVarType); - setSelectedFields(defaultSelected); - setDocFields(docFields); + const { selectedFields: defaultSelected, docFields } = getDefaultFieldsFromJobCaps( + fields, + jobConfig, + needsDestIndexFields + ); + + const types: { [key: string]: ES_FIELD_TYPES } = {}; + const allFields: string[] = []; + + docFields.forEach(field => { + types[field.id] = field.type; + allFields.push(field.id); + }); + + setFieldTypes(types); + setSelectedFields(defaultSelected.map(field => field.id)); + setTableFields(allFields); } }; const loadExploreData = async ({ - field, - direction, - searchQuery, - requiresKeyword, + filterByIsTraining: isTraining, + searchQuery: incomingQuery, }: LoadExploreDataArg) => { if (jobConfig !== undefined) { setErrorMessage(''); @@ -91,15 +128,33 @@ export const useExploreData = ( try { const resultsField = jobConfig.dest.results_field; - const searchQueryClone: ResultsSearchQuery = cloneDeep(searchQuery); + const searchQueryClone: ResultsSearchQuery = cloneDeep(incomingQuery); let query: ResultsSearchQuery; + const { pageIndex, pageSize } = pagination; + // If filterByIsTraining is defined - add that in to the final query + const trainingQuery = + isTraining !== undefined + ? { + term: { [`${resultsField}.is_training`]: { value: isTraining } }, + } + : undefined; - if (JSON.stringify(searchQuery) === JSON.stringify(defaultSearchQuery)) { - query = { + if (JSON.stringify(incomingQuery) === JSON.stringify(defaultSearchQuery)) { + const existsQuery = { exists: { field: resultsField, }, }; + + query = { + bool: { + must: [existsQuery], + }, + }; + + if (trainingQuery !== undefined && isResultsSearchBoolQuery(query)) { + query.bool.must.push(trainingQuery); + } } else if (isResultsSearchBoolQuery(searchQueryClone)) { if (searchQueryClone.bool.must === undefined) { searchQueryClone.bool.must = []; @@ -111,33 +166,37 @@ export const useExploreData = ( }, }); + if (trainingQuery !== undefined) { + searchQueryClone.bool.must.push(trainingQuery); + } + query = searchQueryClone; } else { query = searchQueryClone; } - const body: SearchQuery = { - query, - }; + const sort: EsSorting = sortingColumns + .map(column => { + const { id } = column; + column.id = isKeywordAndTextType(id) ? `${id}.keyword` : id; + return column; + }) + .reduce((s, column) => { + s[column.id] = { order: column.direction }; + return s; + }, {} as EsSorting); - if (field !== undefined) { - body.sort = [ - { - [`${field}${requiresKeyword ? '.keyword' : ''}`]: { - order: direction, - }, - }, - ]; - } - - const resp: SearchResponse = await ml.esSearch({ + const resp: SearchResponse7 = await ml.esSearch({ index: jobConfig.dest.index, - size: SEARCH_SIZE, - body, + body: { + query, + from: pageIndex * pageSize, + size: pageSize, + ...(Object.keys(sort).length > 0 ? { sort } : {}), + }, }); - setSortField(field); - setSortDirection(direction); + setRowCount(resp.hits.total.value); const docs = resp.hits.hits; @@ -189,10 +248,45 @@ export const useExploreData = ( }; useEffect(() => { - if (jobConfig !== undefined) { - getDefaultSelectedFields(); - } + getDefaultSelectedFields(); + }, [jobConfig && jobConfig.id]); + + // By default set sorting to descending on the prediction field (`_prediction`). + useEffect(() => { + const sortByField = isKeywordAndTextType(dependentVariable) + ? `${predictedFieldName}.keyword` + : predictedFieldName; + const direction = SORT_DIRECTION.DESC; + + setSortingColumns([{ id: sortByField, direction }]); }, [jobConfig && jobConfig.id]); - return { errorMessage, loadExploreData, sortField, sortDirection, status, tableItems }; + useEffect(() => { + loadExploreData({ filterByIsTraining, searchQuery }); + }, [ + filterByIsTraining, + jobConfig && jobConfig.id, + pagination, + searchQuery, + selectedFields, + sortingColumns, + ]); + + return { + errorMessage, + fieldTypes, + pagination, + searchQuery, + selectedFields, + rowCount, + setFilterByIsTraining, + setPagination, + setSelectedFields, + setSortingColumns, + setSearchQuery, + sortingColumns, + status, + tableItems, + tableFields, + }; }; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/evaluate_panel.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/evaluate_panel.tsx index 9f235ae6c45c0..6ef6666be5ec6 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/evaluate_panel.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/evaluate_panel.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { FC, Fragment, useEffect, useState } from 'react'; +import React, { FC, useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { @@ -17,7 +17,7 @@ import { EuiTitle, } from '@elastic/eui'; import { useMlKibana } from '../../../../../contexts/kibana'; -import { ErrorCallout } from '../error_callout'; +import { SavedSearchQuery } from '../../../../../contexts/ml'; import { getValuesFromResponse, getDependentVar, @@ -33,14 +33,13 @@ import { EvaluateStat } from './evaluate_stat'; import { isResultsSearchBoolQuery, isRegressionEvaluateResponse, - ResultsSearchQuery, ANALYSIS_CONFIG_TYPE, } from '../../../../common/analytics'; interface Props { jobConfig: DataFrameAnalyticsConfig; jobStatus?: DATA_FRAME_TASK_STATE; - searchQuery: ResultsSearchQuery; + searchQuery: SavedSearchQuery; } const defaultEval: Eval = { meanSquaredError: '', rSquared: '', error: null }; @@ -54,6 +53,7 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery }) const [generalizationEval, setGeneralizationEval] = useState(defaultEval); const [isLoadingTraining, setIsLoadingTraining] = useState(false); const [isLoadingGeneralization, setIsLoadingGeneralization] = useState(false); + const [isTrainingFilter, setIsTrainingFilter] = useState(undefined); const [trainingDocsCount, setTrainingDocsCount] = useState(null); const [generalizationDocsCount, setGeneralizationDocsCount] = useState(null); @@ -92,8 +92,8 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery }) } else { setIsLoadingGeneralization(false); setGeneralizationEval({ - meanSquaredError: '', - rSquared: '', + meanSquaredError: '--', + rSquared: '--', error: genErrorEval.error, }); } @@ -128,108 +128,78 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery }) } else { setIsLoadingTraining(false); setTrainingEval({ - meanSquaredError: '', - rSquared: '', + meanSquaredError: '--', + rSquared: '--', error: trainingErrorEval.error, }); } }; - const loadData = async ({ - isTrainingClause, - }: { - isTrainingClause?: { query: string; operator: string }; - }) => { - // searchBar query is filtering for testing data - if (isTrainingClause !== undefined && isTrainingClause.query === 'false') { - loadGeneralizationData(); - - const docsCountResp = await loadDocsCount({ - isTraining: false, - searchQuery, - resultsField, - destIndex: jobConfig.dest.index, - }); - - if (docsCountResp.success === true) { - setGeneralizationDocsCount(docsCountResp.docsCount); - } else { - setGeneralizationDocsCount(null); - } - - setTrainingDocsCount(0); - setTrainingEval({ - meanSquaredError: '--', - rSquared: '--', - error: null, - }); - } else if (isTrainingClause !== undefined && isTrainingClause.query === 'true') { - // searchBar query is filtering for training data - loadTrainingData(); - - const docsCountResp = await loadDocsCount({ - isTraining: true, - searchQuery, - resultsField, - destIndex: jobConfig.dest.index, - }); - - if (docsCountResp.success === true) { - setTrainingDocsCount(docsCountResp.docsCount); - } else { - setTrainingDocsCount(null); - } - - setGeneralizationDocsCount(0); - setGeneralizationEval({ - meanSquaredError: '--', - rSquared: '--', - error: null, - }); + const loadData = async () => { + loadGeneralizationData(false); + const genDocsCountResp = await loadDocsCount({ + ignoreDefaultQuery: false, + isTraining: false, + searchQuery, + resultsField, + destIndex: jobConfig.dest.index, + }); + if (genDocsCountResp.success === true) { + setGeneralizationDocsCount(genDocsCountResp.docsCount); } else { - // No is_training clause/filter from search bar so load both - loadGeneralizationData(false); - const genDocsCountResp = await loadDocsCount({ - ignoreDefaultQuery: false, - isTraining: false, - searchQuery, - resultsField, - destIndex: jobConfig.dest.index, - }); - if (genDocsCountResp.success === true) { - setGeneralizationDocsCount(genDocsCountResp.docsCount); - } else { - setGeneralizationDocsCount(null); - } + setGeneralizationDocsCount(null); + } - loadTrainingData(false); - const trainDocsCountResp = await loadDocsCount({ - ignoreDefaultQuery: false, - isTraining: true, - searchQuery, - resultsField, - destIndex: jobConfig.dest.index, - }); - if (trainDocsCountResp.success === true) { - setTrainingDocsCount(trainDocsCountResp.docsCount); - } else { - setTrainingDocsCount(null); - } + loadTrainingData(false); + const trainDocsCountResp = await loadDocsCount({ + ignoreDefaultQuery: false, + isTraining: true, + searchQuery, + resultsField, + destIndex: jobConfig.dest.index, + }); + if (trainDocsCountResp.success === true) { + setTrainingDocsCount(trainDocsCountResp.docsCount); + } else { + setTrainingDocsCount(null); } }; useEffect(() => { - const hasIsTrainingClause = - isResultsSearchBoolQuery(searchQuery) && - searchQuery.bool.must.filter( - (clause: any) => clause.match && clause.match[`${resultsField}.is_training`] !== undefined - ); - const isTrainingClause = - hasIsTrainingClause && - hasIsTrainingClause[0] && - hasIsTrainingClause[0].match[`${resultsField}.is_training`]; + let isTraining: boolean | undefined; + const query = + isResultsSearchBoolQuery(searchQuery) && (searchQuery.bool.should || searchQuery.bool.filter); + + if (query !== undefined && query !== false) { + for (let i = 0; i < query.length; i++) { + const clause = query[i]; - loadData({ isTrainingClause }); + if (clause.match && clause.match[`${resultsField}.is_training`] !== undefined) { + isTraining = clause.match[`${resultsField}.is_training`]; + break; + } else if ( + clause.bool && + (clause.bool.should !== undefined || clause.bool.filter !== undefined) + ) { + const innerQuery = clause.bool.should || clause.bool.filter; + if (innerQuery !== undefined) { + for (let j = 0; j < innerQuery.length; j++) { + const innerClause = innerQuery[j]; + if ( + innerClause.match && + innerClause.match[`${resultsField}.is_training`] !== undefined + ) { + isTraining = innerClause.match[`${resultsField}.is_training`]; + break; + } + } + } + } + } + } + + setIsTrainingFilter(isTraining); + loadData(); }, [JSON.stringify(searchQuery)]); return ( @@ -293,13 +263,18 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery }) defaultMessage="{docsCount, plural, one {# doc} other {# docs}} evaluated" values={{ docsCount: generalizationDocsCount }} /> + {isTrainingFilter === true && generalizationDocsCount === 0 && ( + + )} )} - - {generalizationEval.error !== null && } - {generalizationEval.error === null && ( - + + + = ({ jobConfig, jobStatus, searchQuery }) isMSE={false} /> - + + + {generalizationEval.error !== null && ( + + + {generalizationEval.error} + + )} @@ -338,13 +320,18 @@ export const EvaluatePanel: FC = ({ jobConfig, jobStatus, searchQuery }) defaultMessage="{docsCount, plural, one {# doc} other {# docs}} evaluated" values={{ docsCount: trainingDocsCount }} /> + {isTrainingFilter === false && trainingDocsCount === 0 && ( + + )} )} - - {trainingEval.error !== null && } - {trainingEval.error === null && ( - + + + = ({ jobConfig, jobStatus, searchQuery }) isMSE={false} /> - + + + {trainingEval.error !== null && ( + + + {trainingEval.error} + + )} diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/regression_exploration_data_grid.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/regression_exploration_data_grid.tsx new file mode 100644 index 0000000000000..0fcb1ed600719 --- /dev/null +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/regression_exploration_data_grid.tsx @@ -0,0 +1,135 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import React, { Dispatch, FC, SetStateAction, useCallback, useMemo } from 'react'; + +import { i18n } from '@kbn/i18n'; + +import { EuiDataGrid, EuiDataGridPaginationProps, EuiDataGridSorting } from '@elastic/eui'; + +import { euiDataGridStyle, euiDataGridToolbarSettings } from '../../../../common'; + +import { mlFieldFormatService } from '../../../../../services/field_format_service'; + +import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; + +const PAGE_SIZE_OPTIONS = [5, 10, 25, 50]; + +type Pagination = Pick; +type TableItem = Record; + +interface ExplorationDataGridProps { + colorRange?: (d: number) => string; + columns: any[]; + indexPattern: IndexPattern; + pagination: Pagination; + resultsField: string; + rowCount: number; + selectedFields: string[]; + setPagination: Dispatch>; + setSelectedFields: Dispatch>; + setSortingColumns: Dispatch>; + sortingColumns: EuiDataGridSorting['columns']; + tableItems: TableItem[]; +} + +export const RegressionExplorationDataGrid: FC = ({ + columns, + indexPattern, + pagination, + resultsField, + rowCount, + selectedFields, + setPagination, + setSelectedFields, + setSortingColumns, + sortingColumns, + tableItems, +}) => { + const renderCellValue = useMemo(() => { + return ({ rowIndex, columnId }: { rowIndex: number; columnId: string; setCellProps: any }) => { + const adjustedRowIndex = rowIndex - pagination.pageIndex * pagination.pageSize; + + const fullItem = tableItems[adjustedRowIndex]; + + if (fullItem === undefined) { + return null; + } + + let format: any; + + if (indexPattern !== undefined) { + format = mlFieldFormatService.getFieldFormatFromIndexPattern(indexPattern, columnId, ''); + } + + const cellValue = + fullItem.hasOwnProperty(columnId) && fullItem[columnId] !== undefined + ? fullItem[columnId] + : null; + + if (format !== undefined) { + return format.convert(cellValue, 'text'); + } + + if (typeof cellValue === 'string' || cellValue === null) { + return cellValue; + } + + if (typeof cellValue === 'boolean') { + return cellValue ? 'true' : 'false'; + } + + if (typeof cellValue === 'object' && cellValue !== null) { + return JSON.stringify(cellValue); + } + + return cellValue; + }; + }, [resultsField, rowCount, tableItems, pagination.pageIndex, pagination.pageSize]); + + const onChangeItemsPerPage = useCallback( + pageSize => { + setPagination(p => { + const pageIndex = Math.floor((p.pageSize * p.pageIndex) / pageSize); + return { pageIndex, pageSize }; + }); + }, + [setPagination] + ); + + const onChangePage = useCallback(pageIndex => setPagination(p => ({ ...p, pageIndex })), [ + setPagination, + ]); + + const onSort = useCallback(sc => setSortingColumns(sc), [setSortingColumns]); + + return ( + + ); +}; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/results_table.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/results_table.tsx index a35be5400f46b..43fa50b2e4df5 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/results_table.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/results_table.tsx @@ -4,72 +4,41 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { Fragment, FC, useEffect, useState } from 'react'; -import moment from 'moment-timezone'; +import React, { Fragment, FC, useEffect } from 'react'; import { i18n } from '@kbn/i18n'; import { - EuiBadge, - EuiButtonIcon, EuiCallOut, - EuiCheckbox, EuiFlexGroup, EuiFlexItem, EuiFormRow, EuiPanel, - EuiPopover, - EuiPopoverTitle, EuiProgress, EuiSpacer, EuiText, - EuiToolTip, - Query, } from '@elastic/eui'; -import { Query as QueryType } from '../../../analytics_management/components/analytics_list/common'; -import { ES_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; -import { mlFieldFormatService } from '../../../../../services/field_format_service'; - -import { - ColumnType, - mlInMemoryTableBasicFactory, - OnTableChangeArg, - SortingPropType, - SORT_DIRECTION, -} from '../../../../../components/ml_in_memory_table'; - -import { formatHumanReadableDateTimeSeconds } from '../../../../../util/date_utils'; -import { Field } from '../../../../../../../common/types/fields'; -import { SavedSearchQuery } from '../../../../../contexts/ml'; import { BASIC_NUMERICAL_TYPES, EXTENDED_NUMERICAL_TYPES, - toggleSelectedField, - isKeywordAndTextType, sortRegressionResultsFields, } from '../../../../common/fields'; import { DataFrameAnalyticsConfig, - EsFieldName, - EsDoc, MAX_COLUMNS, - getPredictedFieldName, INDEX_STATUS, SEARCH_SIZE, defaultSearchQuery, - getDependentVar, } from '../../../../common'; import { getTaskStateBadge } from '../../../analytics_management/components/analytics_list/columns'; import { DATA_FRAME_TASK_STATE } from '../../../analytics_management/components/analytics_list/common'; import { IndexPattern } from '../../../../../../../../../../src/plugins/data/public'; -import { useExploreData, TableItem } from './use_explore_data'; +import { useExploreData } from './use_explore_data'; import { ExplorationTitle } from './regression_exploration'; - -const PAGE_SIZE_OPTIONS = [5, 10, 25, 50]; - -const MlInMemoryTableBasic = mlInMemoryTableBasicFactory(); +import { RegressionExplorationDataGrid } from './regression_exploration_data_grid'; +import { ExplorationQueryBar } from '../exploration_query_bar'; const showingDocs = i18n.translate( 'xpack.ml.dataframe.analytics.regressionExploration.documentsShownHelpText', @@ -95,308 +64,65 @@ interface Props { export const ResultsTable: FC = React.memo( ({ indexPattern, jobConfig, jobStatus, setEvaluateSearchQuery }) => { - const [pageIndex, setPageIndex] = useState(0); - const [pageSize, setPageSize] = useState(25); - const [selectedFields, setSelectedFields] = useState([] as Field[]); - const [docFields, setDocFields] = useState([] as Field[]); - const [depVarType, setDepVarType] = useState(undefined); - const [isColumnsPopoverVisible, setColumnsPopoverVisible] = useState(false); - const [searchQuery, setSearchQuery] = useState(defaultSearchQuery); - const [searchError, setSearchError] = useState(undefined); - const [searchString, setSearchString] = useState(undefined); - - const predictedFieldName = getPredictedFieldName( - jobConfig.dest.results_field, - jobConfig.analysis - ); - - const dependentVariable = getDependentVar(jobConfig.analysis); - - function toggleColumnsPopover() { - setColumnsPopoverVisible(!isColumnsPopoverVisible); - } - - function closeColumnsPopover() { - setColumnsPopoverVisible(false); - } - - function toggleColumn(column: EsFieldName) { - if (tableItems.length > 0 && jobConfig !== undefined) { - // spread to a new array otherwise the component wouldn't re-render - setSelectedFields([ - ...toggleSelectedField(selectedFields, column, jobConfig.dest.results_field, depVarType), - ]); - } - } - const needsDestIndexFields = indexPattern && indexPattern.title === jobConfig.source.index[0]; - + const resultsField = jobConfig.dest.results_field; const { errorMessage, - loadExploreData, - sortField, - sortDirection, - status, - tableItems, - } = useExploreData( - jobConfig, - needsDestIndexFields, + fieldTypes, + pagination, + searchQuery, selectedFields, + rowCount, + setPagination, + setSearchQuery, setSelectedFields, - setDocFields, - setDepVarType - ); - - const columns: Array> = selectedFields - .sort(({ name: a }, { name: b }) => sortRegressionResultsFields(a, b, jobConfig)) - .map(field => { - const { type } = field; - let format: any; + setSortingColumns, + sortingColumns, + status, + tableFields, + tableItems, + } = useExploreData(jobConfig, needsDestIndexFields); - if (indexPattern !== undefined) { - format = mlFieldFormatService.getFieldFormatFromIndexPattern(indexPattern, field.id, ''); - } + useEffect(() => { + setEvaluateSearchQuery(searchQuery); + }, [JSON.stringify(searchQuery)]); + const columns = tableFields + .sort((a: any, b: any) => sortRegressionResultsFields(a, b, jobConfig)) + .map((field: any) => { + // Built-in values are ['boolean', 'currency', 'datetime', 'numeric', 'json'] + // To fall back to the default string schema it needs to be undefined. + let schema; + let isSortable = true; + const type = fieldTypes[field]; const isNumber = type !== undefined && (BASIC_NUMERICAL_TYPES.has(type) || EXTENDED_NUMERICAL_TYPES.has(type)); - const column: ColumnType = { - field: field.name, - name: field.name, - sortable: true, - truncateText: true, - }; - - const render = (d: any, fullItem: EsDoc) => { - if (format !== undefined) { - d = format.convert(d, 'text'); - return d; - } - - if (Array.isArray(d) && d.every(item => typeof item === 'string')) { - // If the cells data is an array of strings, return as a comma separated list. - // The list will get limited to 5 items with `…` at the end if there's more in the original array. - return `${d.slice(0, 5).join(', ')}${d.length > 5 ? ', …' : ''}`; - } else if (Array.isArray(d)) { - // If the cells data is an array of e.g. objects, display a 'array' badge with a - // tooltip that explains that this type of field is not supported in this table. - return ( - - - {i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.indexArrayBadgeContent', - { - defaultMessage: 'array', - } - )} - - - ); - } - - return d; - }; - if (isNumber) { - column.dataType = 'number'; - column.render = render; - } else if (typeof type !== 'undefined') { - switch (type) { - case ES_FIELD_TYPES.BOOLEAN: - column.dataType = ES_FIELD_TYPES.BOOLEAN; - column.render = d => (d ? 'true' : 'false'); - break; - case ES_FIELD_TYPES.DATE: - column.align = 'right'; - if (format !== undefined) { - column.render = render; - } else { - column.render = (d: any) => { - if (d !== undefined) { - return formatHumanReadableDateTimeSeconds(moment(d).unix() * 1000); - } - return d; - }; - } - break; - default: - column.render = render; - break; - } - } else { - column.render = render; + schema = 'numeric'; } - return column; - }); - - const docFieldsCount = docFields.length; - - useEffect(() => { - if ( - jobConfig !== undefined && - columns.length > 0 && - selectedFields.length > 0 && - sortField !== undefined && - sortDirection !== undefined && - selectedFields.some(field => field.name === sortField) - ) { - let field = sortField; - // If sorting by predictedField use dependentVar type - if (predictedFieldName === sortField) { - field = dependentVariable; + switch (type) { + case 'date': + schema = 'datetime'; + break; + case 'geo_point': + schema = 'json'; + break; + case 'boolean': + schema = 'boolean'; + break; } - const requiresKeyword = isKeywordAndTextType(field); - - loadExploreData({ - field: sortField, - direction: sortDirection, - searchQuery, - requiresKeyword, - }); - } - }, [JSON.stringify(searchQuery)]); - - useEffect(() => { - // By default set sorting to descending on the prediction field (`_prediction`). - // if that's not available sort ascending on the first column. Check if the current sorting field is still available. - if ( - jobConfig !== undefined && - columns.length > 0 && - selectedFields.length > 0 && - !selectedFields.some(field => field.name === sortField) - ) { - const predictedFieldSelected = selectedFields.some( - field => field.name === predictedFieldName - ); - - // CHECK IF keyword suffix is needed (if predicted field is selected we have to check the dependent variable type) - let sortByField = predictedFieldSelected ? dependentVariable : selectedFields[0].name; - - const requiresKeyword = isKeywordAndTextType(sortByField); - - sortByField = predictedFieldSelected ? predictedFieldName : sortByField; - - const direction = predictedFieldSelected ? SORT_DIRECTION.DESC : SORT_DIRECTION.ASC; - loadExploreData({ field: sortByField, direction, searchQuery, requiresKeyword }); - } - }, [ - jobConfig, - columns.length, - selectedFields.length, - sortField, - sortDirection, - tableItems.length, - ]); - - let sorting: SortingPropType = false; - let onTableChange; - - if (columns.length > 0 && sortField !== '' && sortField !== undefined) { - sorting = { - sort: { - field: sortField, - direction: sortDirection, - }, - }; - - onTableChange = ({ - page = { index: 0, size: 10 }, - sort = { field: sortField, direction: sortDirection }, - }: OnTableChangeArg) => { - const { index, size } = page; - setPageIndex(index); - setPageSize(size); - - if (sort.field !== sortField || sort.direction !== sortDirection) { - let field = sort.field; - // If sorting by predictedField use depVar for type check - if (predictedFieldName === sort.field) { - field = dependentVariable; - } - loadExploreData({ - ...sort, - searchQuery, - requiresKeyword: isKeywordAndTextType(field), - }); + if (field === `${resultsField}.feature_importance`) { + isSortable = false; } - }; - } - - const pagination = { - initialPageIndex: pageIndex, - initialPageSize: pageSize, - totalItemCount: tableItems.length, - pageSizeOptions: PAGE_SIZE_OPTIONS, - hidePerPageOptions: false, - }; - const onQueryChange = ({ query, error }: { query: QueryType; error: any }) => { - if (error) { - setSearchError(error.message); - } else { - try { - const esQueryDsl = Query.toESQuery(query); - setSearchQuery(esQueryDsl); - setSearchString(query.text); - setSearchError(undefined); - // set query for use in evaluate panel - setEvaluateSearchQuery(esQueryDsl); - } catch (e) { - setSearchError(e.toString()); - } - } - }; + return { id: field, schema, isSortable }; + }); - const search = { - onChange: onQueryChange, - defaultQuery: searchString, - box: { - incremental: false, - placeholder: i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.searchBoxPlaceholder', - { - defaultMessage: 'E.g. avg>0.5', - } - ), - }, - filters: [ - { - type: 'field_value_toggle_group', - field: `${jobConfig.dest.results_field}.is_training`, - items: [ - { - value: false, - name: i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.isTestingLabel', - { - defaultMessage: 'Testing', - } - ), - }, - { - value: true, - name: i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.isTrainingLabel', - { - defaultMessage: 'Training', - } - ), - }, - ], - }, - ], - }; + const docFieldsCount = tableFields.length; if (jobConfig === undefined) { return null; @@ -428,11 +154,6 @@ export const ResultsTable: FC = React.memo( ); } - const tableError = - status === INDEX_STATUS.ERROR && errorMessage.includes('parsing_exception') - ? errorMessage - : searchError; - return ( @@ -464,52 +185,6 @@ export const ResultsTable: FC = React.memo( )} - - - - } - isOpen={isColumnsPopoverVisible} - closePopover={closeColumnsPopover} - ownFocus - > - - {i18n.translate( - 'xpack.ml.dataframe.analytics.regressionExploration.selectFieldsPopoverTitle', - { - defaultMessage: 'Select fields', - } - )} - -
- {docFields.map(({ name }) => ( - field.name === name)} - onChange={() => toggleColumn(name)} - disabled={ - selectedFields.some(field => field.name === name) && - selectedFields.length === 1 - } - /> - ))} -
-
-
-
@@ -518,29 +193,39 @@ export const ResultsTable: FC = React.memo( )} {(columns.length > 0 || searchQuery !== defaultSearchQuery) && ( - - - - - - - - + + + + + + + + + + + + + + + + )}
); diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/use_explore_data.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/use_explore_data.ts index e158e952c1c18..978aafd10de11 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/use_explore_data.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/regression_exploration/use_explore_data.ts @@ -4,27 +4,29 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState, Dispatch, SetStateAction } from 'react'; +import { EuiDataGridPaginationProps, EuiDataGridSorting } from '@elastic/eui'; import { SearchResponse } from 'elasticsearch'; import { cloneDeep } from 'lodash'; -import { SortDirection, SORT_DIRECTION } from '../../../../../components/ml_in_memory_table'; - import { ml } from '../../../../../services/ml_api_service'; import { getNestedProperty } from '../../../../../util/object_utils'; import { newJobCapsService } from '../../../../../services/new_job_capabilities_service'; +import { SORT_DIRECTION } from '../../../../../components/ml_in_memory_table'; +import { SavedSearchQuery } from '../../../../../contexts/ml'; import { getDefaultFieldsFromJobCaps, + getDependentVar, getFlattenedFields, + getPredictedFieldName, DataFrameAnalyticsConfig, EsFieldName, INDEX_STATUS, - SEARCH_SIZE, - SearchQuery, } from '../../../../common'; -import { Field } from '../../../../../../../common/types/fields'; +import { Dictionary } from '../../../../../../../common/types/common'; +import { isKeywordAndTextType } from '../../../../common/fields'; import { ES_FIELD_TYPES } from '../../../../../../../../../../src/plugins/data/public'; import { LoadExploreDataArg, @@ -34,51 +36,90 @@ import { } from '../../../../common/analytics'; export type TableItem = Record; +type Pagination = Pick; export interface UseExploreDataReturnType { errorMessage: string; - loadExploreData: (arg: LoadExploreDataArg) => void; - sortField: EsFieldName; - sortDirection: SortDirection; + fieldTypes: { [key: string]: ES_FIELD_TYPES }; + pagination: Pagination; + rowCount: number; + searchQuery: SavedSearchQuery; + selectedFields: EsFieldName[]; + setFilterByIsTraining: Dispatch>; + setPagination: Dispatch>; + setSearchQuery: Dispatch>; + setSelectedFields: Dispatch>; + setSortingColumns: Dispatch>; + sortingColumns: EuiDataGridSorting['columns']; status: INDEX_STATUS; + tableFields: string[]; tableItems: TableItem[]; } +type EsSorting = Dictionary<{ + order: 'asc' | 'desc'; +}>; + +// The types specified in `@types/elasticsearch` are out of date and still have `total: number`. +interface SearchResponse7 extends SearchResponse { + hits: SearchResponse['hits'] & { + total: { + value: number; + relation: string; + }; + }; +} + export const useExploreData = ( - jobConfig: DataFrameAnalyticsConfig | undefined, - needsDestIndexFields: boolean, - selectedFields: Field[], - setSelectedFields: React.Dispatch>, - setDocFields: React.Dispatch>, - setDepVarType: React.Dispatch> + jobConfig: DataFrameAnalyticsConfig, + needsDestIndexFields: boolean ): UseExploreDataReturnType => { const [errorMessage, setErrorMessage] = useState(''); const [status, setStatus] = useState(INDEX_STATUS.UNUSED); + + const [selectedFields, setSelectedFields] = useState([] as EsFieldName[]); + const [tableFields, setTableFields] = useState([]); const [tableItems, setTableItems] = useState([]); - const [sortField, setSortField] = useState(''); - const [sortDirection, setSortDirection] = useState(SORT_DIRECTION.ASC); + const [fieldTypes, setFieldTypes] = useState<{ [key: string]: ES_FIELD_TYPES }>({}); + const [rowCount, setRowCount] = useState(0); + + const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 25 }); + const [searchQuery, setSearchQuery] = useState(defaultSearchQuery); + const [filterByIsTraining, setFilterByIsTraining] = useState(undefined); + const [sortingColumns, setSortingColumns] = useState([]); + + const predictedFieldName = getPredictedFieldName( + jobConfig.dest.results_field, + jobConfig.analysis + ); + const dependentVariable = getDependentVar(jobConfig.analysis); const getDefaultSelectedFields = () => { const { fields } = newJobCapsService; - if (selectedFields.length === 0 && jobConfig !== undefined) { - const { - selectedFields: defaultSelected, - docFields, - depVarType, - } = getDefaultFieldsFromJobCaps(fields, jobConfig, needsDestIndexFields); - - setDepVarType(depVarType); - setSelectedFields(defaultSelected); - setDocFields(docFields); + const { selectedFields: defaultSelected, docFields } = getDefaultFieldsFromJobCaps( + fields, + jobConfig, + needsDestIndexFields + ); + + const types: { [key: string]: ES_FIELD_TYPES } = {}; + const allFields: string[] = []; + + docFields.forEach(field => { + types[field.id] = field.type; + allFields.push(field.id); + }); + + setFieldTypes(types); + setSelectedFields(defaultSelected.map(field => field.id)); + setTableFields(allFields); } }; const loadExploreData = async ({ - field, - direction, - searchQuery, - requiresKeyword, + filterByIsTraining: isTraining, + searchQuery: incomingQuery, }: LoadExploreDataArg) => { if (jobConfig !== undefined) { setErrorMessage(''); @@ -86,15 +127,33 @@ export const useExploreData = ( try { const resultsField = jobConfig.dest.results_field; - const searchQueryClone: ResultsSearchQuery = cloneDeep(searchQuery); + const searchQueryClone: ResultsSearchQuery = cloneDeep(incomingQuery); let query: ResultsSearchQuery; + const { pageIndex, pageSize } = pagination; + // If filterByIsTraining is defined - add that in to the final query + const trainingQuery = + isTraining !== undefined + ? { + term: { [`${resultsField}.is_training`]: { value: isTraining } }, + } + : undefined; - if (JSON.stringify(searchQuery) === JSON.stringify(defaultSearchQuery)) { - query = { + if (JSON.stringify(incomingQuery) === JSON.stringify(defaultSearchQuery)) { + const existsQuery = { exists: { field: resultsField, }, }; + + query = { + bool: { + must: [existsQuery], + }, + }; + + if (trainingQuery !== undefined && isResultsSearchBoolQuery(query)) { + query.bool.must.push(trainingQuery); + } } else if (isResultsSearchBoolQuery(searchQueryClone)) { if (searchQueryClone.bool.must === undefined) { searchQueryClone.bool.must = []; @@ -106,32 +165,37 @@ export const useExploreData = ( }, }); + if (trainingQuery !== undefined) { + searchQueryClone.bool.must.push(trainingQuery); + } + query = searchQueryClone; } else { query = searchQueryClone; } - const body: SearchQuery = { - query, - }; - - if (field !== undefined) { - body.sort = [ - { - [`${field}${requiresKeyword ? '.keyword' : ''}`]: { - order: direction, - }, - }, - ]; - } - const resp: SearchResponse = await ml.esSearch({ + const sort: EsSorting = sortingColumns + .map(column => { + const { id } = column; + column.id = isKeywordAndTextType(id) ? `${id}.keyword` : id; + return column; + }) + .reduce((s, column) => { + s[column.id] = { order: column.direction }; + return s; + }, {} as EsSorting); + + const resp: SearchResponse7 = await ml.esSearch({ index: jobConfig.dest.index, - size: SEARCH_SIZE, - body, + body: { + query, + from: pageIndex * pageSize, + size: pageSize, + ...(Object.keys(sort).length > 0 ? { sort } : {}), + }, }); - setSortField(field); - setSortDirection(direction); + setRowCount(resp.hits.total.value); const docs = resp.hits.hits; @@ -183,10 +247,45 @@ export const useExploreData = ( }; useEffect(() => { - if (jobConfig !== undefined) { - getDefaultSelectedFields(); - } + getDefaultSelectedFields(); }, [jobConfig && jobConfig.id]); - return { errorMessage, loadExploreData, sortField, sortDirection, status, tableItems }; + // By default set sorting to descending on the prediction field (`_prediction`). + useEffect(() => { + const sortByField = isKeywordAndTextType(dependentVariable) + ? `${predictedFieldName}.keyword` + : predictedFieldName; + const direction = SORT_DIRECTION.DESC; + + setSortingColumns([{ id: sortByField, direction }]); + }, [jobConfig && jobConfig.id]); + + useEffect(() => { + loadExploreData({ filterByIsTraining, searchQuery }); + }, [ + filterByIsTraining, + jobConfig && jobConfig.id, + pagination, + searchQuery, + selectedFields, + sortingColumns, + ]); + + return { + errorMessage, + fieldTypes, + pagination, + searchQuery, + selectedFields, + rowCount, + setFilterByIsTraining, + setPagination, + setSelectedFields, + setSortingColumns, + setSearchQuery, + sortingColumns, + status, + tableItems, + tableFields, + }; }; diff --git a/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js b/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js index 5e505757dd2aa..42742f6efcb2a 100644 --- a/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js +++ b/x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js @@ -150,7 +150,7 @@ function getTimeseriesexplorerDefaultState() { }; } -const containerPadding = 24; +const containerPadding = 34; export class TimeSeriesExplorer extends React.Component { static propTypes = { diff --git a/x-pack/plugins/ml/server/lib/__tests__/query_utils.js b/x-pack/plugins/ml/server/lib/query_utils.test.ts similarity index 67% rename from x-pack/plugins/ml/server/lib/__tests__/query_utils.js rename to x-pack/plugins/ml/server/lib/query_utils.test.ts index 05292abb36b25..c2f5e814da332 100644 --- a/x-pack/plugins/ml/server/lib/__tests__/query_utils.js +++ b/x-pack/plugins/ml/server/lib/query_utils.test.ts @@ -4,12 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import expect from '@kbn/expect'; import { buildBaseFilterCriteria, buildSamplerAggregation, getSamplerAggregationsResponsePath, -} from '../query_utils'; +} from './query_utils'; describe('ML - query utils', () => { describe('buildBaseFilterCriteria', () => { @@ -23,8 +22,8 @@ describe('ML - query utils', () => { }, }; - it('returns correct criteria for time range', () => { - expect(buildBaseFilterCriteria('timestamp', earliestMs, latestMs)).to.eql([ + test('returns correct criteria for time range', () => { + expect(buildBaseFilterCriteria('timestamp', earliestMs, latestMs)).toEqual([ { range: { timestamp: { @@ -37,8 +36,8 @@ describe('ML - query utils', () => { ]); }); - it('returns correct criteria for time range and query', () => { - expect(buildBaseFilterCriteria('timestamp', earliestMs, latestMs, query)).to.eql([ + test('returns correct criteria for time range and query', () => { + expect(buildBaseFilterCriteria('timestamp', earliestMs, latestMs, query)).toEqual([ { range: { timestamp: { @@ -60,8 +59,8 @@ describe('ML - query utils', () => { }, }; - it('returns wrapped sampler aggregation for sampler shard size of 1000', () => { - expect(buildSamplerAggregation(testAggs, 1000)).to.eql({ + test('returns wrapped sampler aggregation for sampler shard size of 1000', () => { + expect(buildSamplerAggregation(testAggs, 1000)).toEqual({ sample: { sampler: { shard_size: 1000, @@ -71,18 +70,18 @@ describe('ML - query utils', () => { }); }); - it('returns un-sampled aggregation as-is for sampler shard size of 0', () => { - expect(buildSamplerAggregation(testAggs, 0)).to.eql(testAggs); + test('returns un-sampled aggregation as-is for sampler shard size of 0', () => { + expect(buildSamplerAggregation(testAggs, 0)).toEqual(testAggs); }); }); describe('getSamplerAggregationsResponsePath', () => { - it('returns correct path for sampler shard size of 1000', () => { - expect(getSamplerAggregationsResponsePath(1000)).to.eql(['sample']); + test('returns correct path for sampler shard size of 1000', () => { + expect(getSamplerAggregationsResponsePath(1000)).toEqual(['sample']); }); - it('returns correct path for sampler shard size of 0', () => { - expect(getSamplerAggregationsResponsePath(0)).to.eql([]); + test('returns correct path for sampler shard size of 0', () => { + expect(getSamplerAggregationsResponsePath(0)).toEqual([]); }); }); }); diff --git a/x-pack/plugins/ml/server/lib/telemetry/mappings.ts b/x-pack/plugins/ml/server/lib/telemetry/mappings.ts index 87e2243328422..5aaf9f8c79dc0 100644 --- a/x-pack/plugins/ml/server/lib/telemetry/mappings.ts +++ b/x-pack/plugins/ml/server/lib/telemetry/mappings.ts @@ -10,7 +10,7 @@ import { TELEMETRY_DOC_ID } from './telemetry'; export const mlTelemetryMappingsType: SavedObjectsType = { name: TELEMETRY_DOC_ID, hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { file_data_visualizer: { diff --git a/x-pack/plugins/monitoring/server/lib/errors/known_errors.js b/x-pack/plugins/monitoring/server/lib/errors/known_errors.js index 6f02d0b0b26c0..17bcdd0414adf 100644 --- a/x-pack/plugins/monitoring/server/lib/errors/known_errors.js +++ b/x-pack/plugins/monitoring/server/lib/errors/known_errors.js @@ -47,5 +47,7 @@ export function isKnownError(err) { export function handleKnownError(err) { err.message = err.message + ': ' + (err.description || mapTypeMessage[err.constructor.name]); - return boomify(err, { statusCode: KNOWN_ERROR_STATUS_CODE }); + let statusCode = err.statusCode || err.status; + statusCode = statusCode !== 500 ? statusCode : KNOWN_ERROR_STATUS_CODE; + return boomify(err, { statusCode }); } diff --git a/x-pack/plugins/monitoring/server/plugin.ts b/x-pack/plugins/monitoring/server/plugin.ts index 0fa1a5bf144ac..a45e80ac71d65 100644 --- a/x-pack/plugins/monitoring/server/plugin.ts +++ b/x-pack/plugins/monitoring/server/plugin.ts @@ -10,12 +10,6 @@ import { i18n } from '@kbn/i18n'; import { has, get } from 'lodash'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { TelemetryCollectionManagerPluginSetup } from 'src/plugins/telemetry_collection_manager/server'; -import { - LOGGING_TAG, - KIBANA_MONITORING_LOGGING_TAG, - KIBANA_ALERTING_ENABLED, - KIBANA_STATS_TYPE_MONITORING, -} from '../common/constants'; import { Logger, PluginInitializerContext, @@ -27,7 +21,15 @@ import { CoreStart, IRouter, IClusterClient, -} from '../../../../src/core/server'; + CustomHttpResponseOptions, + ResponseError, +} from 'kibana/server'; +import { + LOGGING_TAG, + KIBANA_MONITORING_LOGGING_TAG, + KIBANA_ALERTING_ENABLED, + KIBANA_STATS_TYPE_MONITORING, +} from '../common/constants'; import { MonitoringConfig } from './config'; // @ts-ignore import { requireUIRoutes } from './routes'; @@ -92,6 +94,16 @@ interface IBulkUploader { // This is used to test the version of kibana const snapshotRegex = /-snapshot/i; +const wrapError = (error: any): CustomHttpResponseOptions => { + const options = { statusCode: error.statusCode ?? 500 }; + const boom = Boom.isBoom(error) ? error : Boom.boomify(error, options); + return { + body: boom, + headers: boom.output.headers, + statusCode: boom.output.statusCode, + }; +}; + export class Plugin { private readonly initializerContext: PluginInitializerContext; private readonly log: Logger; @@ -369,12 +381,16 @@ export class Plugin { }, }, }; - - const result = await options.handler(legacyRequest); - if (Boom.isBoom(result)) { - return res.customError({ statusCode: result.output.statusCode, body: result }); + try { + const result = await options.handler(legacyRequest); + return res.ok({ body: result }); + } catch (err) { + const statusCode: number = err.output?.statusCode || err.statusCode || err.status; + if (Boom.isBoom(err) || statusCode !== 500) { + return res.customError({ statusCode, body: err }); + } + return res.internalError(wrapError(err)); } - return res.ok({ body: result }); }; const validate: any = get(options, 'config.validate', false); diff --git a/x-pack/plugins/monitoring/server/routes/api/v1/cluster/cluster.js b/x-pack/plugins/monitoring/server/routes/api/v1/cluster/cluster.js index 8d6fe04cdb7bd..240cb84539dbf 100644 --- a/x-pack/plugins/monitoring/server/routes/api/v1/cluster/cluster.js +++ b/x-pack/plugins/monitoring/server/routes/api/v1/cluster/cluster.js @@ -46,9 +46,13 @@ export function clusterRoute(server) { codePaths: req.payload.codePaths, }; - return getClustersFromRequest(req, indexPatterns, options).catch(err => - handleError(err, req) - ); + let clusters = []; + try { + clusters = await getClustersFromRequest(req, indexPatterns, options); + } catch (err) { + throw handleError(err, req); + } + return clusters; }, }); } diff --git a/x-pack/plugins/monitoring/server/telemetry_collection/get_all_stats.test.ts b/x-pack/plugins/monitoring/server/telemetry_collection/get_all_stats.test.ts index 1a9f2a4da32c2..f0ad6399c6c72 100644 --- a/x-pack/plugins/monitoring/server/telemetry_collection/get_all_stats.test.ts +++ b/x-pack/plugins/monitoring/server/telemetry_collection/get_all_stats.test.ts @@ -182,7 +182,6 @@ describe('get_all_stats', () => { }, { logger: coreMock.createPluginInitializerContext().logger.get('test'), - isDev: true, version: 'version', maxBucketSize: 1, } @@ -208,7 +207,6 @@ describe('get_all_stats', () => { }, { logger: coreMock.createPluginInitializerContext().logger.get('test'), - isDev: true, version: 'version', maxBucketSize: 1, } diff --git a/x-pack/plugins/oss_telemetry/server/lib/tasks/index.ts b/x-pack/plugins/oss_telemetry/server/lib/tasks/index.ts index 9342c2574bedd..415aeb2791d9e 100644 --- a/x-pack/plugins/oss_telemetry/server/lib/tasks/index.ts +++ b/x-pack/plugins/oss_telemetry/server/lib/tasks/index.ts @@ -41,6 +41,7 @@ export function registerTasks({ createTaskRunner({ taskInstance }: { taskInstance: TaskInstance }) { return { run: visualizationsTaskRunner(taskInstance, config, esClientPromise), + cancel: async () => {}, }; }, }, diff --git a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/pipeline_edit/index.js b/x-pack/plugins/reporting/common/types.d.ts old mode 100755 new mode 100644 similarity index 83% rename from x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/pipeline_edit/index.js rename to x-pack/plugins/reporting/common/types.d.ts index 5889bbdf96a93..34f0bc9ac8a36 --- a/x-pack/legacy/plugins/logstash/public/sections/pipeline_edit/components/pipeline_edit/index.js +++ b/x-pack/plugins/reporting/common/types.d.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -import './pipeline_edit'; +export { ConfigType } from '../server/config'; diff --git a/x-pack/plugins/reporting/constants.ts b/x-pack/plugins/reporting/constants.ts index 5756d29face12..8079c5b1d9887 100644 --- a/x-pack/plugins/reporting/constants.ts +++ b/x-pack/plugins/reporting/constants.ts @@ -7,13 +7,6 @@ export const JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY = 'xpack.reporting.jobCompletionNotifications'; -export const JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG = { - jobCompletionNotifier: { - interval: 10000, - intervalErrorMultiplier: 5, - }, -}; - // Routes export const API_BASE_URL = '/api/reporting'; export const API_LIST_URL = `${API_BASE_URL}/jobs`; diff --git a/x-pack/plugins/reporting/index.d.ts b/x-pack/plugins/reporting/index.d.ts index 26d661e29bd94..77faf837e6505 100644 --- a/x-pack/plugins/reporting/index.d.ts +++ b/x-pack/plugins/reporting/index.d.ts @@ -4,15 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { - CoreSetup, - CoreStart, - HttpSetup, - Plugin, - PluginInitializerContext, - NotificationsStart, -} from '../../../src/core/public'; - export type JobId = string; export type JobStatus = | 'completed' @@ -21,9 +12,6 @@ export type JobStatus = | 'processing' | 'failed'; -export type HttpService = HttpSetup; -export type NotificationsService = NotificationsStart; - export interface SourceJob { _id: JobId; _source: { diff --git a/x-pack/plugins/reporting/public/components/report_listing.test.tsx b/x-pack/plugins/reporting/public/components/report_listing.test.tsx index 380a3b3295b9f..787279e6caf9b 100644 --- a/x-pack/plugins/reporting/public/components/report_listing.test.tsx +++ b/x-pack/plugins/reporting/public/components/report_listing.test.tsx @@ -47,12 +47,24 @@ const toasts = { addDanger: jest.fn(), } as any; +const mockPollConfig = { + jobCompletionNotifier: { + interval: 5000, + intervalErrorMultiplier: 3, + }, + jobsRefresh: { + interval: 5000, + intervalErrorMultiplier: 3, + }, +}; + describe('ReportListing', () => { it('Report job listing with some items', () => { const wrapper = mountWithIntl( @@ -74,6 +86,7 @@ describe('ReportListing', () => { } + pollConfig={mockPollConfig} redirect={jest.fn()} toasts={toasts} /> diff --git a/x-pack/plugins/reporting/public/components/report_listing.tsx b/x-pack/plugins/reporting/public/components/report_listing.tsx index 885e9577471a0..d8f9b7d37cfbf 100644 --- a/x-pack/plugins/reporting/public/components/report_listing.tsx +++ b/x-pack/plugins/reporting/public/components/report_listing.tsx @@ -16,14 +16,15 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import { get } from 'lodash'; import moment from 'moment'; -import { Component, Fragment, default as React } from 'react'; +import { Component, default as React, Fragment } from 'react'; import { Subscription } from 'rxjs'; import { ApplicationStart, ToastsSetup } from 'src/core/public'; import { ILicense, LicensingPluginSetup } from '../../../licensing/public'; import { Poller } from '../../common/poller'; -import { JobStatuses, JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG } from '../../constants'; +import { JobStatuses } from '../../constants'; import { checkLicense } from '../lib/license_check'; import { JobQueueEntry, ReportingAPIClient } from '../lib/reporting_api_client'; +import { ClientConfigType } from '../plugin'; import { ReportDeleteButton, ReportDownloadButton, @@ -53,6 +54,7 @@ export interface Props { intl: InjectedIntl; apiClient: ReportingAPIClient; license$: LicensingPluginSetup['license$']; + pollConfig: ClientConfigType['poll']; redirect: ApplicationStart['navigateToApp']; toasts: ToastsSetup; } @@ -167,12 +169,10 @@ class ReportListingUi extends Component { functionToPoll: () => { return this.fetchJobs(); }, - pollFrequencyInMillis: - JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG.jobCompletionNotifier.interval, + pollFrequencyInMillis: this.props.pollConfig.jobsRefresh.interval, trailing: false, continuePollingOnError: true, - pollFrequencyErrorMultiplier: - JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG.jobCompletionNotifier.intervalErrorMultiplier, + pollFrequencyErrorMultiplier: this.props.pollConfig.jobsRefresh.intervalErrorMultiplier, }); this.poller.start(); this.licenseSubscription = this.props.license$.subscribe(this.licenseHandler); diff --git a/x-pack/plugins/reporting/public/lib/stream_handler.ts b/x-pack/plugins/reporting/public/lib/stream_handler.ts index 3c121f1712685..eed6d5dd141e7 100644 --- a/x-pack/plugins/reporting/public/lib/stream_handler.ts +++ b/x-pack/plugins/reporting/public/lib/stream_handler.ts @@ -4,30 +4,23 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import * as Rx from 'rxjs'; import { catchError, map } from 'rxjs/operators'; -import { i18n } from '@kbn/i18n'; +import { NotificationsSetup } from 'src/core/public'; import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY, JOB_STATUS_COMPLETED, JOB_STATUS_FAILED, JOB_STATUS_WARNINGS, } from '../../constants'; - -import { - JobId, - JobSummary, - JobStatusBuckets, - NotificationsService, - SourceJob, -} from '../../index.d'; - +import { JobId, JobStatusBuckets, JobSummary, SourceJob } from '../../index.d'; import { - getSuccessToast, getFailureToast, + getGeneralErrorToast, + getSuccessToast, getWarningFormulasToast, getWarningMaxSizeToast, - getGeneralErrorToast, } from '../components'; import { ReportingAPIClient } from './reporting_api_client'; @@ -47,7 +40,7 @@ function summarizeJob(src: SourceJob): JobSummary { } export class ReportingNotifierStreamHandler { - constructor(private notifications: NotificationsService, private apiClient: ReportingAPIClient) {} + constructor(private notifications: NotificationsSetup, private apiClient: ReportingAPIClient) {} /* * Use Kibana Toast API to show our messages diff --git a/x-pack/plugins/reporting/public/plugin.tsx b/x-pack/plugins/reporting/public/plugin.tsx index 08ba10ff69207..c40e7ad373eaf 100644 --- a/x-pack/plugins/reporting/public/plugin.tsx +++ b/x-pack/plugins/reporting/public/plugin.tsx @@ -4,44 +4,42 @@ * you may not use this file except in compliance with the Elastic License. */ -import * as Rx from 'rxjs'; +import { i18n } from '@kbn/i18n'; +import { I18nProvider } from '@kbn/i18n/react'; import React from 'react'; import ReactDOM from 'react-dom'; +import * as Rx from 'rxjs'; import { catchError, filter, map, mergeMap, takeUntil } from 'rxjs/operators'; -import { i18n } from '@kbn/i18n'; +import { + CoreSetup, + CoreStart, + NotificationsSetup, + Plugin, + PluginInitializerContext, +} from 'src/core/public'; import { ManagementSetup } from 'src/plugins/management/public'; -import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/public'; -import { I18nProvider } from '@kbn/i18n/react'; import { UiActionsSetup } from 'src/plugins/ui_actions/public'; - -import { ReportListing } from './components/report_listing'; -import { getGeneralErrorToast } from './components'; - -import { ReportingNotifierStreamHandler as StreamHandler } from './lib/stream_handler'; -import { ReportingAPIClient } from './lib/reporting_api_client'; -import { GetCsvReportPanelAction } from './panel_actions/get_csv_panel_action'; -import { csvReportingProvider } from './share_context_menu/register_csv_reporting'; -import { reportingPDFPNGProvider } from './share_context_menu/register_pdf_png_reporting'; - -import { LicensingPluginSetup } from '../../licensing/public'; +import { JobId, JobStatusBuckets } from '../'; import { CONTEXT_MENU_TRIGGER } from '../../../../src/plugins/embeddable/public'; -import { SharePluginSetup } from '../../../../src/plugins/share/public'; - import { FeatureCatalogueCategory, HomePublicPluginSetup, } from '../../../../src/plugins/home/public'; +import { SharePluginSetup } from '../../../../src/plugins/share/public'; +import { LicensingPluginSetup } from '../../licensing/public'; +import { ConfigType } from '../common/types'; +import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../constants'; +import { getGeneralErrorToast } from './components'; +import { ReportListing } from './components/report_listing'; +import { ReportingAPIClient } from './lib/reporting_api_client'; +import { ReportingNotifierStreamHandler as StreamHandler } from './lib/stream_handler'; +import { GetCsvReportPanelAction } from './panel_actions/get_csv_panel_action'; +import { csvReportingProvider } from './share_context_menu/register_csv_reporting'; +import { reportingPDFPNGProvider } from './share_context_menu/register_pdf_png_reporting'; -import { - JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG, - JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY, -} from '../constants'; - -import { JobId, JobStatusBuckets, NotificationsService } from '..'; - -const { - jobCompletionNotifier: { interval: JOBS_REFRESH_INTERVAL }, -} = JOB_COMPLETION_NOTIFICATIONS_POLLER_CONFIG; +export interface ClientConfigType { + poll: ConfigType['poll']; +} function getStored(): JobId[] { const sessionValue = sessionStorage.getItem(JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY); @@ -49,7 +47,7 @@ function getStored(): JobId[] { } function handleError( - notifications: NotificationsService, + notifications: NotificationsSetup, err: Error ): Rx.Observable { notifications.toasts.addDanger( @@ -64,18 +62,19 @@ function handleError( return Rx.of({ completed: [], failed: [] }); } -export class ReportingPublicPlugin implements Plugin { +export class ReportingPublicPlugin implements Plugin { + private config: ClientConfigType; private readonly stop$ = new Rx.ReplaySubject(1); - private readonly title = i18n.translate('xpack.reporting.management.reportingTitle', { defaultMessage: 'Reporting', }); - private readonly breadcrumbText = i18n.translate('xpack.reporting.breadcrumb', { defaultMessage: 'Reporting', }); - constructor(initializerContext: PluginInitializerContext) {} + constructor(initializerContext: PluginInitializerContext) { + this.config = initializerContext.config.get(); + } public setup( core: CoreSetup, @@ -130,6 +129,7 @@ export class ReportingPublicPlugin implements Plugin { @@ -163,8 +163,9 @@ export class ReportingPublicPlugin implements Plugin { const { http, notifications } = core; const apiClient = new ReportingAPIClient(http); const streamHandler = new StreamHandler(notifications, apiClient); + const { interval } = this.config.poll.jobsRefresh; - Rx.timer(0, JOBS_REFRESH_INTERVAL) + Rx.timer(0, interval) .pipe( takeUntil(this.stop$), // stop the interval when stop method is called map(() => getStored()), // read all pending job IDs from session storage diff --git a/x-pack/plugins/reporting/server/config/index.ts b/x-pack/plugins/reporting/server/config/index.ts index f0a0a093aa8c0..a0d7618322c65 100644 --- a/x-pack/plugins/reporting/server/config/index.ts +++ b/x-pack/plugins/reporting/server/config/index.ts @@ -10,6 +10,7 @@ import { ConfigSchema, ConfigType } from './schema'; export { createConfig$ } from './create_config'; export const config: PluginConfigDescriptor = { + exposeToBrowser: { poll: true }, schema: ConfigSchema, deprecations: ({ unused }) => [ unused('capture.browser.chromium.maxScreenshotDimension'), diff --git a/x-pack/plugins/reporting/server/config/schema.ts b/x-pack/plugins/reporting/server/config/schema.ts index 67d70c1513c15..402fddcb5e014 100644 --- a/x-pack/plugins/reporting/server/config/schema.ts +++ b/x-pack/plugins/reporting/server/config/schema.ts @@ -114,6 +114,7 @@ const CaptureSchema = schema.object({ const CsvSchema = schema.object({ checkForFormulas: schema.boolean({ defaultValue: true }), + escapeFormulaValues: schema.boolean({ defaultValue: false }), enablePanelActionDownload: schema.boolean({ defaultValue: true }), maxSizeBytes: schema.number({ defaultValue: 1024 * 1024 * 10, // 10MB diff --git a/x-pack/plugins/rollup/common/index.ts b/x-pack/plugins/rollup/common/index.ts new file mode 100644 index 0000000000000..aeffa3dc3959f --- /dev/null +++ b/x-pack/plugins/rollup/common/index.ts @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const CONFIG_ROLLUPS = 'rollups:enableIndexPatterns'; + +export const API_BASE_PATH = '/api/rollup'; + +export { + UIM_APP_NAME, + UIM_APP_LOAD, + UIM_JOB_CREATE, + UIM_JOB_DELETE, + UIM_JOB_DELETE_MANY, + UIM_JOB_START, + UIM_JOB_START_MANY, + UIM_JOB_STOP, + UIM_JOB_STOP_MANY, + UIM_SHOW_DETAILS_CLICK, + UIM_DETAIL_PANEL_SUMMARY_TAB_CLICK, + UIM_DETAIL_PANEL_TERMS_TAB_CLICK, + UIM_DETAIL_PANEL_HISTOGRAM_TAB_CLICK, + UIM_DETAIL_PANEL_METRICS_TAB_CLICK, + UIM_DETAIL_PANEL_JSON_TAB_CLICK, +} from './ui_metric'; diff --git a/x-pack/legacy/plugins/rollup/common/ui_metric.ts b/x-pack/plugins/rollup/common/ui_metric.ts similarity index 100% rename from x-pack/legacy/plugins/rollup/common/ui_metric.ts rename to x-pack/plugins/rollup/common/ui_metric.ts diff --git a/x-pack/legacy/plugins/rollup/fixtures/index.js b/x-pack/plugins/rollup/fixtures/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/fixtures/index.js rename to x-pack/plugins/rollup/fixtures/index.js diff --git a/x-pack/legacy/plugins/rollup/fixtures/job.js b/x-pack/plugins/rollup/fixtures/job.js similarity index 95% rename from x-pack/legacy/plugins/rollup/fixtures/job.js rename to x-pack/plugins/rollup/fixtures/job.js index 3889cc6087d83..310244a5031e7 100644 --- a/x-pack/legacy/plugins/rollup/fixtures/job.js +++ b/x-pack/plugins/rollup/fixtures/job.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRandomString } from '../../../../test_utils'; +import { getRandomString } from '../../../test_utils'; const initialValues = { dateHistogramField: 'timestamp', diff --git a/x-pack/plugins/rollup/kibana.json b/x-pack/plugins/rollup/kibana.json index 6ab2fc8907c0d..8f832f6c6a345 100644 --- a/x-pack/plugins/rollup/kibana.json +++ b/x-pack/plugins/rollup/kibana.json @@ -2,5 +2,8 @@ "id": "rollup", "version": "8.0.0", "kibanaVersion": "kibana", - "server": true + "server": true, + "ui": true, + "optionalPlugins": ["home", "indexManagement", "indexPatternManagement", "usageCollection"], + "requiredPlugins": ["management", "data"] } diff --git a/x-pack/legacy/plugins/rollup/public/application.tsx b/x-pack/plugins/rollup/public/application.tsx similarity index 87% rename from x-pack/legacy/plugins/rollup/public/application.tsx rename to x-pack/plugins/rollup/public/application.tsx index df17d37bc3465..1bdf940d746b2 100644 --- a/x-pack/legacy/plugins/rollup/public/application.tsx +++ b/x-pack/plugins/rollup/public/application.tsx @@ -5,15 +5,17 @@ */ import React from 'react'; +import { ChromeBreadcrumb, CoreSetup } from 'kibana/public'; import { render, unmountComponentAtNode } from 'react-dom'; import { Provider } from 'react-redux'; -import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; -import { ChromeBreadcrumb, CoreSetup } from '../../../../../src/core/public'; +import { KibanaContextProvider } from '../../../../src/plugins/kibana_react/public'; // @ts-ignore import { rollupJobsStore } from './crud_app/store'; // @ts-ignore import { App } from './crud_app/app'; +import './index.scss'; + /** * This module will be loaded asynchronously to reduce the bundle size of your plugin's main bundle. */ diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/_crud_app.scss b/x-pack/plugins/rollup/public/crud_app/_crud_app.scss similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/_crud_app.scss rename to x-pack/plugins/rollup/public/crud_app/_crud_app.scss diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/app.js b/x-pack/plugins/rollup/public/crud_app/app.js similarity index 93% rename from x-pack/legacy/plugins/rollup/public/crud_app/app.js rename to x-pack/plugins/rollup/public/crud_app/app.js index da35c8a56f2d2..0ef3253eeb94e 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/app.js +++ b/x-pack/plugins/rollup/public/crud_app/app.js @@ -10,7 +10,8 @@ import { HashRouter, Switch, Route, Redirect, withRouter } from 'react-router-do import { UIM_APP_LOAD } from '../../common'; import { CRUD_APP_BASE_PATH } from './constants'; -import { registerRouter, setUserHasLeftApp, trackUiMetric, METRIC_TYPE } from './services'; +import { registerRouter, setUserHasLeftApp, METRIC_TYPE } from './services'; +import { trackUiMetric } from '../kibana_services'; import { JobList, JobCreate } from './sections'; class ShareRouterComponent extends Component { diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/constants/index.js b/x-pack/plugins/rollup/public/crud_app/constants/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/constants/index.js rename to x-pack/plugins/rollup/public/crud_app/constants/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/constants/metrics_config.js b/x-pack/plugins/rollup/public/crud_app/constants/metrics_config.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/constants/metrics_config.js rename to x-pack/plugins/rollup/public/crud_app/constants/metrics_config.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/constants/paths.js b/x-pack/plugins/rollup/public/crud_app/constants/paths.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/constants/paths.js rename to x-pack/plugins/rollup/public/crud_app/constants/paths.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/field_list/field_list.js b/x-pack/plugins/rollup/public/crud_app/sections/components/field_list/field_list.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/field_list/field_list.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/field_list/field_list.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/field_list/index.js b/x-pack/plugins/rollup/public/crud_app/sections/components/field_list/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/field_list/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/field_list/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/index.js b/x-pack/plugins/rollup/public/crud_app/sections/components/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/confirm_delete_modal.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/confirm_delete_modal.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/confirm_delete_modal.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/confirm_delete_modal.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/index.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/confirm_delete_modal/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/index.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/job_action_menu.container.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/job_action_menu.container.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/job_action_menu.container.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/job_action_menu.container.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/job_action_menu.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/job_action_menu.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_action_menu/job_action_menu.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_action_menu/job_action_menu.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/index.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_details/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_details/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/job_details.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_details/job_details.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/job_details.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_details/job_details.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/index.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_histogram.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_histogram.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_histogram.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_histogram.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_json.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_json.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_json.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_json.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_metrics.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_metrics.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_metrics.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_metrics.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_request.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_request.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_request.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_request.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_summary.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_summary.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_summary.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_summary.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_terms.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_terms.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_terms.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_details/tabs/tab_terms.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_status/index.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_status/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_status/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_status/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_status/job_status.js b/x-pack/plugins/rollup/public/crud_app/sections/components/job_status/job_status.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/components/job_status/job_status.js rename to x-pack/plugins/rollup/public/crud_app/sections/components/job_status/job_status.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/index.js b/x-pack/plugins/rollup/public/crud_app/sections/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/index.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/job_create.container.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/job_create.container.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/job_create.container.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/job_create.container.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/job_create.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/job_create.js similarity index 99% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/job_create.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/job_create.js index 5379778c77e2f..4458054f30dd1 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/job_create.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_create/job_create.js @@ -14,7 +14,7 @@ import first from 'lodash/array/first'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { withKibana } from '../../../../../../../../src/plugins/kibana_react/public/'; +import { withKibana } from '../../../../../../../src/plugins/kibana_react/public'; import { EuiCallOut, diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/navigation/index.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/navigation/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/navigation/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/navigation/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/navigation/navigation.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/navigation/navigation.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/navigation/navigation.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/navigation/navigation.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/components/field_chooser.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/components/field_chooser.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/components/field_chooser.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/components/field_chooser.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/components/index.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/components/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/components/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/components/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/components/step_error.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/components/step_error.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/components/step_error.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/components/step_error.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/index.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_date_histogram.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_date_histogram.js similarity index 99% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_date_histogram.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_date_histogram.js index ba65d082c0b4b..c327e51a6b7ee 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_date_histogram.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_date_histogram.js @@ -24,7 +24,7 @@ import { EuiTitle, } from '@elastic/eui'; -import { search } from '../../../../../../../../../src/plugins/data/public'; +import { search } from '../../../../../../../../src/plugins/data/public'; const { parseEsInterval } = search.aggs; import { getDateHistogramDetailsUrl, getDateHistogramAggregationUrl } from '../../../services'; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_histogram.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_histogram.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_histogram.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_histogram.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js similarity index 99% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js index 5462a46bf59b9..0fd76e572b2e5 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_logistics.js @@ -24,8 +24,8 @@ import { EuiTitle, } from '@elastic/eui'; -import { CronEditor } from '../../../../../../../../../src/plugins/es_ui_shared/public'; -import { indexPatterns } from '../../../../../../../../../src/plugins/data/public'; +import { CronEditor } from '../../../../../../../../src/plugins/es_ui_shared/public'; +import { indexPatterns } from '../../../../../../../../src/plugins/data/public'; import { indices } from '../../../../shared_imports'; import { getLogisticalDetailsUrl, getCronUrl } from '../../../services'; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_metrics.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_metrics.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_metrics.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_metrics.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_review.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_terms.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_terms.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps/step_terms.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps/step_terms.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/index.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/index.js similarity index 96% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/index.js index e1efcfdd24627..4a55c4679c3d8 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/index.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/index.js @@ -8,7 +8,7 @@ import cloneDeep from 'lodash/lang/cloneDeep'; import get from 'lodash/object/get'; import pick from 'lodash/object/pick'; -import { WEEK } from '../../../../../../../../../src/plugins/es_ui_shared/public'; +import { WEEK } from '../../../../../../../../src/plugins/es_ui_shared/public'; import { validateId } from './validate_id'; import { validateIndexPattern } from './validate_index_pattern'; @@ -42,7 +42,7 @@ export const stepIds = [ * 1. getDefaultFields: (overrides) => object * 2. fieldValidations * - * See x-pack/legacy/plugins/rollup/public/crud_app/services/jobs.js for more information on override's shape + * See x-pack/plugins/rollup/public/crud_app/services/jobs.js for more information on override's shape */ export const stepIdToStepConfigMap = { [STEP_LOGISTICS]: { diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_field.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_field.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_field.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_field.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_interval.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_interval.js similarity index 95% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_interval.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_interval.js index b6c824bc8c553..819c814e373d5 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_interval.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_date_histogram_interval.js @@ -6,7 +6,7 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { search } from '../../../../../../../../../src/plugins/data/public'; +import { search } from '../../../../../../../../src/plugins/data/public'; const { InvalidEsIntervalFormatError, InvalidEsCalendarIntervalError, diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_histogram_interval.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_histogram_interval.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_histogram_interval.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_histogram_interval.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_id.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_id.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_id.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_id.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js similarity index 95% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js index 206cc325813c0..534fcaa744744 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_index_pattern.js @@ -7,7 +7,7 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { indexPatterns } from '../../../../../../../../../src/plugins/data/public'; +import { indexPatterns } from '../../../../../../../../src/plugins/data/public'; export function validateIndexPattern(indexPattern, rollupIndex) { if (!indexPattern || !indexPattern.trim()) { return [ diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_metrics.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_metrics.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_metrics.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_metrics.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_cron.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_cron.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_cron.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_cron.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_delay.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_delay.js similarity index 95% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_delay.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_delay.js index 37c2ca9a1d775..66bfd43bc3d1b 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_delay.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_delay.js @@ -6,7 +6,7 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { search } from '../../../../../../../../../src/plugins/data/public'; +import { search } from '../../../../../../../../src/plugins/data/public'; const { InvalidEsIntervalFormatError, InvalidEsCalendarIntervalError, diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_index.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_index.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_page_size.js b/x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_page_size.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_page_size.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_create/steps_config/validate_rollup_page_size.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.container.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.container.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.container.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.container.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js similarity index 98% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js index f774b1d7f63b7..3f168a66feed8 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.js @@ -34,7 +34,8 @@ import { UIM_DETAIL_PANEL_METRICS_TAB_CLICK, UIM_DETAIL_PANEL_JSON_TAB_CLICK, } from '../../../../../common'; -import { trackUiMetric, METRIC_TYPE } from '../../../services'; +import { METRIC_TYPE } from '../../../services'; +import { trackUiMetric } from '../../../../kibana_services'; import { JobActionMenu, diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js similarity index 98% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js index 9ac8e6075e4cf..cea5b3c3e96e5 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/detail_panel.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { registerTestBed } from '../../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../../../test_utils'; import { getJob } from '../../../../../fixtures'; import { rollupJobsStore } from '../../../store'; import { DetailPanel } from './detail_panel'; @@ -17,9 +17,8 @@ import { tabToHumanizedMap, } from '../../components'; -jest.mock('ui/new_platform'); -jest.mock('../../../services', () => { - const services = require.requireActual('../../../services'); +jest.mock('../../../../kibana_services', () => { + const services = require.requireActual('../../../../kibana_services'); return { ...services, trackUiMetric: jest.fn(), diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/index.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/detail_panel/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/detail_panel/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/index.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.container.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.container.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.container.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.container.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.js similarity index 98% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.js index 98329a687217a..011becded148c 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.js @@ -25,7 +25,7 @@ import { EuiCallOut, } from '@elastic/eui'; -import { withKibana } from '../../../../../../../../src/plugins/kibana_react/public/'; +import { withKibana } from '../../../../../../../src/plugins/kibana_react/public'; import { CRUD_APP_BASE_PATH } from '../../constants'; import { getRouterLinkProps, extractQueryParams, listBreadcrumb } from '../../services'; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js similarity index 90% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js index 725789fc584de..8c3bffd223ca9 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_list.test.js @@ -5,16 +5,14 @@ */ import React from 'react'; -import { registerTestBed } from '../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../../test_utils'; import { rollupJobsStore } from '../../store'; import { JobList } from './job_list'; -import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; -import { coreMock } from '../../../../../../../../src/core/public/mocks'; +import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public'; +import { coreMock } from '../../../../../../../src/core/public/mocks'; const startMock = coreMock.createStart(); -jest.mock('ui/new_platform'); - jest.mock('../../services', () => { const services = require.requireActual('../../services'); return { diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/index.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/index.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.container.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.container.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.container.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.container.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js similarity index 99% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js index 4dbe396ab8410..f47992e1b501a 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.js @@ -30,7 +30,8 @@ import { } from '@elastic/eui'; import { UIM_SHOW_DETAILS_CLICK } from '../../../../../common'; -import { trackUiMetric, METRIC_TYPE } from '../../../services'; +import { METRIC_TYPE } from '../../../services'; +import { trackUiMetric } from '../../../../kibana_services'; import { JobActionMenu, JobStatus } from '../../components'; const COLUMNS = [ diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js similarity index 96% rename from x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js rename to x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js index c688343d5f768..c6a3d3a8f69ad 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js +++ b/x-pack/plugins/rollup/public/crud_app/sections/job_list/job_table/job_table.test.js @@ -6,14 +6,13 @@ import { Pager } from '@elastic/eui'; -import { registerTestBed } from '../../../../../../../../test_utils'; +import { registerTestBed } from '../../../../../../../test_utils'; import { getJobs, jobCount } from '../../../../../fixtures'; import { rollupJobsStore } from '../../../store'; import { JobTable } from './job_table'; -jest.mock('ui/new_platform'); -jest.mock('../../../services', () => { - const services = require.requireActual('../../../services'); +jest.mock('../../../../kibana_services', () => { + const services = require.requireActual('../../../../kibana_services'); return { ...services, trackUiMetric: jest.fn(), diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/api.js b/x-pack/plugins/rollup/public/crud_app/services/api.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/api.js rename to x-pack/plugins/rollup/public/crud_app/services/api.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/api_errors.ts b/x-pack/plugins/rollup/public/crud_app/services/api_errors.ts similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/api_errors.ts rename to x-pack/plugins/rollup/public/crud_app/services/api_errors.ts diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/breadcrumbs.js b/x-pack/plugins/rollup/public/crud_app/services/breadcrumbs.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/breadcrumbs.js rename to x-pack/plugins/rollup/public/crud_app/services/breadcrumbs.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/documentation_links.js b/x-pack/plugins/rollup/public/crud_app/services/documentation_links.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/documentation_links.js rename to x-pack/plugins/rollup/public/crud_app/services/documentation_links.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/filter_items.js b/x-pack/plugins/rollup/public/crud_app/services/filter_items.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/filter_items.js rename to x-pack/plugins/rollup/public/crud_app/services/filter_items.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/flatten_panel_tree.js b/x-pack/plugins/rollup/public/crud_app/services/flatten_panel_tree.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/flatten_panel_tree.js rename to x-pack/plugins/rollup/public/crud_app/services/flatten_panel_tree.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/format_fields.js b/x-pack/plugins/rollup/public/crud_app/services/format_fields.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/format_fields.js rename to x-pack/plugins/rollup/public/crud_app/services/format_fields.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/http_provider.ts b/x-pack/plugins/rollup/public/crud_app/services/http_provider.ts similarity index 91% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/http_provider.ts rename to x-pack/plugins/rollup/public/crud_app/services/http_provider.ts index dd84328084d05..93898610b844e 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/services/http_provider.ts +++ b/x-pack/plugins/rollup/public/crud_app/services/http_provider.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { HttpStart } from 'src/core/public'; +import { HttpStart } from 'kibana/public'; let _http: HttpStart | null = null; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/index.js b/x-pack/plugins/rollup/public/crud_app/services/index.js similarity index 95% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/index.js rename to x-pack/plugins/rollup/public/crud_app/services/index.js index 790770b9b6a9f..0b45b1bdb6b5f 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/services/index.js +++ b/x-pack/plugins/rollup/public/crud_app/services/index.js @@ -47,4 +47,4 @@ export { sortTable } from './sort_table'; export { retypeMetrics } from './retype_metrics'; -export { trackUiMetric, METRIC_TYPE } from './track_ui_metric'; +export { METRIC_TYPE } from './track_ui_metric'; diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/jobs.js b/x-pack/plugins/rollup/public/crud_app/services/jobs.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/jobs.js rename to x-pack/plugins/rollup/public/crud_app/services/jobs.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/noticeable_delay.js b/x-pack/plugins/rollup/public/crud_app/services/noticeable_delay.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/noticeable_delay.js rename to x-pack/plugins/rollup/public/crud_app/services/noticeable_delay.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/query_params.js b/x-pack/plugins/rollup/public/crud_app/services/query_params.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/query_params.js rename to x-pack/plugins/rollup/public/crud_app/services/query_params.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/retype_metrics.js b/x-pack/plugins/rollup/public/crud_app/services/retype_metrics.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/retype_metrics.js rename to x-pack/plugins/rollup/public/crud_app/services/retype_metrics.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/routing.js b/x-pack/plugins/rollup/public/crud_app/services/routing.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/routing.js rename to x-pack/plugins/rollup/public/crud_app/services/routing.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/sort_table.js b/x-pack/plugins/rollup/public/crud_app/services/sort_table.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/sort_table.js rename to x-pack/plugins/rollup/public/crud_app/services/sort_table.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/services/track_ui_metric.js b/x-pack/plugins/rollup/public/crud_app/services/track_ui_metric.ts similarity index 70% rename from x-pack/legacy/plugins/rollup/public/crud_app/services/track_ui_metric.js rename to x-pack/plugins/rollup/public/crud_app/services/track_ui_metric.ts index 69a5995386bd7..aa1cc2dfea323 100644 --- a/x-pack/legacy/plugins/rollup/public/crud_app/services/track_ui_metric.js +++ b/x-pack/plugins/rollup/public/crud_app/services/track_ui_metric.ts @@ -4,20 +4,16 @@ * you may not use this file except in compliance with the Elastic License. */ -import { - createUiStatsReporter, - METRIC_TYPE, -} from '../../../../../../../src/legacy/core_plugins/ui_metric/public'; -import { UIM_APP_NAME } from '../../../common'; +import { METRIC_TYPE } from '@kbn/analytics'; +import { trackUiMetric } from '../../kibana_services'; -export const trackUiMetric = createUiStatsReporter(UIM_APP_NAME); export { METRIC_TYPE }; /** * Transparently return provided request Promise, while allowing us to track * a successful completion of the request. */ -export function trackUserRequest(request, actionType) { +export function trackUserRequest(request: Promise, actionType: string) { // Only track successful actions. return request.then(response => { trackUiMetric(METRIC_TYPE.LOADED, actionType); diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/action_types.js b/x-pack/plugins/rollup/public/crud_app/store/action_types.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/action_types.js rename to x-pack/plugins/rollup/public/crud_app/store/action_types.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/change_job_status.js b/x-pack/plugins/rollup/public/crud_app/store/actions/change_job_status.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/actions/change_job_status.js rename to x-pack/plugins/rollup/public/crud_app/store/actions/change_job_status.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/clone_job.js b/x-pack/plugins/rollup/public/crud_app/store/actions/clone_job.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/actions/clone_job.js rename to x-pack/plugins/rollup/public/crud_app/store/actions/clone_job.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js b/x-pack/plugins/rollup/public/crud_app/store/actions/create_job.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js rename to x-pack/plugins/rollup/public/crud_app/store/actions/create_job.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/delete_jobs.js b/x-pack/plugins/rollup/public/crud_app/store/actions/delete_jobs.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/actions/delete_jobs.js rename to x-pack/plugins/rollup/public/crud_app/store/actions/delete_jobs.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/detail_panel.js b/x-pack/plugins/rollup/public/crud_app/store/actions/detail_panel.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/actions/detail_panel.js rename to x-pack/plugins/rollup/public/crud_app/store/actions/detail_panel.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/index.js b/x-pack/plugins/rollup/public/crud_app/store/actions/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/actions/index.js rename to x-pack/plugins/rollup/public/crud_app/store/actions/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/load_jobs.js b/x-pack/plugins/rollup/public/crud_app/store/actions/load_jobs.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/actions/load_jobs.js rename to x-pack/plugins/rollup/public/crud_app/store/actions/load_jobs.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/refresh_jobs.js b/x-pack/plugins/rollup/public/crud_app/store/actions/refresh_jobs.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/actions/refresh_jobs.js rename to x-pack/plugins/rollup/public/crud_app/store/actions/refresh_jobs.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/actions/table_state.js b/x-pack/plugins/rollup/public/crud_app/store/actions/table_state.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/actions/table_state.js rename to x-pack/plugins/rollup/public/crud_app/store/actions/table_state.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/index.js b/x-pack/plugins/rollup/public/crud_app/store/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/index.js rename to x-pack/plugins/rollup/public/crud_app/store/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/middleware/clone_job.js b/x-pack/plugins/rollup/public/crud_app/store/middleware/clone_job.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/middleware/clone_job.js rename to x-pack/plugins/rollup/public/crud_app/store/middleware/clone_job.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/middleware/detail_panel.js b/x-pack/plugins/rollup/public/crud_app/store/middleware/detail_panel.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/middleware/detail_panel.js rename to x-pack/plugins/rollup/public/crud_app/store/middleware/detail_panel.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/middleware/index.js b/x-pack/plugins/rollup/public/crud_app/store/middleware/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/middleware/index.js rename to x-pack/plugins/rollup/public/crud_app/store/middleware/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/clone_job.js b/x-pack/plugins/rollup/public/crud_app/store/reducers/clone_job.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/clone_job.js rename to x-pack/plugins/rollup/public/crud_app/store/reducers/clone_job.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/create_job.js b/x-pack/plugins/rollup/public/crud_app/store/reducers/create_job.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/create_job.js rename to x-pack/plugins/rollup/public/crud_app/store/reducers/create_job.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/detail_panel.js b/x-pack/plugins/rollup/public/crud_app/store/reducers/detail_panel.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/detail_panel.js rename to x-pack/plugins/rollup/public/crud_app/store/reducers/detail_panel.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/index.js b/x-pack/plugins/rollup/public/crud_app/store/reducers/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/index.js rename to x-pack/plugins/rollup/public/crud_app/store/reducers/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/jobs.js b/x-pack/plugins/rollup/public/crud_app/store/reducers/jobs.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/jobs.js rename to x-pack/plugins/rollup/public/crud_app/store/reducers/jobs.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/table_state.js b/x-pack/plugins/rollup/public/crud_app/store/reducers/table_state.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/table_state.js rename to x-pack/plugins/rollup/public/crud_app/store/reducers/table_state.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/update_job.js b/x-pack/plugins/rollup/public/crud_app/store/reducers/update_job.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/reducers/update_job.js rename to x-pack/plugins/rollup/public/crud_app/store/reducers/update_job.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/selectors/index.js b/x-pack/plugins/rollup/public/crud_app/store/selectors/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/selectors/index.js rename to x-pack/plugins/rollup/public/crud_app/store/selectors/index.js diff --git a/x-pack/legacy/plugins/rollup/public/crud_app/store/store.js b/x-pack/plugins/rollup/public/crud_app/store/store.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/crud_app/store/store.js rename to x-pack/plugins/rollup/public/crud_app/store/store.js diff --git a/x-pack/legacy/plugins/rollup/public/extend_index_management/index.ts b/x-pack/plugins/rollup/public/extend_index_management/index.ts similarity index 100% rename from x-pack/legacy/plugins/rollup/public/extend_index_management/index.ts rename to x-pack/plugins/rollup/public/extend_index_management/index.ts diff --git a/x-pack/legacy/plugins/rollup/public/index.scss b/x-pack/plugins/rollup/public/index.scss similarity index 67% rename from x-pack/legacy/plugins/rollup/public/index.scss rename to x-pack/plugins/rollup/public/index.scss index 0ad0eac50f7b9..cbbedcebb043e 100644 --- a/x-pack/legacy/plugins/rollup/public/index.scss +++ b/x-pack/plugins/rollup/public/index.scss @@ -1,6 +1,3 @@ -// Import the EUI global scope so we can use EUI constants -@import 'src/legacy/ui/public/styles/_styling_constants'; - // Index management plugin styles // Prefix all styles with "rollup" to avoid conflicts. diff --git a/x-pack/plugins/rollup/public/index.ts b/x-pack/plugins/rollup/public/index.ts new file mode 100644 index 0000000000000..4c965fc38f4e7 --- /dev/null +++ b/x-pack/plugins/rollup/public/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { RollupPlugin } from './plugin'; + +export const plugin = () => new RollupPlugin(); diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/index.js b/x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/index.js rename to x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/index.js diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js b/x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js rename to x-pack/plugins/rollup/public/index_pattern_creation/components/rollup_prompt/rollup_prompt.js diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js b/x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js similarity index 97% rename from x-pack/legacy/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js rename to x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js index f4de2a3098127..c29fba44285be 100644 --- a/x-pack/legacy/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js +++ b/x-pack/plugins/rollup/public/index_pattern_creation/rollup_index_pattern_creation_config.js @@ -8,7 +8,7 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { RollupPrompt } from './components/rollup_prompt'; -import { IndexPatternCreationConfig } from '../../../../../../src/plugins/index_pattern_management/public'; +import { IndexPatternCreationConfig } from '../../../../../src/plugins/index_pattern_management/public'; const rollupIndexPatternTypeName = i18n.translate( 'xpack.rollupJobs.editRollupIndexPattern.createIndex.defaultTypeName', diff --git a/x-pack/legacy/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js b/x-pack/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js similarity index 93% rename from x-pack/legacy/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js rename to x-pack/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js index 809a76d1868b2..e61287d303643 100644 --- a/x-pack/legacy/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js +++ b/x-pack/plugins/rollup/public/index_pattern_list/rollup_index_pattern_list_config.js @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { IndexPatternListConfig } from '../../../../../../src/plugins/index_pattern_management/public'; +import { IndexPatternListConfig } from '../../../../../src/plugins/index_pattern_management/public'; function isRollup(indexPattern) { return ( diff --git a/x-pack/legacy/plugins/rollup/public/kibana_services.ts b/x-pack/plugins/rollup/public/kibana_services.ts similarity index 57% rename from x-pack/legacy/plugins/rollup/public/kibana_services.ts rename to x-pack/plugins/rollup/public/kibana_services.ts index 335eeb90282ca..edbf69568f5e5 100644 --- a/x-pack/legacy/plugins/rollup/public/kibana_services.ts +++ b/x-pack/plugins/rollup/public/kibana_services.ts @@ -4,7 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { NotificationsStart, FatalErrorsSetup } from 'src/core/public'; +import { NotificationsStart, FatalErrorsSetup } from 'kibana/public'; +import { UiStatsMetricType } from '@kbn/analytics'; +import { createGetterSetter } from '../../../../src/plugins/kibana_utils/common'; let notifications: NotificationsStart | null = null; let fatalErrors: FatalErrorsSetup | null = null; @@ -28,3 +30,18 @@ export function getFatalErrors() { export function setFatalErrors(newFatalErrors: FatalErrorsSetup) { fatalErrors = newFatalErrors; } + +export const [getUiStatsReporter, setUiStatsReporter] = createGetterSetter< + (type: UiStatsMetricType, eventNames: string | string[], count?: number) => void +>('uiMetric'); + +// default value if usageCollection is not available +setUiStatsReporter(() => {}); + +export function trackUiMetric( + type: UiStatsMetricType, + eventNames: string | string[], + count?: number +) { + getUiStatsReporter()(type, eventNames, count); +} diff --git a/x-pack/legacy/plugins/rollup/public/plugin.ts b/x-pack/plugins/rollup/public/plugin.ts similarity index 73% rename from x-pack/legacy/plugins/rollup/public/plugin.ts rename to x-pack/plugins/rollup/public/plugin.ts index 17ec8a5a4aedf..fd1b90fbc9855 100644 --- a/x-pack/legacy/plugins/rollup/public/plugin.ts +++ b/x-pack/plugins/rollup/public/plugin.ts @@ -6,7 +6,6 @@ import { i18n } from '@kbn/i18n'; import { CoreSetup, CoreStart, Plugin } from 'kibana/public'; -import { PluginsStart } from './legacy_imports'; import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_management'; // @ts-ignore import { RollupIndexPatternCreationConfig } from './index_pattern_creation/rollup_index_pattern_creation_config'; @@ -16,35 +15,49 @@ import { RollupIndexPatternListConfig } from './index_pattern_list/rollup_index_ import { initAggTypeFilter } from './visualize/agg_type_filter'; // @ts-ignore import { initAggTypeFieldFilter } from './visualize/agg_type_field_filter'; -import { CONFIG_ROLLUPS } from '../common'; +import { CONFIG_ROLLUPS, UIM_APP_NAME } from '../common'; import { FeatureCatalogueCategory, HomePublicPluginSetup, -} from '../../../../../src/plugins/home/public'; +} from '../../../../src/plugins/home/public'; // @ts-ignore import { CRUD_APP_BASE_PATH } from './crud_app/constants'; -import { ManagementSetup } from '../../../../../src/plugins/management/public'; -import { IndexManagementPluginSetup } from '../../../../plugins/index_management/public'; -import { IndexPatternManagementSetup } from '../../../../../src/plugins/index_pattern_management/public'; -import { search } from '../../../../../src/plugins/data/public'; +import { ManagementSetup } from '../../../../src/plugins/management/public'; +import { IndexManagementPluginSetup } from '../../index_management/public'; +import { IndexPatternManagementSetup } from '../../../../src/plugins/index_pattern_management/public'; +import { DataPublicPluginStart, search } from '../../../../src/plugins/data/public'; // @ts-ignore -import { setEsBaseAndXPackBase, setHttp } from './crud_app/services'; -import { setNotifications, setFatalErrors } from './kibana_services'; -import { renderApp } from './application'; +import { setEsBaseAndXPackBase, setHttp } from './crud_app/services/index'; +import { setNotifications, setFatalErrors, setUiStatsReporter } from './kibana_services'; +import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/public'; export interface RollupPluginSetupDependencies { home?: HomePublicPluginSetup; management: ManagementSetup; indexManagement?: IndexManagementPluginSetup; indexPatternManagement: IndexPatternManagementSetup; + usageCollection?: UsageCollectionSetup; +} + +export interface RollupPluginStartDependencies { + data: DataPublicPluginStart; } export class RollupPlugin implements Plugin { setup( core: CoreSetup, - { home, management, indexManagement, indexPatternManagement }: RollupPluginSetupDependencies + { + home, + management, + indexManagement, + indexPatternManagement, + usageCollection, + }: RollupPluginSetupDependencies ) { setFatalErrors(core.fatalErrors); + if (usageCollection) { + setUiStatsReporter(usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME)); + } if (indexManagement) { indexManagement.extensionsService.addBadge(rollupBadgeExtension); @@ -79,7 +92,7 @@ export class RollupPlugin implements Plugin { id: 'rollup_jobs', title: i18n.translate('xpack.rollupJobs.appTitle', { defaultMessage: 'Rollup Jobs' }), order: 3, - mount(params) { + async mount(params) { params.setBreadcrumbs([ { text: i18n.translate('xpack.rollupJobs.breadcrumbsTitle', { @@ -87,6 +100,7 @@ export class RollupPlugin implements Plugin { }), }, ]); + const { renderApp } = await import('./application'); return renderApp(core, params); }, @@ -94,7 +108,7 @@ export class RollupPlugin implements Plugin { } } - start(core: CoreStart, plugins: PluginsStart) { + start(core: CoreStart, plugins: RollupPluginStartDependencies) { setHttp(core.http); setNotifications(core.notifications); setEsBaseAndXPackBase(core.docLinks.ELASTIC_WEBSITE_URL, core.docLinks.DOC_LINK_VERSION); diff --git a/x-pack/legacy/plugins/rollup/public/shared_imports.ts b/x-pack/plugins/rollup/public/shared_imports.ts similarity index 76% rename from x-pack/legacy/plugins/rollup/public/shared_imports.ts rename to x-pack/plugins/rollup/public/shared_imports.ts index 6bf74da6db6fe..1ac25a1a0e5f8 100644 --- a/x-pack/legacy/plugins/rollup/public/shared_imports.ts +++ b/x-pack/plugins/rollup/public/shared_imports.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export { indices } from '../../../../../src/plugins/es_ui_shared/public'; +export { indices } from '../../../../src/plugins/es_ui_shared/public'; diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/constants.js b/x-pack/plugins/rollup/public/test/client_integration/helpers/constants.js similarity index 100% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/constants.js rename to x-pack/plugins/rollup/public/test/client_integration/helpers/constants.js diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/index.js b/x-pack/plugins/rollup/public/test/client_integration/helpers/index.js similarity index 100% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/index.js rename to x-pack/plugins/rollup/public/test/client_integration/helpers/index.js diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_clone.helpers.js b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_clone.helpers.js similarity index 83% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_clone.helpers.js rename to x-pack/plugins/rollup/public/test/client_integration/helpers/job_clone.helpers.js index a8376bb31b23f..fa9929a207615 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_clone.helpers.js +++ b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_clone.helpers.js @@ -5,10 +5,10 @@ */ import { registerTestBed } from '../../../../../../test_utils'; -import { createRollupJobsStore } from '../../../public/crud_app/store'; -import { JobCreate } from '../../../public/crud_app/sections'; +import { createRollupJobsStore } from '../../../crud_app/store'; +import { JobCreate } from '../../../crud_app/sections'; import { JOB_TO_CLONE } from './constants'; -import { deserializeJob } from '../../../public/crud_app/services'; +import { deserializeJob } from '../../../crud_app/services'; import { wrapComponent } from './setup_context'; diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_create.helpers.js b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_create.helpers.js similarity index 96% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_create.helpers.js rename to x-pack/plugins/rollup/public/test/client_integration/helpers/job_create.helpers.js index 2395fd014dd1e..7ddcfa9eb83ff 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_create.helpers.js +++ b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_create.helpers.js @@ -5,8 +5,8 @@ */ import { registerTestBed } from '../../../../../../test_utils'; -import { rollupJobsStore } from '../../../public/crud_app/store'; -import { JobCreate } from '../../../public/crud_app/sections'; +import { rollupJobsStore } from '../../../crud_app/store'; +import { JobCreate } from '../../../crud_app/sections'; import { JOB_TO_CREATE } from './constants'; diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_list.helpers.js b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_list.helpers.js similarity index 74% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_list.helpers.js rename to x-pack/plugins/rollup/public/test/client_integration/helpers/job_list.helpers.js index bcad8c29c87c0..fda1ec8cfed22 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/job_list.helpers.js +++ b/x-pack/plugins/rollup/public/test/client_integration/helpers/job_list.helpers.js @@ -5,9 +5,9 @@ */ import { registerTestBed } from '../../../../../../test_utils'; -import { registerRouter } from '../../../public/crud_app/services'; -import { createRollupJobsStore } from '../../../public/crud_app/store'; -import { JobList } from '../../../public/crud_app/sections/job_list'; +import { registerRouter } from '../../../crud_app/services'; +import { createRollupJobsStore } from '../../../crud_app/store'; +import { JobList } from '../../../crud_app/sections/job_list'; import { wrapComponent } from './setup_context'; diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_context.tsx b/x-pack/plugins/rollup/public/test/client_integration/helpers/setup_context.tsx similarity index 100% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_context.tsx rename to x-pack/plugins/rollup/public/test/client_integration/helpers/setup_context.tsx diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_environment.ts b/x-pack/plugins/rollup/public/test/client_integration/helpers/setup_environment.ts similarity index 100% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/helpers/setup_environment.ts rename to x-pack/plugins/rollup/public/test/client_integration/helpers/setup_environment.ts diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_clone.test.js b/x-pack/plugins/rollup/public/test/client_integration/job_create_clone.test.js similarity index 93% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_clone.test.js rename to x-pack/plugins/rollup/public/test/client_integration/job_create_clone.test.js index b7c98ed179c7a..7b61a03dcde45 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_clone.test.js +++ b/x-pack/plugins/rollup/public/test/client_integration/job_create_clone.test.js @@ -4,11 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setHttp } from '../../public/crud_app/services'; +import { setHttp } from '../../crud_app/services'; import { mockHttpRequest, pageHelpers, nextTick } from './helpers'; import { JOB_TO_CLONE, JOB_CLONE_INDEX_PATTERN_CHECK } from './helpers/constants'; - -jest.mock('ui/new_platform'); +import { coreMock } from '../../../../../../src/core/public/mocks'; jest.mock('lodash/function/debounce', () => fn => fn); @@ -23,23 +22,23 @@ describe('Cloning a rollup job through create job wizard', () => { let form; let table; let actions; - let npStart; + let startMock; beforeAll(() => { - npStart = require('ui/new_platform').npStart; // eslint-disable-line - setHttp(npStart.core.http); + startMock = coreMock.createStart(); + setHttp(startMock.http); }); beforeEach(() => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: JOB_CLONE_INDEX_PATTERN_CHECK }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: JOB_CLONE_INDEX_PATTERN_CHECK }); ({ exists, find, form, actions, table } = setup()); }); afterEach(() => { - npStart.core.http.get.mockClear(); - npStart.core.http.post.mockClear(); - npStart.core.http.put.mockClear(); + startMock.http.get.mockClear(); + startMock.http.post.mockClear(); + startMock.http.put.mockClear(); }); it('should have fields correctly pre-populated', async () => { diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_date_histogram.test.js b/x-pack/plugins/rollup/public/test/client_integration/job_create_date_histogram.test.js similarity index 88% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_date_histogram.test.js rename to x-pack/plugins/rollup/public/test/client_integration/job_create_date_histogram.test.js index b8ec7d9f85d00..095609ac2b2d7 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_date_histogram.test.js +++ b/x-pack/plugins/rollup/public/test/client_integration/job_create_date_histogram.test.js @@ -6,10 +6,9 @@ import moment from 'moment-timezone'; -import { setHttp } from '../../public/crud_app/services'; +import { setHttp } from '../../crud_app/services'; import { mockHttpRequest, pageHelpers } from './helpers'; - -jest.mock('ui/new_platform'); +import { coreMock } from '../../../../../../src/core/public/mocks'; jest.mock('lodash/function/debounce', () => fn => fn); @@ -22,23 +21,23 @@ describe('Create Rollup Job, step 2: Date histogram', () => { let goToStep; let form; let getEuiStepsHorizontalActive; - let npStart; + let startMock; beforeAll(() => { - npStart = require('ui/new_platform').npStart; // eslint-disable-line - setHttp(npStart.core.http); + startMock = coreMock.createStart(); + setHttp(startMock.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - mockHttpRequest(npStart.core.http); + mockHttpRequest(startMock.http); ({ find, exists, actions, form, getEuiStepsHorizontalActive, goToStep } = setup()); }); afterEach(() => { - npStart.core.http.get.mockClear(); - npStart.core.http.post.mockClear(); - npStart.core.http.put.mockClear(); + startMock.http.get.mockClear(); + startMock.http.post.mockClear(); + startMock.http.put.mockClear(); }); describe('layout', () => { @@ -73,7 +72,7 @@ describe('Create Rollup Job, step 2: Date histogram', () => { describe('Date field select', () => { it('should set the options value from the index pattern', async () => { const dateFields = ['field1', 'field2', 'field3']; - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { dateFields } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { dateFields } }); await goToStep(2); @@ -85,7 +84,7 @@ describe('Create Rollup Job, step 2: Date histogram', () => { it('should sort the options in ascending order', async () => { const dateFields = ['field3', 'field2', 'field1']; - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { dateFields } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { dateFields } }); await goToStep(2); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_histogram.test.js b/x-pack/plugins/rollup/public/test/client_integration/job_create_histogram.test.js similarity index 91% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_histogram.test.js rename to x-pack/plugins/rollup/public/test/client_integration/job_create_histogram.test.js index c4b5d753f1a26..141aa06843556 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_histogram.test.js +++ b/x-pack/plugins/rollup/public/test/client_integration/job_create_histogram.test.js @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setHttp } from '../../public/crud_app/services'; +import { setHttp } from '../../crud_app/services'; import { mockHttpRequest, pageHelpers } from './helpers'; - -jest.mock('ui/new_platform'); +import { coreMock } from '../../../../../../src/core/public/mocks'; jest.mock('lodash/function/debounce', () => fn => fn); @@ -21,24 +20,24 @@ describe('Create Rollup Job, step 4: Histogram', () => { let goToStep; let table; let form; - let npStart; + let startMock; beforeAll(() => { - npStart = require('ui/new_platform').npStart; // eslint-disable-line - setHttp(npStart.core.http); + startMock = coreMock.createStart(); + setHttp(startMock.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - mockHttpRequest(npStart.core.http); + mockHttpRequest(startMock.http); ({ find, exists, actions, getEuiStepsHorizontalActive, goToStep, table, form } = setup()); }); afterEach(() => { - npStart.core.http.get.mockClear(); - npStart.core.http.post.mockClear(); - npStart.core.http.put.mockClear(); + startMock.http.get.mockClear(); + startMock.http.post.mockClear(); + startMock.http.put.mockClear(); }); const numericFields = ['a-numericField', 'b-numericField']; @@ -111,7 +110,7 @@ describe('Create Rollup Job, step 4: Histogram', () => { describe('when no histogram fields are availalbe', () => { it('should indicate it to the user', async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields: [] } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields: [] } }); await goToStepAndOpenFieldChooser(); const { tableCellsValues } = table.getMetaData('rollupJobHistogramFieldChooser-table'); @@ -122,7 +121,7 @@ describe('Create Rollup Job, step 4: Histogram', () => { describe('when histogram fields are available', () => { beforeEach(async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields } }); await goToStepAndOpenFieldChooser(); }); @@ -156,7 +155,7 @@ describe('Create Rollup Job, step 4: Histogram', () => { it('should have a delete button on each row to remove an histogram field', async () => { // First let's add a term to the list - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields } }); await goToStepAndOpenFieldChooser(); const { rows: fieldChooserRows } = table.getMetaData('rollupJobHistogramFieldChooser-table'); fieldChooserRows[0].reactWrapper.simulate('click'); @@ -183,7 +182,7 @@ describe('Create Rollup Job, step 4: Histogram', () => { }; beforeEach(async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields } }); await goToStep(4); addHistogramFieldToList(); }); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js b/x-pack/plugins/rollup/public/test/client_integration/job_create_logistics.test.js similarity index 96% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js rename to x-pack/plugins/rollup/public/test/client_integration/job_create_logistics.test.js index ebc03e40cc2b9..7b89244bb52a9 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_logistics.test.js +++ b/x-pack/plugins/rollup/public/test/client_integration/job_create_logistics.test.js @@ -13,10 +13,9 @@ import { YEAR, } from '../../../../../../src/plugins/es_ui_shared/public'; import { indexPatterns } from '../../../../../../src/plugins/data/public'; -import { setHttp } from '../../public/crud_app/services'; +import { setHttp } from '../../crud_app/services'; import { mockHttpRequest, pageHelpers } from './helpers'; - -jest.mock('ui/new_platform'); +import { coreMock } from '../../../../../../src/core/public/mocks'; jest.mock('lodash/function/debounce', () => fn => fn); @@ -28,24 +27,24 @@ describe('Create Rollup Job, step 1: Logistics', () => { let actions; let form; let getEuiStepsHorizontalActive; - let npStart; + let startMock; beforeAll(() => { - npStart = require('ui/new_platform').npStart; // eslint-disable-line - setHttp(npStart.core.http); + startMock = coreMock.createStart(); + setHttp(startMock.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - mockHttpRequest(npStart.core.http); + mockHttpRequest(startMock.http); ({ find, exists, actions, form, getEuiStepsHorizontalActive } = setup()); }); afterEach(() => { - npStart.core.http.get.mockClear(); - npStart.core.http.post.mockClear(); - npStart.core.http.put.mockClear(); + startMock.http.get.mockClear(); + startMock.http.post.mockClear(); + startMock.http.put.mockClear(); }); it('should have the horizontal step active on "Logistics"', () => { @@ -97,14 +96,14 @@ describe('Create Rollup Job, step 1: Logistics', () => { }); it('should not allow an unknown index pattern', async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { doesMatchIndices: false } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { doesMatchIndices: false } }); await form.setInputValue('rollupIndexPattern', 'unknown', true); actions.clickNextStep(); expect(form.getErrorsMessages()).toContain("Index pattern doesn't match any indices."); }); it('should not allow an index pattern without time fields', async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { dateFields: [] } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { dateFields: [] } }); await form.setInputValue('rollupIndexPattern', 'abc', true); actions.clickNextStep(); expect(form.getErrorsMessages()).toContain( @@ -113,7 +112,7 @@ describe('Create Rollup Job, step 1: Logistics', () => { }); it('should not allow an index pattern that matches a rollup index', async () => { - mockHttpRequest(npStart.core.http, { + mockHttpRequest(startMock.http, { indxPatternVldtResp: { doesMatchRollupIndices: true }, }); await form.setInputValue('rollupIndexPattern', 'abc', true); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_metrics.test.js b/x-pack/plugins/rollup/public/test/client_integration/job_create_metrics.test.js similarity index 95% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_metrics.test.js rename to x-pack/plugins/rollup/public/test/client_integration/job_create_metrics.test.js index a72dc8b25c083..1e9dd88648da6 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_metrics.test.js +++ b/x-pack/plugins/rollup/public/test/client_integration/job_create_metrics.test.js @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setHttp } from '../../public/crud_app/services'; +import { setHttp } from '../../crud_app/services'; import { mockHttpRequest, pageHelpers } from './helpers'; - -jest.mock('ui/new_platform'); +import { coreMock } from '../../../../../../src/core/public/mocks'; jest.mock('lodash/function/debounce', () => fn => fn); @@ -21,24 +20,24 @@ describe('Create Rollup Job, step 5: Metrics', () => { let goToStep; let table; let metrics; - let npStart; + let startMock; beforeAll(() => { - npStart = require('ui/new_platform').npStart; // eslint-disable-line - setHttp(npStart.core.http); + startMock = coreMock.createStart(); + setHttp(startMock.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - mockHttpRequest(npStart.core.http); + mockHttpRequest(startMock.http); ({ find, exists, actions, getEuiStepsHorizontalActive, goToStep, table, metrics } = setup()); }); afterEach(() => { - npStart.core.http.get.mockClear(); - npStart.core.http.post.mockClear(); - npStart.core.http.put.mockClear(); + startMock.http.get.mockClear(); + startMock.http.post.mockClear(); + startMock.http.put.mockClear(); }); const numericFields = ['a-numericField', 'c-numericField']; @@ -112,7 +111,7 @@ describe('Create Rollup Job, step 5: Metrics', () => { describe('table', () => { beforeEach(async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields, dateFields } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields, dateFields } }); await goToStepAndOpenFieldChooser(); }); @@ -169,7 +168,7 @@ describe('Create Rollup Job, step 5: Metrics', () => { describe('when fields are added', () => { beforeEach(async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields, dateFields } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields, dateFields } }); await goToStepAndOpenFieldChooser(); }); @@ -260,7 +259,7 @@ describe('Create Rollup Job, step 5: Metrics', () => { let getFieldListTableRows; beforeEach(async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields, dateFields } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields, dateFields } }); await goToStep(5); await addFieldToList('numeric'); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js b/x-pack/plugins/rollup/public/test/client_integration/job_create_review.test.js similarity index 71% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js rename to x-pack/plugins/rollup/public/test/client_integration/job_create_review.test.js index 0fa9509368d3f..d625b8f11208f 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_review.test.js +++ b/x-pack/plugins/rollup/public/test/client_integration/job_create_review.test.js @@ -6,13 +6,20 @@ import { pageHelpers, mockHttpRequest } from './helpers'; import { first } from 'lodash'; -import { setHttp } from '../../public/crud_app/services'; +import { setHttp } from '../../crud_app/services'; import { JOBS } from './helpers/constants'; - -jest.mock('ui/new_platform'); +import { coreMock } from '../../../../../../src/core/public/mocks'; jest.mock('lodash/function/debounce', () => fn => fn); +jest.mock('../../kibana_services', () => { + const services = require.requireActual('../../kibana_services'); + return { + ...services, + getUiStatsReporter: jest.fn(() => () => {}), + }; +}); + const { setup } = pageHelpers.jobCreate; describe('Create Rollup Job, step 6: Review', () => { @@ -23,23 +30,23 @@ describe('Create Rollup Job, step 6: Review', () => { let goToStep; let table; let form; - let npStart; + let startMock; beforeAll(() => { - npStart = require('ui/new_platform').npStart; // eslint-disable-line - setHttp(npStart.core.http); + startMock = coreMock.createStart(); + setHttp(startMock.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - mockHttpRequest(npStart.core.http); + mockHttpRequest(startMock.http); ({ find, exists, actions, getEuiStepsHorizontalActive, goToStep, table, form } = setup()); }); afterEach(() => { - npStart.core.http.get.mockClear(); - npStart.core.http.post.mockClear(); - npStart.core.http.put.mockClear(); + startMock.http.get.mockClear(); + startMock.http.post.mockClear(); + startMock.http.put.mockClear(); }); describe('layout', () => { @@ -84,7 +91,7 @@ describe('Create Rollup Job, step 6: Review', () => { }); it('should have a "Summary", "Terms" & "Request" tab if a term aggregation was added', async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields: ['my-field'] } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields: ['my-field'] } }); await goToStep(3); selectFirstField('Terms'); @@ -96,7 +103,7 @@ describe('Create Rollup Job, step 6: Review', () => { }); it('should have a "Summary", "Histogram" & "Request" tab if a histogram field was added', async () => { - mockHttpRequest(npStart.core.http, { indxPatternVldtResp: { numericFields: ['a-field'] } }); + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields: ['a-field'] } }); await goToStep(4); selectFirstField('Histogram'); form.setInputValue('rollupJobCreateHistogramInterval', 3); // set an interval @@ -108,7 +115,7 @@ describe('Create Rollup Job, step 6: Review', () => { }); it('should have a "Summary", "Metrics" & "Request" tab if a histogram field was added', async () => { - mockHttpRequest(npStart.core.http, { + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields: ['a-field'], dateFields: ['b-field'], @@ -130,28 +137,28 @@ describe('Create Rollup Job, step 6: Review', () => { describe('without starting job after creation', () => { it('should call the "create" Api server endpoint', async () => { - mockHttpRequest(npStart.core.http, { + mockHttpRequest(startMock.http, { createdJob: first(JOBS.jobs), }); await goToStep(6); - expect(npStart.core.http.put).not.toHaveBeenCalledWith(jobCreateApiPath); // make sure it hasn't been called - expect(npStart.core.http.get).not.toHaveBeenCalledWith(jobStartApiPath); // make sure it hasn't been called + expect(startMock.http.put).not.toHaveBeenCalledWith(jobCreateApiPath); // make sure it hasn't been called + expect(startMock.http.get).not.toHaveBeenCalledWith(jobStartApiPath); // make sure it hasn't been called actions.clickSave(); - // Given the following anti-jitter sleep x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js + // Given the following anti-jitter sleep x-pack/plugins/rollup/public/crud_app/store/actions/create_job.js // we add a longer sleep here :( await new Promise(res => setTimeout(res, 750)); - expect(npStart.core.http.put).toHaveBeenCalledWith(jobCreateApiPath, expect.anything()); // It has been called! - expect(npStart.core.http.get).not.toHaveBeenCalledWith(jobStartApiPath); // It has still not been called! + expect(startMock.http.put).toHaveBeenCalledWith(jobCreateApiPath, expect.anything()); // It has been called! + expect(startMock.http.get).not.toHaveBeenCalledWith(jobStartApiPath); // It has still not been called! }); }); describe('with starting job after creation', () => { it('should call the "create" and "start" Api server endpoints', async () => { - mockHttpRequest(npStart.core.http, { + mockHttpRequest(startMock.http, { createdJob: first(JOBS.jobs), }); @@ -161,14 +168,14 @@ describe('Create Rollup Job, step 6: Review', () => { target: { checked: true }, }); - expect(npStart.core.http.post).not.toHaveBeenCalledWith(jobStartApiPath); // make sure it hasn't been called + expect(startMock.http.post).not.toHaveBeenCalledWith(jobStartApiPath); // make sure it hasn't been called actions.clickSave(); - // Given the following anti-jitter sleep x-pack/legacy/plugins/rollup/public/crud_app/store/actions/create_job.js + // Given the following anti-jitter sleep x-pack/plugins/rollup/public/crud_app/store/actions/create_job.js // we add a longer sleep here :( await new Promise(res => setTimeout(res, 750)); - expect(npStart.core.http.post).toHaveBeenCalledWith(jobStartApiPath, expect.anything()); // It has been called! + expect(startMock.http.post).toHaveBeenCalledWith(jobStartApiPath, expect.anything()); // It has been called! }); }); }); diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_terms.test.js b/x-pack/plugins/rollup/public/test/client_integration/job_create_terms.test.js similarity index 93% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_terms.test.js rename to x-pack/plugins/rollup/public/test/client_integration/job_create_terms.test.js index f111a7df2c250..61993f3092840 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_create_terms.test.js +++ b/x-pack/plugins/rollup/public/test/client_integration/job_create_terms.test.js @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { setHttp } from '../../public/crud_app/services'; +import { setHttp } from '../../crud_app/services'; import { pageHelpers, mockHttpRequest } from './helpers'; - -jest.mock('ui/new_platform'); +import { coreMock } from '../../../../../../src/core/public/mocks'; jest.mock('lodash/function/debounce', () => fn => fn); @@ -20,22 +19,22 @@ describe('Create Rollup Job, step 3: Terms', () => { let getEuiStepsHorizontalActive; let goToStep; let table; - let npStart; + let startMock; beforeAll(() => { - npStart = require('ui/new_platform').npStart; // eslint-disable-line - setHttp(npStart.core.http); + startMock = coreMock.createStart(); + setHttp(startMock.http); }); beforeEach(() => { // Set "default" mock responses by not providing any arguments - mockHttpRequest(npStart.core.http); + mockHttpRequest(startMock.http); ({ find, exists, actions, getEuiStepsHorizontalActive, goToStep, table } = setup()); }); afterEach(() => { - npStart.core.http.get.mockClear(); + startMock.http.get.mockClear(); }); const numericFields = ['a-numericField', 'c-numericField']; @@ -109,7 +108,7 @@ describe('Create Rollup Job, step 3: Terms', () => { describe('when no terms are available', () => { it('should indicate it to the user', async () => { - mockHttpRequest(npStart.core.http, { + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields: [], keywordFields: [], @@ -125,7 +124,7 @@ describe('Create Rollup Job, step 3: Terms', () => { describe('when terms are available', () => { beforeEach(async () => { - mockHttpRequest(npStart.core.http, { + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields, keywordFields, @@ -171,7 +170,7 @@ describe('Create Rollup Job, step 3: Terms', () => { it('should have a delete button on each row to remove a term', async () => { // First let's add a term to the list - mockHttpRequest(npStart.core.http, { + mockHttpRequest(startMock.http, { indxPatternVldtResp: { numericFields, keywordFields, diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list.test.js b/x-pack/plugins/rollup/public/test/client_integration/job_list.test.js similarity index 77% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list.test.js rename to x-pack/plugins/rollup/public/test/client_integration/job_list.test.js index a9e474cf0b559..c6988236d6b7c 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list.test.js +++ b/x-pack/plugins/rollup/public/test/client_integration/job_list.test.js @@ -4,20 +4,27 @@ * you may not use this file except in compliance with the Elastic License. */ -import { getRouter, setHttp } from '../../public/crud_app/services'; +import { getRouter, setHttp } from '../../crud_app/services'; import { mockHttpRequest, pageHelpers, nextTick } from './helpers'; import { JOBS } from './helpers/constants'; +import { coreMock } from '../../../../../../src/core/public/mocks'; -jest.mock('ui/new_platform'); - -jest.mock('../../public/crud_app/services', () => { - const services = require.requireActual('../../public/crud_app/services'); +jest.mock('../../crud_app/services', () => { + const services = require.requireActual('../../crud_app/services'); return { ...services, getRouterLinkProps: link => ({ href: link }), }; }); +jest.mock('../../kibana_services', () => { + const services = require.requireActual('../../kibana_services'); + return { + ...services, + getUiStatsReporter: jest.fn(() => () => {}), + }; +}); + const { setup } = pageHelpers.jobList; describe('', () => { @@ -25,15 +32,15 @@ describe('', () => { let component; let table; let exists; - let npStart; + let startMock; beforeAll(() => { - npStart = require('ui/new_platform').npStart; // eslint-disable-line - setHttp(npStart.core.http); + startMock = coreMock.createStart(); + setHttp(startMock.http); }); beforeEach(async () => { - mockHttpRequest(npStart.core.http, { jobs: JOBS }); + mockHttpRequest(startMock.http, { jobs: JOBS }); ({ component, exists, table } = setup()); @@ -42,7 +49,7 @@ describe('', () => { }); afterEach(() => { - npStart.core.http.get.mockClear(); + startMock.http.get.mockClear(); }); test('should open the detail panel when clicking on a job in the table', () => { diff --git a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list_clone.test.js b/x-pack/plugins/rollup/public/test/client_integration/job_list_clone.test.js similarity index 74% rename from x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list_clone.test.js rename to x-pack/plugins/rollup/public/test/client_integration/job_list_clone.test.js index 8a36af83def4c..bdf57a555cdad 100644 --- a/x-pack/legacy/plugins/rollup/__jest__/client_integration/job_list_clone.test.js +++ b/x-pack/plugins/rollup/public/test/client_integration/job_list_clone.test.js @@ -6,14 +6,21 @@ import { mockHttpRequest, pageHelpers, nextTick } from './helpers'; import { JOB_TO_CLONE, JOB_CLONE_INDEX_PATTERN_CHECK } from './helpers/constants'; -import { getRouter } from '../../public/crud_app/services/routing'; -import { setHttp } from '../../public/crud_app/services'; -import { CRUD_APP_BASE_PATH } from '../../public/crud_app/constants'; - -jest.mock('ui/new_platform'); +import { getRouter } from '../../crud_app/services/routing'; +import { setHttp } from '../../crud_app/services'; +import { CRUD_APP_BASE_PATH } from '../../crud_app/constants'; +import { coreMock } from '../../../../../../src/core/public/mocks'; jest.mock('lodash/function/debounce', () => fn => fn); +jest.mock('../../kibana_services', () => { + const services = require.requireActual('../../kibana_services'); + return { + ...services, + getUiStatsReporter: jest.fn(() => () => {}), + }; +}); + const { setup } = pageHelpers.jobList; describe('Smoke test cloning an existing rollup job from job list', () => { @@ -21,15 +28,15 @@ describe('Smoke test cloning an existing rollup job from job list', () => { let find; let component; let exists; - let npStart; + let startMock; beforeAll(() => { - npStart = require('ui/new_platform').npStart; // eslint-disable-line - setHttp(npStart.core.http); + startMock = coreMock.createStart(); + setHttp(startMock.http); }); beforeEach(async () => { - mockHttpRequest(npStart.core.http, { + mockHttpRequest(startMock.http, { jobs: JOB_TO_CLONE, indxPatternVldtResp: JOB_CLONE_INDEX_PATTERN_CHECK, }); @@ -41,7 +48,7 @@ describe('Smoke test cloning an existing rollup job from job list', () => { }); afterEach(() => { - npStart.core.http.get.mockClear(); + startMock.http.get.mockClear(); }); it('should navigate to create view with default values set', async () => { diff --git a/x-pack/legacy/plugins/rollup/public/visualize/agg_type_field_filter.js b/x-pack/plugins/rollup/public/visualize/agg_type_field_filter.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/visualize/agg_type_field_filter.js rename to x-pack/plugins/rollup/public/visualize/agg_type_field_filter.js diff --git a/x-pack/legacy/plugins/rollup/public/visualize/agg_type_filter.js b/x-pack/plugins/rollup/public/visualize/agg_type_filter.js similarity index 100% rename from x-pack/legacy/plugins/rollup/public/visualize/agg_type_filter.js rename to x-pack/plugins/rollup/public/visualize/agg_type_filter.js diff --git a/x-pack/plugins/rollup/server/plugin.ts b/x-pack/plugins/rollup/server/plugin.ts index fa05b8d1307d6..ea6d197e22029 100644 --- a/x-pack/plugins/rollup/server/plugin.ts +++ b/x-pack/plugins/rollup/server/plugin.ts @@ -4,7 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Plugin, PluginInitializerContext } from 'src/core/server'; +import { CoreSetup, Plugin, PluginInitializerContext } from 'src/core/server'; +import { i18n } from '@kbn/i18n'; +import { schema } from '@kbn/config-schema'; +import { CONFIG_ROLLUPS } from '../common'; export class RollupPlugin implements Plugin { private readonly initContext: PluginInitializerContext; @@ -13,7 +16,23 @@ export class RollupPlugin implements Plugin { this.initContext = initContext; } - public setup() { + public setup(core: CoreSetup) { + core.uiSettings.register({ + [CONFIG_ROLLUPS]: { + name: i18n.translate('xpack.rollupJobs.rollupIndexPatternsTitle', { + defaultMessage: 'Enable rollup index patterns', + }), + value: true, + description: i18n.translate('xpack.rollupJobs.rollupIndexPatternsDescription', { + defaultMessage: `Enable the creation of index patterns which capture rollup indices, + which in turn enable visualizations based on rollup data. Refresh + the page to apply the changes.`, + }), + category: ['rollups'], + schema: schema.boolean(), + }, + }); + return { __legacy: { config: this.initContext.config, diff --git a/x-pack/plugins/siem/.gitattributes b/x-pack/plugins/siem/.gitattributes new file mode 100644 index 0000000000000..96ab5dadbda10 --- /dev/null +++ b/x-pack/plugins/siem/.gitattributes @@ -0,0 +1,4 @@ +# Auto-collapse generated files in GitHub +# https://help.github.com/en/articles/customizing-how-changed-files-appear-on-github +x-pack/plugins/siem/server/graphql/types.ts linguist-generated=true + diff --git a/x-pack/legacy/plugins/siem/common/constants.ts b/x-pack/plugins/siem/common/constants.ts similarity index 87% rename from x-pack/legacy/plugins/siem/common/constants.ts rename to x-pack/plugins/siem/common/constants.ts index 22f1b3beffa35..edde5c6b8fa0d 100644 --- a/x-pack/legacy/plugins/siem/common/constants.ts +++ b/x-pack/plugins/siem/common/constants.ts @@ -29,6 +29,16 @@ export const DEFAULT_INTERVAL_TYPE = 'manual'; export const DEFAULT_INTERVAL_VALUE = 300000; // ms export const DEFAULT_TIMEPICKER_QUICK_RANGES = 'timepicker:quickRanges'; +/** The comma-delimited list of Elasticsearch indices from which the SIEM app collects events */ +export const DEFAULT_INDEX_PATTERN = [ + 'apm-*-transaction*', + 'auditbeat-*', + 'endgame-*', + 'filebeat-*', + 'packetbeat-*', + 'winlogbeat-*', +]; + /** This Kibana Advanced Setting enables the `Security news` feed widget */ export const ENABLE_NEWS_FEED_SETTING = 'siem:enableNewsFeed'; @@ -111,3 +121,20 @@ export const NOTIFICATION_SUPPORTED_ACTION_TYPES_IDS = [ ]; export const NOTIFICATION_THROTTLE_NO_ACTIONS = 'no_actions'; export const NOTIFICATION_THROTTLE_RULE = 'rule'; + +/** + * Histograms for fields named in this list should be displayed with an + * "All others" bucket, to count events that don't specify a value for + * the field being counted + */ +export const showAllOthersBucket: string[] = [ + 'destination.ip', + 'event.action', + 'event.category', + 'event.dataset', + 'event.module', + 'signal.rule.threat.tactic.name', + 'source.ip', + 'destination.ip', + 'user.name', +]; diff --git a/x-pack/legacy/plugins/siem/default_index_pattern.ts b/x-pack/plugins/siem/common/default_index_pattern.ts similarity index 100% rename from x-pack/legacy/plugins/siem/default_index_pattern.ts rename to x-pack/plugins/siem/common/default_index_pattern.ts diff --git a/x-pack/legacy/plugins/siem/common/detection_engine/ml_helpers.test.ts b/x-pack/plugins/siem/common/detection_engine/ml_helpers.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/common/detection_engine/ml_helpers.test.ts rename to x-pack/plugins/siem/common/detection_engine/ml_helpers.test.ts diff --git a/x-pack/legacy/plugins/siem/common/detection_engine/ml_helpers.ts b/x-pack/plugins/siem/common/detection_engine/ml_helpers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/common/detection_engine/ml_helpers.ts rename to x-pack/plugins/siem/common/detection_engine/ml_helpers.ts diff --git a/x-pack/legacy/plugins/siem/common/detection_engine/transform_actions.test.ts b/x-pack/plugins/siem/common/detection_engine/transform_actions.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/common/detection_engine/transform_actions.test.ts rename to x-pack/plugins/siem/common/detection_engine/transform_actions.test.ts diff --git a/x-pack/legacy/plugins/siem/common/detection_engine/transform_actions.ts b/x-pack/plugins/siem/common/detection_engine/transform_actions.ts similarity index 90% rename from x-pack/legacy/plugins/siem/common/detection_engine/transform_actions.ts rename to x-pack/plugins/siem/common/detection_engine/transform_actions.ts index aeb4d53933022..4ce3823575833 100644 --- a/x-pack/legacy/plugins/siem/common/detection_engine/transform_actions.ts +++ b/x-pack/plugins/siem/common/detection_engine/transform_actions.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertAction } from '../../../../../plugins/alerting/common'; +import { AlertAction } from '../../../alerting/common'; import { RuleAlertAction } from './types'; export const transformRuleToAlertAction = ({ diff --git a/x-pack/legacy/plugins/siem/common/detection_engine/types.ts b/x-pack/plugins/siem/common/detection_engine/types.ts similarity index 88% rename from x-pack/legacy/plugins/siem/common/detection_engine/types.ts rename to x-pack/plugins/siem/common/detection_engine/types.ts index 39012d0b4b683..5a91cfd4809c6 100644 --- a/x-pack/legacy/plugins/siem/common/detection_engine/types.ts +++ b/x-pack/plugins/siem/common/detection_engine/types.ts @@ -5,7 +5,7 @@ */ import * as t from 'io-ts'; -import { AlertAction } from '../../../../../plugins/alerting/common'; +import { AlertAction } from '../../../alerting/common'; export type RuleAlertAction = Omit & { action_type_id: string; diff --git a/x-pack/legacy/plugins/siem/common/graphql/root/index.ts b/x-pack/plugins/siem/common/graphql/root/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/common/graphql/root/index.ts rename to x-pack/plugins/siem/common/graphql/root/index.ts diff --git a/x-pack/legacy/plugins/siem/common/graphql/root/schema.gql.ts b/x-pack/plugins/siem/common/graphql/root/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/common/graphql/root/schema.gql.ts rename to x-pack/plugins/siem/common/graphql/root/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/common/graphql/shared/index.ts b/x-pack/plugins/siem/common/graphql/shared/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/common/graphql/shared/index.ts rename to x-pack/plugins/siem/common/graphql/shared/index.ts diff --git a/x-pack/legacy/plugins/siem/common/graphql/shared/schema.gql.ts b/x-pack/plugins/siem/common/graphql/shared/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/common/graphql/shared/schema.gql.ts rename to x-pack/plugins/siem/common/graphql/shared/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/common/typed_json.ts b/x-pack/plugins/siem/common/typed_json.ts similarity index 91% rename from x-pack/legacy/plugins/siem/common/typed_json.ts rename to x-pack/plugins/siem/common/typed_json.ts index dcd26d176d746..62e7319e091cb 100644 --- a/x-pack/legacy/plugins/siem/common/typed_json.ts +++ b/x-pack/plugins/siem/common/typed_json.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { JsonObject } from '../../../../../src/plugins/kibana_utils/public'; +import { JsonObject } from '../../../../src/plugins/kibana_utils/public'; export type ESQuery = ESRangeQuery | ESQueryStringQuery | ESMatchQuery | ESTermQuery | JsonObject; diff --git a/x-pack/legacy/plugins/siem/common/utility_types.ts b/x-pack/plugins/siem/common/utility_types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/common/utility_types.ts rename to x-pack/plugins/siem/common/utility_types.ts diff --git a/x-pack/legacy/plugins/siem/cypress/.eslintrc.json b/x-pack/plugins/siem/cypress/.eslintrc.json similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/.eslintrc.json rename to x-pack/plugins/siem/cypress/.eslintrc.json diff --git a/x-pack/legacy/plugins/siem/cypress/.gitignore b/x-pack/plugins/siem/cypress/.gitignore similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/.gitignore rename to x-pack/plugins/siem/cypress/.gitignore diff --git a/x-pack/legacy/plugins/siem/cypress/README.md b/x-pack/plugins/siem/cypress/README.md similarity index 93% rename from x-pack/legacy/plugins/siem/cypress/README.md rename to x-pack/plugins/siem/cypress/README.md index 89bafce9c9dc8..d84c66fec1c3a 100644 --- a/x-pack/legacy/plugins/siem/cypress/README.md +++ b/x-pack/plugins/siem/cypress/README.md @@ -124,7 +124,7 @@ yarn kbn bootstrap 2. Launch Cypress command line test runner: ```sh -cd x-pack/legacy/plugins/siem +cd x-pack/plugins/siem yarn cypress:run-as-ci ``` @@ -193,15 +193,15 @@ We are using es_archiver in order to manage the data that our Cypress tests need 1. Setup if possible a clean instance of kibana and elasticsearch (if not, possible please try to clean the data that you are going to generate). 2. With the kibana and elasticsearch instance up and running, create the data that you need for your test. -3. When you are sure that you have all the data you need run the following command from: `x-pack/legacy/plugins/siem` +3. When you are sure that you have all the data you need run the following command from: `x-pack/plugins/siem` ```sh -node ../../../../scripts/es_archiver save --dir ../../../test/siem_cypress/es_archives --config ../../../../test/functional/config.js --es-url http://:@: +node ../../../scripts/es_archiver save --dir ../../test/siem_cypress/es_archives --config ../../../test/functional/config.js --es-url http://:@: ``` Example: ```sh -node ../../../../scripts/es_archiver save custom_rules ".kibana",".siem-signal*" --dir ../../../test/siem_cypress/es_archives --config ../../../../test/functional/config.js --es-url http://elastic:changeme@localhost:9220 +node ../../../scripts/es_archiver save custom_rules ".kibana",".siem-signal*" --dir ../../test/siem_cypress/es_archives --config ../../../test/functional/config.js --es-url http://elastic:changeme@localhost:9220 ``` Note that the command is going to create the folder if does not exist in the directory with the imported data. @@ -236,7 +236,7 @@ yarn start --no-base-path `baseUrl`, as configured in `plugins/siem/cypress.json`: ```sh -cd x-pack/legacy/plugins/siem +cd x-pack/plugins/siem yarn cypress:open ``` @@ -245,7 +245,7 @@ yarn cypress:open test runner, as shown in the following example: ```sh -cd x-pack/legacy/plugins/siem +cd x-pack/plugins/siem CYPRESS_baseUrl=http://localhost:5601 yarn cypress:open ``` @@ -253,7 +253,7 @@ CYPRESS_baseUrl=http://localhost:5601 yarn cypress:open running tests interactively: ```sh -cd x-pack/legacy/plugins/siem +cd x-pack/plugins/siem CYPRESS_baseUrl=http://localhost:5601 CYPRESS_ELASTICSEARCH_USERNAME=elastic CYPRESS_ELASTICSEARCH_PASSWORD= yarn cypress:open ``` @@ -285,7 +285,7 @@ yarn start --no-base-path `baseUrl`, as configured in `plugins/siem/cypress.json`: ```sh -cd x-pack/legacy/plugins/siem +cd x-pack/plugins/siem yarn cypress:run ``` @@ -294,7 +294,7 @@ yarn cypress:run the following example: ```sh -cd x-pack/legacy/plugins/siem +cd x-pack/plugins/siem CYPRESS_baseUrl=http://localhost:5601 yarn cypress:run ``` @@ -302,7 +302,7 @@ CYPRESS_baseUrl=http://localhost:5601 yarn cypress:run running via the command line: ```sh -cd x-pack/legacy/plugins/siem +cd x-pack/plugins/siem CYPRESS_baseUrl=http://localhost:5601 CYPRESS_ELASTICSEARCH_USERNAME=elastic CYPRESS_ELASTICSEARCH_PASSWORD= yarn cypress:run ``` diff --git a/x-pack/plugins/siem/cypress/cypress.json b/x-pack/plugins/siem/cypress/cypress.json new file mode 100644 index 0000000000000..7a4efba8c2d64 --- /dev/null +++ b/x-pack/plugins/siem/cypress/cypress.json @@ -0,0 +1,8 @@ +{ + "baseUrl": "http://localhost:5601", + "defaultCommandTimeout": 120000, + "screenshotsFolder": "../../../target/kibana-siem/cypress/screenshots", + "trashAssetsBeforeRuns": false, + "video": false, + "videosFolder": "../../../target/kibana-siem/cypress/videos" +} diff --git a/x-pack/legacy/plugins/siem/cypress/fixtures/overview.json b/x-pack/plugins/siem/cypress/fixtures/overview.json similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/fixtures/overview.json rename to x-pack/plugins/siem/cypress/fixtures/overview.json diff --git a/x-pack/legacy/plugins/siem/cypress/integration/detections.spec.ts b/x-pack/plugins/siem/cypress/integration/detections.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/detections.spec.ts rename to x-pack/plugins/siem/cypress/integration/detections.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/detections_timeline.spec.ts b/x-pack/plugins/siem/cypress/integration/detections_timeline.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/detections_timeline.spec.ts rename to x-pack/plugins/siem/cypress/integration/detections_timeline.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/events_viewer.spec.ts b/x-pack/plugins/siem/cypress/integration/events_viewer.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/events_viewer.spec.ts rename to x-pack/plugins/siem/cypress/integration/events_viewer.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/fields_browser.spec.ts b/x-pack/plugins/siem/cypress/integration/fields_browser.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/fields_browser.spec.ts rename to x-pack/plugins/siem/cypress/integration/fields_browser.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/inspect.spec.ts b/x-pack/plugins/siem/cypress/integration/inspect.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/inspect.spec.ts rename to x-pack/plugins/siem/cypress/integration/inspect.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/ml_conditional_links.spec.ts b/x-pack/plugins/siem/cypress/integration/ml_conditional_links.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/ml_conditional_links.spec.ts rename to x-pack/plugins/siem/cypress/integration/ml_conditional_links.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/navigation.spec.ts b/x-pack/plugins/siem/cypress/integration/navigation.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/navigation.spec.ts rename to x-pack/plugins/siem/cypress/integration/navigation.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/overview.spec.ts b/x-pack/plugins/siem/cypress/integration/overview.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/overview.spec.ts rename to x-pack/plugins/siem/cypress/integration/overview.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/pagination.spec.ts b/x-pack/plugins/siem/cypress/integration/pagination.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/pagination.spec.ts rename to x-pack/plugins/siem/cypress/integration/pagination.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules.spec.ts b/x-pack/plugins/siem/cypress/integration/signal_detection_rules.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules.spec.ts rename to x-pack/plugins/siem/cypress/integration/signal_detection_rules.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts b/x-pack/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts rename to x-pack/plugins/siem/cypress/integration/signal_detection_rules_custom.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts b/x-pack/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts rename to x-pack/plugins/siem/cypress/integration/signal_detection_rules_ml.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts b/x-pack/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts rename to x-pack/plugins/siem/cypress/integration/signal_detection_rules_prebuilt.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/timeline_data_providers.spec.ts b/x-pack/plugins/siem/cypress/integration/timeline_data_providers.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/timeline_data_providers.spec.ts rename to x-pack/plugins/siem/cypress/integration/timeline_data_providers.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/timeline_flyout_button.spec.ts b/x-pack/plugins/siem/cypress/integration/timeline_flyout_button.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/timeline_flyout_button.spec.ts rename to x-pack/plugins/siem/cypress/integration/timeline_flyout_button.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/timeline_search_or_filter.spec.ts b/x-pack/plugins/siem/cypress/integration/timeline_search_or_filter.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/timeline_search_or_filter.spec.ts rename to x-pack/plugins/siem/cypress/integration/timeline_search_or_filter.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/timeline_toggle_column.spec.ts b/x-pack/plugins/siem/cypress/integration/timeline_toggle_column.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/timeline_toggle_column.spec.ts rename to x-pack/plugins/siem/cypress/integration/timeline_toggle_column.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/integration/url_state.spec.ts b/x-pack/plugins/siem/cypress/integration/url_state.spec.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/integration/url_state.spec.ts rename to x-pack/plugins/siem/cypress/integration/url_state.spec.ts diff --git a/x-pack/legacy/plugins/siem/cypress/objects/rule.ts b/x-pack/plugins/siem/cypress/objects/rule.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/objects/rule.ts rename to x-pack/plugins/siem/cypress/objects/rule.ts diff --git a/x-pack/legacy/plugins/siem/cypress/objects/timeline.ts b/x-pack/plugins/siem/cypress/objects/timeline.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/objects/timeline.ts rename to x-pack/plugins/siem/cypress/objects/timeline.ts diff --git a/x-pack/legacy/plugins/siem/cypress/plugins/index.js b/x-pack/plugins/siem/cypress/plugins/index.js similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/plugins/index.js rename to x-pack/plugins/siem/cypress/plugins/index.js diff --git a/x-pack/plugins/siem/cypress/reporter_config.json b/x-pack/plugins/siem/cypress/reporter_config.json new file mode 100644 index 0000000000000..e7e08eeae1dab --- /dev/null +++ b/x-pack/plugins/siem/cypress/reporter_config.json @@ -0,0 +1,10 @@ +{ + "reporterEnabled": "mochawesome, mocha-junit-reporter", + "reporterOptions": { + "html": false, + "json": true, + "mochaFile": "../../../target/kibana-siem/cypress/results/TEST-siem-cypress-[hash].xml", + "overwrite": false, + "reportDir": "../../../target/kibana-siem/cypress/results" + } +} diff --git a/x-pack/legacy/plugins/siem/cypress/screens/create_new_rule.ts b/x-pack/plugins/siem/cypress/screens/create_new_rule.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/create_new_rule.ts rename to x-pack/plugins/siem/cypress/screens/create_new_rule.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/date_picker.ts b/x-pack/plugins/siem/cypress/screens/date_picker.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/date_picker.ts rename to x-pack/plugins/siem/cypress/screens/date_picker.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/detections.ts b/x-pack/plugins/siem/cypress/screens/detections.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/detections.ts rename to x-pack/plugins/siem/cypress/screens/detections.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/fields_browser.ts b/x-pack/plugins/siem/cypress/screens/fields_browser.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/fields_browser.ts rename to x-pack/plugins/siem/cypress/screens/fields_browser.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/all_hosts.ts b/x-pack/plugins/siem/cypress/screens/hosts/all_hosts.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/hosts/all_hosts.ts rename to x-pack/plugins/siem/cypress/screens/hosts/all_hosts.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/authentications.ts b/x-pack/plugins/siem/cypress/screens/hosts/authentications.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/hosts/authentications.ts rename to x-pack/plugins/siem/cypress/screens/hosts/authentications.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/events.ts b/x-pack/plugins/siem/cypress/screens/hosts/events.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/hosts/events.ts rename to x-pack/plugins/siem/cypress/screens/hosts/events.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/main.ts b/x-pack/plugins/siem/cypress/screens/hosts/main.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/hosts/main.ts rename to x-pack/plugins/siem/cypress/screens/hosts/main.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/hosts/uncommon_processes.ts b/x-pack/plugins/siem/cypress/screens/hosts/uncommon_processes.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/hosts/uncommon_processes.ts rename to x-pack/plugins/siem/cypress/screens/hosts/uncommon_processes.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/inspect.ts b/x-pack/plugins/siem/cypress/screens/inspect.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/inspect.ts rename to x-pack/plugins/siem/cypress/screens/inspect.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/network/flows.ts b/x-pack/plugins/siem/cypress/screens/network/flows.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/network/flows.ts rename to x-pack/plugins/siem/cypress/screens/network/flows.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/overview.ts b/x-pack/plugins/siem/cypress/screens/overview.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/overview.ts rename to x-pack/plugins/siem/cypress/screens/overview.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/pagination.ts b/x-pack/plugins/siem/cypress/screens/pagination.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/pagination.ts rename to x-pack/plugins/siem/cypress/screens/pagination.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/rule_details.ts b/x-pack/plugins/siem/cypress/screens/rule_details.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/rule_details.ts rename to x-pack/plugins/siem/cypress/screens/rule_details.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/siem_header.ts b/x-pack/plugins/siem/cypress/screens/siem_header.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/siem_header.ts rename to x-pack/plugins/siem/cypress/screens/siem_header.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/siem_main.ts b/x-pack/plugins/siem/cypress/screens/siem_main.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/siem_main.ts rename to x-pack/plugins/siem/cypress/screens/siem_main.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/signal_detection_rules.ts b/x-pack/plugins/siem/cypress/screens/signal_detection_rules.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/signal_detection_rules.ts rename to x-pack/plugins/siem/cypress/screens/signal_detection_rules.ts diff --git a/x-pack/legacy/plugins/siem/cypress/screens/timeline.ts b/x-pack/plugins/siem/cypress/screens/timeline.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/screens/timeline.ts rename to x-pack/plugins/siem/cypress/screens/timeline.ts diff --git a/x-pack/legacy/plugins/siem/cypress/support/commands.js b/x-pack/plugins/siem/cypress/support/commands.js similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/support/commands.js rename to x-pack/plugins/siem/cypress/support/commands.js diff --git a/x-pack/legacy/plugins/siem/cypress/support/index.d.ts b/x-pack/plugins/siem/cypress/support/index.d.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/support/index.d.ts rename to x-pack/plugins/siem/cypress/support/index.d.ts diff --git a/x-pack/legacy/plugins/siem/cypress/support/index.js b/x-pack/plugins/siem/cypress/support/index.js similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/support/index.js rename to x-pack/plugins/siem/cypress/support/index.js diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/common.ts b/x-pack/plugins/siem/cypress/tasks/common.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/common.ts rename to x-pack/plugins/siem/cypress/tasks/common.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/create_new_rule.ts b/x-pack/plugins/siem/cypress/tasks/create_new_rule.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/create_new_rule.ts rename to x-pack/plugins/siem/cypress/tasks/create_new_rule.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/date_picker.ts b/x-pack/plugins/siem/cypress/tasks/date_picker.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/date_picker.ts rename to x-pack/plugins/siem/cypress/tasks/date_picker.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/detections.ts b/x-pack/plugins/siem/cypress/tasks/detections.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/detections.ts rename to x-pack/plugins/siem/cypress/tasks/detections.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/es_archiver.ts b/x-pack/plugins/siem/cypress/tasks/es_archiver.ts similarity index 53% rename from x-pack/legacy/plugins/siem/cypress/tasks/es_archiver.ts rename to x-pack/plugins/siem/cypress/tasks/es_archiver.ts index 6417a7d872251..8a4ab8c819457 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/es_archiver.ts +++ b/x-pack/plugins/siem/cypress/tasks/es_archiver.ts @@ -6,7 +6,7 @@ export const esArchiverLoadEmptyKibana = () => { cy.exec( - `node ../../../../scripts/es_archiver empty_kibana load empty--dir ../../../test/siem_cypress/es_archives --config ../../../../test/functional/config.js --es-url ${Cypress.env( + `node ../../../scripts/es_archiver empty_kibana load empty--dir ../../test/siem_cypress/es_archives --config ../../../test/functional/config.js --es-url ${Cypress.env( 'ELASTICSEARCH_URL' )} --kibana-url ${Cypress.config().baseUrl}` ); @@ -14,7 +14,7 @@ export const esArchiverLoadEmptyKibana = () => { export const esArchiverLoad = (folder: string) => { cy.exec( - `node ../../../../scripts/es_archiver load ${folder} --dir ../../../test/siem_cypress/es_archives --config ../../../../test/functional/config.js --es-url ${Cypress.env( + `node ../../../scripts/es_archiver load ${folder} --dir ../../test/siem_cypress/es_archives --config ../../../test/functional/config.js --es-url ${Cypress.env( 'ELASTICSEARCH_URL' )} --kibana-url ${Cypress.config().baseUrl}` ); @@ -22,7 +22,7 @@ export const esArchiverLoad = (folder: string) => { export const esArchiverUnload = (folder: string) => { cy.exec( - `node ../../../../scripts/es_archiver unload ${folder} --dir ../../../test/siem_cypress/es_archives --config ../../../../test/functional/config.js --es-url ${Cypress.env( + `node ../../../scripts/es_archiver unload ${folder} --dir ../../test/siem_cypress/es_archives --config ../../../test/functional/config.js --es-url ${Cypress.env( 'ELASTICSEARCH_URL' )} --kibana-url ${Cypress.config().baseUrl}` ); @@ -30,7 +30,7 @@ export const esArchiverUnload = (folder: string) => { export const esArchiverUnloadEmptyKibana = () => { cy.exec( - `node ../../../../scripts/es_archiver unload empty_kibana empty--dir ../../../test/siem_cypress/es_archives --config ../../../../test/functional/config.js --es-url ${Cypress.env( + `node ../../../scripts/es_archiver unload empty_kibana empty--dir ../../test/siem_cypress/es_archives --config ../../../test/functional/config.js --es-url ${Cypress.env( 'ELASTICSEARCH_URL' )} --kibana-url ${Cypress.config().baseUrl}` ); @@ -38,7 +38,7 @@ export const esArchiverUnloadEmptyKibana = () => { export const esArchiverResetKibana = () => { cy.exec( - `node ../../../../scripts/es_archiver empty-kibana-index --config ../../../../test/functional/config.js --es-url ${Cypress.env( + `node ../../../scripts/es_archiver empty-kibana-index --config ../../../test/functional/config.js --es-url ${Cypress.env( 'ELASTICSEARCH_URL' )} --kibana-url ${Cypress.config().baseUrl}` ); diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/fields_browser.ts b/x-pack/plugins/siem/cypress/tasks/fields_browser.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/fields_browser.ts rename to x-pack/plugins/siem/cypress/tasks/fields_browser.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/all_hosts.ts b/x-pack/plugins/siem/cypress/tasks/hosts/all_hosts.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/hosts/all_hosts.ts rename to x-pack/plugins/siem/cypress/tasks/hosts/all_hosts.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/authentications.ts b/x-pack/plugins/siem/cypress/tasks/hosts/authentications.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/hosts/authentications.ts rename to x-pack/plugins/siem/cypress/tasks/hosts/authentications.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/events.ts b/x-pack/plugins/siem/cypress/tasks/hosts/events.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/hosts/events.ts rename to x-pack/plugins/siem/cypress/tasks/hosts/events.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/main.ts b/x-pack/plugins/siem/cypress/tasks/hosts/main.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/hosts/main.ts rename to x-pack/plugins/siem/cypress/tasks/hosts/main.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/hosts/uncommon_processes.ts b/x-pack/plugins/siem/cypress/tasks/hosts/uncommon_processes.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/hosts/uncommon_processes.ts rename to x-pack/plugins/siem/cypress/tasks/hosts/uncommon_processes.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/inspect.ts b/x-pack/plugins/siem/cypress/tasks/inspect.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/inspect.ts rename to x-pack/plugins/siem/cypress/tasks/inspect.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/login.ts b/x-pack/plugins/siem/cypress/tasks/login.ts similarity index 98% rename from x-pack/legacy/plugins/siem/cypress/tasks/login.ts rename to x-pack/plugins/siem/cypress/tasks/login.ts index c7788b080d06e..1bbf41d05db00 100644 --- a/x-pack/legacy/plugins/siem/cypress/tasks/login.ts +++ b/x-pack/plugins/siem/cypress/tasks/login.ts @@ -10,7 +10,7 @@ import * as yaml from 'js-yaml'; * Credentials in the `kibana.dev.yml` config file will be used to authenticate * with Kibana when credentials are not provided via environment variables */ -const KIBANA_DEV_YML_PATH = '../../../../config/kibana.dev.yml'; +const KIBANA_DEV_YML_PATH = '../../../config/kibana.dev.yml'; /** * The configuration path in `kibana.dev.yml` to the username to be used when diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/network/flows.ts b/x-pack/plugins/siem/cypress/tasks/network/flows.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/network/flows.ts rename to x-pack/plugins/siem/cypress/tasks/network/flows.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/overview.ts b/x-pack/plugins/siem/cypress/tasks/overview.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/overview.ts rename to x-pack/plugins/siem/cypress/tasks/overview.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/pagination.ts b/x-pack/plugins/siem/cypress/tasks/pagination.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/pagination.ts rename to x-pack/plugins/siem/cypress/tasks/pagination.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/siem_header.ts b/x-pack/plugins/siem/cypress/tasks/siem_header.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/siem_header.ts rename to x-pack/plugins/siem/cypress/tasks/siem_header.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/siem_main.ts b/x-pack/plugins/siem/cypress/tasks/siem_main.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/siem_main.ts rename to x-pack/plugins/siem/cypress/tasks/siem_main.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/signal_detection_rules.ts b/x-pack/plugins/siem/cypress/tasks/signal_detection_rules.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/signal_detection_rules.ts rename to x-pack/plugins/siem/cypress/tasks/signal_detection_rules.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tasks/timeline.ts b/x-pack/plugins/siem/cypress/tasks/timeline.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tasks/timeline.ts rename to x-pack/plugins/siem/cypress/tasks/timeline.ts diff --git a/x-pack/legacy/plugins/siem/cypress/tsconfig.json b/x-pack/plugins/siem/cypress/tsconfig.json similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/tsconfig.json rename to x-pack/plugins/siem/cypress/tsconfig.json diff --git a/x-pack/legacy/plugins/siem/cypress/urls/ml_conditional_links.ts b/x-pack/plugins/siem/cypress/urls/ml_conditional_links.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/urls/ml_conditional_links.ts rename to x-pack/plugins/siem/cypress/urls/ml_conditional_links.ts diff --git a/x-pack/legacy/plugins/siem/cypress/urls/navigation.ts b/x-pack/plugins/siem/cypress/urls/navigation.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/urls/navigation.ts rename to x-pack/plugins/siem/cypress/urls/navigation.ts diff --git a/x-pack/legacy/plugins/siem/cypress/urls/state.ts b/x-pack/plugins/siem/cypress/urls/state.ts similarity index 100% rename from x-pack/legacy/plugins/siem/cypress/urls/state.ts rename to x-pack/plugins/siem/cypress/urls/state.ts diff --git a/x-pack/plugins/siem/kibana.json b/x-pack/plugins/siem/kibana.json index 2bc33b87a1b43..1eb1a7dbde876 100644 --- a/x-pack/plugins/siem/kibana.json +++ b/x-pack/plugins/siem/kibana.json @@ -3,6 +3,8 @@ "version": "8.0.0", "kibanaVersion": "kibana", "configPath": ["xpack", "siem"], + "requiredPlugins": ["actions", "alerting", "features", "licensing"], + "optionalPlugins": ["encryptedSavedObjects", "ml", "security", "spaces"], "server": true, "ui": false } diff --git a/x-pack/plugins/siem/package.json b/x-pack/plugins/siem/package.json new file mode 100644 index 0000000000000..1fcef46243628 --- /dev/null +++ b/x-pack/plugins/siem/package.json @@ -0,0 +1,20 @@ +{ + "author": "Elastic", + "name": "siem", + "version": "8.0.0", + "private": true, + "license": "Elastic-License", + "scripts": { + "extract-mitre-attacks": "node scripts/extract_tactics_techniques_mitre.js & node ../../../scripts/eslint ../../legacy/plugins/siem/public/pages/detection_engine/mitre/mitre_tactics_techniques.ts --fix", + "build-graphql-types": "node scripts/generate_types_from_graphql.js", + "cypress:open": "cypress open --config-file ./cypress/cypress.json", + "cypress:run": "cypress run --spec ./cypress/integration/**/*.spec.ts --config-file ./cypress/cypress.json --reporter ../../node_modules/cypress-multi-reporters --reporter-options configFile=./cypress/reporter_config.json; status=$?; ../../node_modules/.bin/mochawesome-merge --reportDir ../../../target/kibana-siem/cypress/results > ../../../target/kibana-siem/cypress/results/output.json; ../../../node_modules/.bin/marge ../../../target/kibana-siem/cypress/results/output.json --reportDir ../../../target/kibana-siem/cypress/results; mkdir -p ../../../target/junit && cp ../../../target/kibana-siem/cypress/results/*.xml ../../../target/junit/ && exit $status;", + "cypress:run-as-ci": "node ../../../scripts/functional_tests --config ../../test/siem_cypress/config.ts" + }, + "devDependencies": { + "@types/lodash": "^4.14.110" + }, + "dependencies": { + "lodash": "^4.17.15" + } +} diff --git a/x-pack/plugins/siem/scripts/check_circular_deps.js b/x-pack/plugins/siem/scripts/check_circular_deps.js new file mode 100644 index 0000000000000..4ba7020d13465 --- /dev/null +++ b/x-pack/plugins/siem/scripts/check_circular_deps.js @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +require('../../../../src/setup_node_env'); +require('./check_circular_deps/run_check_circular_deps_cli'); diff --git a/x-pack/legacy/plugins/siem/dev_tools/circular_deps/run_check_circular_deps_cli.js b/x-pack/plugins/siem/scripts/check_circular_deps/run_check_circular_deps_cli.js similarity index 88% rename from x-pack/legacy/plugins/siem/dev_tools/circular_deps/run_check_circular_deps_cli.js rename to x-pack/plugins/siem/scripts/check_circular_deps/run_check_circular_deps_cli.js index f3a97f5b9c9b6..0b5e5d6cf13b5 100644 --- a/x-pack/legacy/plugins/siem/dev_tools/circular_deps/run_check_circular_deps_cli.js +++ b/x-pack/plugins/siem/scripts/check_circular_deps/run_check_circular_deps_cli.js @@ -11,10 +11,13 @@ import madge from 'madge'; /* eslint-disable-next-line import/no-extraneous-dependencies */ import { run, createFailError } from '@kbn/dev-utils'; +const legacyPluginPath = '../../../../legacy/plugins/siem'; +const pluginPath = '../..'; + run( async ({ log }) => { const result = await madge( - [resolve(__dirname, '../../public'), resolve(__dirname, '../../common')], + [resolve(__dirname, legacyPluginPath, 'public'), resolve(__dirname, pluginPath, 'common')], { fileExtensions: ['ts', 'js', 'tsx'], excludeRegExp: [ diff --git a/x-pack/legacy/plugins/siem/scripts/combined_schema.ts b/x-pack/plugins/siem/scripts/combined_schema.ts similarity index 91% rename from x-pack/legacy/plugins/siem/scripts/combined_schema.ts rename to x-pack/plugins/siem/scripts/combined_schema.ts index 625eb3a4a4755..48215548650fe 100644 --- a/x-pack/legacy/plugins/siem/scripts/combined_schema.ts +++ b/x-pack/plugins/siem/scripts/combined_schema.ts @@ -6,6 +6,7 @@ import { buildSchemaFromTypeDefinitions } from 'graphql-tools'; +// eslint-disable-next-line @kbn/eslint/no-restricted-paths import { schemas as serverSchemas } from '../server/graphql'; export const schemas = [...serverSchemas]; diff --git a/x-pack/legacy/plugins/siem/scripts/convert_saved_search_to_rules.js b/x-pack/plugins/siem/scripts/convert_saved_search_to_rules.js similarity index 99% rename from x-pack/legacy/plugins/siem/scripts/convert_saved_search_to_rules.js rename to x-pack/plugins/siem/scripts/convert_saved_search_to_rules.js index 233d4dd7de721..65da56dd09bca 100644 --- a/x-pack/legacy/plugins/siem/scripts/convert_saved_search_to_rules.js +++ b/x-pack/plugins/siem/scripts/convert_saved_search_to_rules.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -require('../../../../../src/setup_node_env'); +require('../../../../src/setup_node_env'); const fs = require('fs'); const path = require('path'); diff --git a/x-pack/legacy/plugins/siem/scripts/extract_tactics_techniques_mitre.js b/x-pack/plugins/siem/scripts/extract_tactics_techniques_mitre.js similarity index 95% rename from x-pack/legacy/plugins/siem/scripts/extract_tactics_techniques_mitre.js rename to x-pack/plugins/siem/scripts/extract_tactics_techniques_mitre.js index 6cb2a40049631..478463b1a8064 100644 --- a/x-pack/legacy/plugins/siem/scripts/extract_tactics_techniques_mitre.js +++ b/x-pack/plugins/siem/scripts/extract_tactics_techniques_mitre.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -require('../../../../../src/setup_node_env'); +require('../../../../src/setup_node_env'); const fs = require('fs'); // eslint-disable-next-line import/no-extraneous-dependencies @@ -12,7 +12,13 @@ const fetch = require('node-fetch'); const { camelCase } = require('lodash'); const { resolve } = require('path'); -const OUTPUT_DIRECTORY = resolve('public', 'pages', 'detection_engine', 'mitre'); +const OUTPUT_DIRECTORY = resolve( + '../../legacy/plugins/siem', + 'public', + 'pages', + 'detection_engine', + 'mitre' +); const MITRE_ENTREPRISE_ATTACK_URL = 'https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json'; diff --git a/x-pack/legacy/plugins/siem/scripts/generate_types_from_graphql.js b/x-pack/plugins/siem/scripts/generate_types_from_graphql.js similarity index 91% rename from x-pack/legacy/plugins/siem/scripts/generate_types_from_graphql.js rename to x-pack/plugins/siem/scripts/generate_types_from_graphql.js index 36674fec73e09..bded8832aba5a 100644 --- a/x-pack/legacy/plugins/siem/scripts/generate_types_from_graphql.js +++ b/x-pack/plugins/siem/scripts/generate_types_from_graphql.js @@ -4,18 +4,25 @@ * you may not use this file except in compliance with the Elastic License. */ -require('../../../../../src/setup_node_env'); +require('../../../../src/setup_node_env'); const { join, resolve } = require('path'); // eslint-disable-next-line import/no-extraneous-dependencies, import/no-unresolved const { generate } = require('graphql-code-generator'); +const legacyPluginPath = '../../legacy/plugins/siem'; + const GRAPHQL_GLOBS = [ - join('public', 'containers', '**', '*.gql_query.ts{,x}'), + join(legacyPluginPath, 'public', 'containers', '**', '*.gql_query.ts{,x}'), join('common', 'graphql', '**', '*.gql_query.ts{,x}'), ]; -const OUTPUT_INTROSPECTION_PATH = resolve('public', 'graphql', 'introspection.json'); -const OUTPUT_CLIENT_TYPES_PATH = resolve('public', 'graphql', 'types.ts'); +const OUTPUT_INTROSPECTION_PATH = resolve( + legacyPluginPath, + 'public', + 'graphql', + 'introspection.json' +); +const OUTPUT_CLIENT_TYPES_PATH = resolve(legacyPluginPath, 'public', 'graphql', 'types.ts'); const OUTPUT_SERVER_TYPES_PATH = resolve('server', 'graphql', 'types.ts'); const SCHEMA_PATH = resolve(__dirname, 'combined_schema.ts'); diff --git a/x-pack/legacy/plugins/siem/scripts/loop_cypress_tests.js b/x-pack/plugins/siem/scripts/loop_cypress_tests.js similarity index 100% rename from x-pack/legacy/plugins/siem/scripts/loop_cypress_tests.js rename to x-pack/plugins/siem/scripts/loop_cypress_tests.js diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig.js b/x-pack/plugins/siem/scripts/optimize_tsconfig.js similarity index 100% rename from x-pack/legacy/plugins/siem/scripts/optimize_tsconfig.js rename to x-pack/plugins/siem/scripts/optimize_tsconfig.js diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/README.md b/x-pack/plugins/siem/scripts/optimize_tsconfig/README.md similarity index 86% rename from x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/README.md rename to x-pack/plugins/siem/scripts/optimize_tsconfig/README.md index d3615d2870ef9..2b402367c1db3 100644 --- a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/README.md +++ b/x-pack/plugins/siem/scripts/optimize_tsconfig/README.md @@ -8,9 +8,9 @@ Kibana and X-Pack are very large TypeScript projects, and it comes at a cost. Ed To run the optimization: -`$ node x-pack/legacy/plugins/siem/scripts/optimize_tsconfig` +`$ node x-pack/plugins/siem/scripts/optimize_tsconfig` To undo the optimization: -`$ node x-pack/legacy/plugins/siem/scripts/unoptimize_tsconfig` +`$ node x-pack/plugins/siem/scripts/unoptimize_tsconfig` diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/optimize.js b/x-pack/plugins/siem/scripts/optimize_tsconfig/optimize.js similarity index 100% rename from x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/optimize.js rename to x-pack/plugins/siem/scripts/optimize_tsconfig/optimize.js diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/paths.js b/x-pack/plugins/siem/scripts/optimize_tsconfig/paths.js similarity index 90% rename from x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/paths.js rename to x-pack/plugins/siem/scripts/optimize_tsconfig/paths.js index ca26203e17d2e..c75e16f74b932 100644 --- a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/paths.js +++ b/x-pack/plugins/siem/scripts/optimize_tsconfig/paths.js @@ -5,7 +5,7 @@ */ const path = require('path'); -const xpackRoot = path.resolve(__dirname, '../../../../..'); +const xpackRoot = path.resolve(__dirname, '../../../..'); const kibanaRoot = path.resolve(xpackRoot, '..'); const tsconfigTpl = path.resolve(__dirname, './tsconfig.json'); diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/tsconfig.json b/x-pack/plugins/siem/scripts/optimize_tsconfig/tsconfig.json similarity index 88% rename from x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/tsconfig.json rename to x-pack/plugins/siem/scripts/optimize_tsconfig/tsconfig.json index c4705c8b8c16a..42d26c4c27ed6 100644 --- a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/tsconfig.json +++ b/x-pack/plugins/siem/scripts/optimize_tsconfig/tsconfig.json @@ -10,7 +10,7 @@ "exclude": [ "test/**/*", "**/__fixtures__/**/*", - "legacy/plugins/siem/cypress/**/*", + "plugins/siem/cypress/**/*", "**/typespec_tests.ts" ] } diff --git a/x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/unoptimize.js b/x-pack/plugins/siem/scripts/optimize_tsconfig/unoptimize.js similarity index 100% rename from x-pack/legacy/plugins/siem/scripts/optimize_tsconfig/unoptimize.js rename to x-pack/plugins/siem/scripts/optimize_tsconfig/unoptimize.js diff --git a/x-pack/legacy/plugins/siem/scripts/storybook.js b/x-pack/plugins/siem/scripts/storybook.js similarity index 100% rename from x-pack/legacy/plugins/siem/scripts/storybook.js rename to x-pack/plugins/siem/scripts/storybook.js diff --git a/x-pack/legacy/plugins/siem/scripts/unoptimize_tsconfig.js b/x-pack/plugins/siem/scripts/unoptimize_tsconfig.js similarity index 100% rename from x-pack/legacy/plugins/siem/scripts/unoptimize_tsconfig.js rename to x-pack/plugins/siem/scripts/unoptimize_tsconfig.js diff --git a/x-pack/legacy/plugins/siem/server/client/client.test.ts b/x-pack/plugins/siem/server/client/client.test.ts similarity index 79% rename from x-pack/legacy/plugins/siem/server/client/client.test.ts rename to x-pack/plugins/siem/server/client/client.test.ts index bfe7b97f43003..94ff2149b8c64 100644 --- a/x-pack/legacy/plugins/siem/server/client/client.test.ts +++ b/x-pack/plugins/siem/server/client/client.test.ts @@ -4,17 +4,17 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SiemClient } from './client'; +import { SIGNALS_INDEX_KEY } from '../../common/constants'; import { createMockConfig } from '../lib/detection_engine/routes/__mocks__'; +import { SiemClient } from './client'; describe('SiemClient', () => { describe('#signalsIndex', () => { it('returns the index scoped to the specified spaceId', () => { - let mockConfig = createMockConfig(); - mockConfig = () => ({ - get: jest.fn(() => 'mockSignalsIndex'), - has: jest.fn(), - }); + const mockConfig = { + ...createMockConfig(), + [SIGNALS_INDEX_KEY]: 'mockSignalsIndex', + }; const spaceId = 'fooSpace'; const client = new SiemClient(spaceId, mockConfig); diff --git a/x-pack/legacy/plugins/siem/server/client/client.ts b/x-pack/plugins/siem/server/client/client.ts similarity index 56% rename from x-pack/legacy/plugins/siem/server/client/client.ts rename to x-pack/plugins/siem/server/client/client.ts index 245b81d0be97a..6cb0d4cfade77 100644 --- a/x-pack/legacy/plugins/siem/server/client/client.ts +++ b/x-pack/plugins/siem/server/client/client.ts @@ -4,17 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Legacy } from 'kibana'; - -import { APP_ID, SIGNALS_INDEX_KEY } from '../../common/constants'; +import { ConfigType } from '..'; export class SiemClient { public readonly signalsIndex: string; - constructor(private spaceId: string, private config: Legacy.Server['config']) { - const configuredSignalsIndex = this.config().get( - `xpack.${APP_ID}.${SIGNALS_INDEX_KEY}` - ); + constructor(private spaceId: string, private config: ConfigType) { + const configuredSignalsIndex = this.config.signalsIndex; this.signalsIndex = `${configuredSignalsIndex}-${this.spaceId}`; } diff --git a/x-pack/legacy/plugins/siem/server/client/factory.test.ts b/x-pack/plugins/siem/server/client/factory.test.ts similarity index 82% rename from x-pack/legacy/plugins/siem/server/client/factory.test.ts rename to x-pack/plugins/siem/server/client/factory.test.ts index c166b6b838be2..f0cddc5f09747 100644 --- a/x-pack/legacy/plugins/siem/server/client/factory.test.ts +++ b/x-pack/plugins/siem/server/client/factory.test.ts @@ -4,7 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { httpServerMock } from '../../../../../../src/core/server/mocks'; +import { httpServerMock } from '../../../../../src/core/server/mocks'; +import { createMockConfig } from '../lib/detection_engine/routes/__mocks__'; import { SiemClientFactory } from './factory'; import { SiemClient } from './client'; @@ -16,7 +17,7 @@ describe('SiemClientFactory', () => { it('constructs a client with the current spaceId', () => { const factory = new SiemClientFactory(); const mockRequest = httpServerMock.createKibanaRequest(); - factory.setup({ getSpaceId: () => 'mockSpace', config: jest.fn() }); + factory.setup({ getSpaceId: () => 'mockSpace', config: createMockConfig() }); factory.create(mockRequest); expect(mockClient).toHaveBeenCalledWith('mockSpace', expect.anything()); @@ -25,7 +26,7 @@ describe('SiemClientFactory', () => { it('constructs a client with the default spaceId if spaces are disabled', () => { const factory = new SiemClientFactory(); const mockRequest = httpServerMock.createKibanaRequest(); - factory.setup({ getSpaceId: undefined, config: jest.fn() }); + factory.setup({ getSpaceId: undefined, config: createMockConfig() }); factory.create(mockRequest); expect(mockClient).toHaveBeenCalledWith('default', expect.anything()); diff --git a/x-pack/legacy/plugins/siem/server/client/factory.ts b/x-pack/plugins/siem/server/client/factory.ts similarity index 87% rename from x-pack/legacy/plugins/siem/server/client/factory.ts rename to x-pack/plugins/siem/server/client/factory.ts index d31920bdf2c77..d3d6b84e5b090 100644 --- a/x-pack/legacy/plugins/siem/server/client/factory.ts +++ b/x-pack/plugins/siem/server/client/factory.ts @@ -4,14 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Legacy } from 'kibana'; - -import { KibanaRequest } from '../../../../../../src/core/server'; +import { KibanaRequest } from '../../../../../src/core/server'; import { SiemClient } from './client'; +import { ConfigType } from '..'; interface SetupDependencies { getSpaceId?: (request: KibanaRequest) => string | undefined; - config: Legacy.Server['config']; + config: ConfigType; } export class SiemClientFactory { diff --git a/x-pack/legacy/plugins/siem/server/client/index.ts b/x-pack/plugins/siem/server/client/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/client/index.ts rename to x-pack/plugins/siem/server/client/index.ts diff --git a/x-pack/plugins/siem/server/config.ts b/x-pack/plugins/siem/server/config.ts index 224043c0c6fe5..4b0e8d34ef1a0 100644 --- a/x-pack/plugins/siem/server/config.ts +++ b/x-pack/plugins/siem/server/config.ts @@ -7,13 +7,14 @@ import { Observable } from 'rxjs'; import { schema, TypeOf } from '@kbn/config-schema'; import { PluginInitializerContext } from '../../../../src/core/server'; -import { - SIGNALS_INDEX_KEY, - DEFAULT_SIGNALS_INDEX, -} from '../../../legacy/plugins/siem/common/constants'; +import { SIGNALS_INDEX_KEY, DEFAULT_SIGNALS_INDEX } from '../common/constants'; export const configSchema = schema.object({ enabled: schema.boolean({ defaultValue: true }), + maxRuleImportExportSize: schema.number({ defaultValue: 10000 }), + maxRuleImportPayloadBytes: schema.number({ defaultValue: 10485760 }), + maxTimelineImportExportSize: schema.number({ defaultValue: 10000 }), + maxTimelineImportPayloadBytes: schema.number({ defaultValue: 10485760 }), [SIGNALS_INDEX_KEY]: schema.string({ defaultValue: DEFAULT_SIGNALS_INDEX }), }); diff --git a/x-pack/legacy/plugins/siem/server/graphql/authentications/index.ts b/x-pack/plugins/siem/server/graphql/authentications/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/authentications/index.ts rename to x-pack/plugins/siem/server/graphql/authentications/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/authentications/resolvers.ts b/x-pack/plugins/siem/server/graphql/authentications/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/authentications/resolvers.ts rename to x-pack/plugins/siem/server/graphql/authentications/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/authentications/schema.gql.ts b/x-pack/plugins/siem/server/graphql/authentications/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/authentications/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/authentications/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/ecs/index.ts b/x-pack/plugins/siem/server/graphql/ecs/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/ecs/index.ts rename to x-pack/plugins/siem/server/graphql/ecs/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/ecs/resolvers.ts b/x-pack/plugins/siem/server/graphql/ecs/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/ecs/resolvers.ts rename to x-pack/plugins/siem/server/graphql/ecs/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/ecs/schema.gql.ts b/x-pack/plugins/siem/server/graphql/ecs/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/ecs/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/ecs/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/events/index.ts b/x-pack/plugins/siem/server/graphql/events/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/events/index.ts rename to x-pack/plugins/siem/server/graphql/events/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/events/resolvers.ts b/x-pack/plugins/siem/server/graphql/events/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/events/resolvers.ts rename to x-pack/plugins/siem/server/graphql/events/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/events/schema.gql.ts b/x-pack/plugins/siem/server/graphql/events/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/events/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/events/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/hosts/index.ts b/x-pack/plugins/siem/server/graphql/hosts/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/hosts/index.ts rename to x-pack/plugins/siem/server/graphql/hosts/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/hosts/resolvers.ts b/x-pack/plugins/siem/server/graphql/hosts/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/hosts/resolvers.ts rename to x-pack/plugins/siem/server/graphql/hosts/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/hosts/schema.gql.ts b/x-pack/plugins/siem/server/graphql/hosts/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/hosts/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/hosts/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/index.ts b/x-pack/plugins/siem/server/graphql/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/index.ts rename to x-pack/plugins/siem/server/graphql/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/ip_details/index.ts b/x-pack/plugins/siem/server/graphql/ip_details/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/ip_details/index.ts rename to x-pack/plugins/siem/server/graphql/ip_details/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/ip_details/resolvers.ts b/x-pack/plugins/siem/server/graphql/ip_details/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/ip_details/resolvers.ts rename to x-pack/plugins/siem/server/graphql/ip_details/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/ip_details/schema.gql.ts b/x-pack/plugins/siem/server/graphql/ip_details/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/ip_details/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/ip_details/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/kpi_hosts/index.ts b/x-pack/plugins/siem/server/graphql/kpi_hosts/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/kpi_hosts/index.ts rename to x-pack/plugins/siem/server/graphql/kpi_hosts/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/kpi_hosts/resolvers.ts b/x-pack/plugins/siem/server/graphql/kpi_hosts/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/kpi_hosts/resolvers.ts rename to x-pack/plugins/siem/server/graphql/kpi_hosts/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/kpi_hosts/schema.gql.ts b/x-pack/plugins/siem/server/graphql/kpi_hosts/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/kpi_hosts/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/kpi_hosts/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/kpi_network/index.ts b/x-pack/plugins/siem/server/graphql/kpi_network/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/kpi_network/index.ts rename to x-pack/plugins/siem/server/graphql/kpi_network/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/kpi_network/resolvers.ts b/x-pack/plugins/siem/server/graphql/kpi_network/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/kpi_network/resolvers.ts rename to x-pack/plugins/siem/server/graphql/kpi_network/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/kpi_network/schema.gql.ts b/x-pack/plugins/siem/server/graphql/kpi_network/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/kpi_network/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/kpi_network/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/matrix_histogram/index.ts b/x-pack/plugins/siem/server/graphql/matrix_histogram/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/matrix_histogram/index.ts rename to x-pack/plugins/siem/server/graphql/matrix_histogram/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/matrix_histogram/resolvers.ts b/x-pack/plugins/siem/server/graphql/matrix_histogram/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/matrix_histogram/resolvers.ts rename to x-pack/plugins/siem/server/graphql/matrix_histogram/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/matrix_histogram/schema.gql.ts b/x-pack/plugins/siem/server/graphql/matrix_histogram/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/matrix_histogram/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/matrix_histogram/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/network/index.ts b/x-pack/plugins/siem/server/graphql/network/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/network/index.ts rename to x-pack/plugins/siem/server/graphql/network/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/network/resolvers.ts b/x-pack/plugins/siem/server/graphql/network/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/network/resolvers.ts rename to x-pack/plugins/siem/server/graphql/network/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/network/schema.gql.ts b/x-pack/plugins/siem/server/graphql/network/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/network/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/network/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/note/index.ts b/x-pack/plugins/siem/server/graphql/note/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/note/index.ts rename to x-pack/plugins/siem/server/graphql/note/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/note/resolvers.ts b/x-pack/plugins/siem/server/graphql/note/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/note/resolvers.ts rename to x-pack/plugins/siem/server/graphql/note/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/note/schema.gql.ts b/x-pack/plugins/siem/server/graphql/note/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/note/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/note/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/overview/index.ts b/x-pack/plugins/siem/server/graphql/overview/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/overview/index.ts rename to x-pack/plugins/siem/server/graphql/overview/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/overview/resolvers.ts b/x-pack/plugins/siem/server/graphql/overview/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/overview/resolvers.ts rename to x-pack/plugins/siem/server/graphql/overview/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/overview/schema.gql.ts b/x-pack/plugins/siem/server/graphql/overview/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/overview/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/overview/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/pinned_event/index.ts b/x-pack/plugins/siem/server/graphql/pinned_event/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/pinned_event/index.ts rename to x-pack/plugins/siem/server/graphql/pinned_event/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/pinned_event/resolvers.ts b/x-pack/plugins/siem/server/graphql/pinned_event/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/pinned_event/resolvers.ts rename to x-pack/plugins/siem/server/graphql/pinned_event/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/pinned_event/schema.gql.ts b/x-pack/plugins/siem/server/graphql/pinned_event/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/pinned_event/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/pinned_event/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_date/index.ts b/x-pack/plugins/siem/server/graphql/scalar_date/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_date/index.ts rename to x-pack/plugins/siem/server/graphql/scalar_date/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_date/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/scalar_date/resolvers.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_date/resolvers.test.ts rename to x-pack/plugins/siem/server/graphql/scalar_date/resolvers.test.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_date/resolvers.ts b/x-pack/plugins/siem/server/graphql/scalar_date/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_date/resolvers.ts rename to x-pack/plugins/siem/server/graphql/scalar_date/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_date/schema.gql.ts b/x-pack/plugins/siem/server/graphql/scalar_date/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_date/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/scalar_date/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_any/index.ts b/x-pack/plugins/siem/server/graphql/scalar_to_any/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_any/index.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_any/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_any/resolvers.ts b/x-pack/plugins/siem/server/graphql/scalar_to_any/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_any/resolvers.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_any/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_any/schema.gql.ts b/x-pack/plugins/siem/server/graphql/scalar_to_any/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_any/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_any/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_boolean_array/index.ts b/x-pack/plugins/siem/server/graphql/scalar_to_boolean_array/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_boolean_array/index.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_boolean_array/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_boolean_array/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/scalar_to_boolean_array/resolvers.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_boolean_array/resolvers.test.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_boolean_array/resolvers.test.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_boolean_array/resolvers.ts b/x-pack/plugins/siem/server/graphql/scalar_to_boolean_array/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_boolean_array/resolvers.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_boolean_array/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_boolean_array/schema.gql.ts b/x-pack/plugins/siem/server/graphql/scalar_to_boolean_array/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_boolean_array/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_boolean_array/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_date_array/index.ts b/x-pack/plugins/siem/server/graphql/scalar_to_date_array/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_date_array/index.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_date_array/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_date_array/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/scalar_to_date_array/resolvers.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_date_array/resolvers.test.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_date_array/resolvers.test.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_date_array/resolvers.ts b/x-pack/plugins/siem/server/graphql/scalar_to_date_array/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_date_array/resolvers.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_date_array/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_date_array/schema.gql.ts b/x-pack/plugins/siem/server/graphql/scalar_to_date_array/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_date_array/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_date_array/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_number_array/index.ts b/x-pack/plugins/siem/server/graphql/scalar_to_number_array/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_number_array/index.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_number_array/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_number_array/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/scalar_to_number_array/resolvers.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_number_array/resolvers.test.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_number_array/resolvers.test.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_number_array/resolvers.ts b/x-pack/plugins/siem/server/graphql/scalar_to_number_array/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_number_array/resolvers.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_number_array/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/scalar_to_number_array/schema.gql.ts b/x-pack/plugins/siem/server/graphql/scalar_to_number_array/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/scalar_to_number_array/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/scalar_to_number_array/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/source_status/index.ts b/x-pack/plugins/siem/server/graphql/source_status/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/source_status/index.ts rename to x-pack/plugins/siem/server/graphql/source_status/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/source_status/resolvers.ts b/x-pack/plugins/siem/server/graphql/source_status/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/source_status/resolvers.ts rename to x-pack/plugins/siem/server/graphql/source_status/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/source_status/schema.gql.ts b/x-pack/plugins/siem/server/graphql/source_status/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/source_status/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/source_status/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/sources/index.ts b/x-pack/plugins/siem/server/graphql/sources/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/sources/index.ts rename to x-pack/plugins/siem/server/graphql/sources/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/sources/resolvers.ts b/x-pack/plugins/siem/server/graphql/sources/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/sources/resolvers.ts rename to x-pack/plugins/siem/server/graphql/sources/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/sources/schema.gql.ts b/x-pack/plugins/siem/server/graphql/sources/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/sources/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/sources/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/timeline/index.ts b/x-pack/plugins/siem/server/graphql/timeline/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/timeline/index.ts rename to x-pack/plugins/siem/server/graphql/timeline/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/timeline/resolvers.ts b/x-pack/plugins/siem/server/graphql/timeline/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/timeline/resolvers.ts rename to x-pack/plugins/siem/server/graphql/timeline/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/timeline/schema.gql.ts b/x-pack/plugins/siem/server/graphql/timeline/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/timeline/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/timeline/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/tls/index.ts b/x-pack/plugins/siem/server/graphql/tls/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/tls/index.ts rename to x-pack/plugins/siem/server/graphql/tls/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/tls/resolvers.ts b/x-pack/plugins/siem/server/graphql/tls/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/tls/resolvers.ts rename to x-pack/plugins/siem/server/graphql/tls/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/tls/schema.gql.ts b/x-pack/plugins/siem/server/graphql/tls/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/tls/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/tls/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/types.ts b/x-pack/plugins/siem/server/graphql/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/types.ts rename to x-pack/plugins/siem/server/graphql/types.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/uncommon_processes/index.ts b/x-pack/plugins/siem/server/graphql/uncommon_processes/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/uncommon_processes/index.ts rename to x-pack/plugins/siem/server/graphql/uncommon_processes/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/uncommon_processes/resolvers.ts b/x-pack/plugins/siem/server/graphql/uncommon_processes/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/uncommon_processes/resolvers.ts rename to x-pack/plugins/siem/server/graphql/uncommon_processes/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/uncommon_processes/schema.gql.ts b/x-pack/plugins/siem/server/graphql/uncommon_processes/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/uncommon_processes/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/uncommon_processes/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/who_am_i/index.ts b/x-pack/plugins/siem/server/graphql/who_am_i/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/who_am_i/index.ts rename to x-pack/plugins/siem/server/graphql/who_am_i/index.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/who_am_i/resolvers.ts b/x-pack/plugins/siem/server/graphql/who_am_i/resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/who_am_i/resolvers.ts rename to x-pack/plugins/siem/server/graphql/who_am_i/resolvers.ts diff --git a/x-pack/legacy/plugins/siem/server/graphql/who_am_i/schema.gql.ts b/x-pack/plugins/siem/server/graphql/who_am_i/schema.gql.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/graphql/who_am_i/schema.gql.ts rename to x-pack/plugins/siem/server/graphql/who_am_i/schema.gql.ts diff --git a/x-pack/legacy/plugins/siem/server/init_server.ts b/x-pack/plugins/siem/server/init_server.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/init_server.ts rename to x-pack/plugins/siem/server/init_server.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/authentications/elasticsearch_adapter.test.ts b/x-pack/plugins/siem/server/lib/authentications/elasticsearch_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/authentications/elasticsearch_adapter.test.ts rename to x-pack/plugins/siem/server/lib/authentications/elasticsearch_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/authentications/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/authentications/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/authentications/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/authentications/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/authentications/index.ts b/x-pack/plugins/siem/server/lib/authentications/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/authentications/index.ts rename to x-pack/plugins/siem/server/lib/authentications/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/authentications/query.dsl.ts b/x-pack/plugins/siem/server/lib/authentications/query.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/authentications/query.dsl.ts rename to x-pack/plugins/siem/server/lib/authentications/query.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/authentications/types.ts b/x-pack/plugins/siem/server/lib/authentications/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/authentications/types.ts rename to x-pack/plugins/siem/server/lib/authentications/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/compose/kibana.ts b/x-pack/plugins/siem/server/lib/compose/kibana.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/compose/kibana.ts rename to x-pack/plugins/siem/server/lib/compose/kibana.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/configuration/adapter_types.ts b/x-pack/plugins/siem/server/lib/configuration/adapter_types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/configuration/adapter_types.ts rename to x-pack/plugins/siem/server/lib/configuration/adapter_types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/configuration/index.ts b/x-pack/plugins/siem/server/lib/configuration/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/configuration/index.ts rename to x-pack/plugins/siem/server/lib/configuration/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/configuration/inmemory_configuration_adapter.ts b/x-pack/plugins/siem/server/lib/configuration/inmemory_configuration_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/configuration/inmemory_configuration_adapter.ts rename to x-pack/plugins/siem/server/lib/configuration/inmemory_configuration_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/README.md b/x-pack/plugins/siem/server/lib/detection_engine/README.md similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/README.md rename to x-pack/plugins/siem/server/lib/detection_engine/README.md index 1e8e3d5e3dd75..610e82fd5f6ee 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/README.md +++ b/x-pack/plugins/siem/server/lib/detection_engine/README.md @@ -46,7 +46,7 @@ server log [22:05:22.277] [info][status][plugin:alerting@8.0.0] Status changed f server log [22:05:22.270] [info][status][plugin:actions@8.0.0] Status changed from uninitialized to green - Ready ``` -Go to the scripts folder `cd kibana/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts` and run: +Go to the scripts folder `cd kibana/x-pack/plugins/siem/server/lib/detection_engine/scripts` and run: ```sh ./hard_reset.sh @@ -159,7 +159,7 @@ https://github.com/elastic/kibana/tree/master/x-pack/plugins/actions To update the status of a signal or group of signals, the following scripts provide an example of how to go about doing so. -`cd x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts` +`cd x-pack/plugins/siem/server/lib/detection_engine/scripts` `./signals/put_signal_doc.sh` will post a sample signal doc into the signals index to play with `./signals/set_status_with_id.sh closed` will update the status of the sample signal to closed `./signals/set_status_with_id.sh open` will update the status of the sample signal to open diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/errors/bad_request_error.ts b/x-pack/plugins/siem/server/lib/detection_engine/errors/bad_request_error.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/errors/bad_request_error.ts rename to x-pack/plugins/siem/server/lib/detection_engine/errors/bad_request_error.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/feature_flags.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/feature_flags.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/feature_flags.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/feature_flags.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/feature_flags.ts b/x-pack/plugins/siem/server/lib/detection_engine/feature_flags.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/feature_flags.ts rename to x-pack/plugins/siem/server/lib/detection_engine/feature_flags.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/create_bootstrap_index.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/create_bootstrap_index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/create_bootstrap_index.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/create_bootstrap_index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/delete_all_index.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/delete_all_index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/delete_all_index.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/delete_all_index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/delete_policy.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/delete_policy.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/delete_policy.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/delete_policy.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/delete_template.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/delete_template.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/delete_template.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/delete_template.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/get_index_exists.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/get_index_exists.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/get_index_exists.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/get_index_exists.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/get_index_exists.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/get_index_exists.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/get_index_exists.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/get_index_exists.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/get_policy_exists.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/get_policy_exists.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/get_policy_exists.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/get_policy_exists.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/get_template_exists.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/get_template_exists.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/get_template_exists.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/get_template_exists.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/read_index.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/read_index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/read_index.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/read_index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/set_policy.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/set_policy.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/set_policy.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/set_policy.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/index/set_template.ts b/x-pack/plugins/siem/server/lib/detection_engine/index/set_template.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/index/set_template.ts rename to x-pack/plugins/siem/server/lib/detection_engine/index/set_template.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/add_tags.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/add_tags.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/add_tags.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/add_tags.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/add_tags.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/add_tags.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/add_tags.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/add_tags.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/build_signals_query.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/build_signals_query.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/build_signals_query.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/build_signals_query.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/build_signals_query.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/build_signals_query.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/build_signals_query.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/build_signals_query.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/create_notifications.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/create_notifications.test.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/create_notifications.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/create_notifications.test.ts index 3878f5dae8889..e0414f842ceb3 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/create_notifications.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/create_notifications.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { createNotifications } from './create_notifications'; describe('createNotifications', () => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/create_notifications.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/create_notifications.ts similarity index 93% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/create_notifications.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/create_notifications.ts index ccd7576255d83..35a737177ad49 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/create_notifications.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/create_notifications.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Alert } from '../../../../../../../plugins/alerting/common'; +import { Alert } from '../../../../../alerting/common'; import { APP_ID, NOTIFICATIONS_ID } from '../../../../common/constants'; import { CreateNotificationParams } from './types'; import { addTags } from './add_tags'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.test.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.test.ts index 7e5c0eaf6286e..089822f486aeb 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { deleteNotifications } from './delete_notifications'; import { readNotifications } from './read_notifications'; jest.mock('./read_notifications'); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/delete_notifications.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/find_notifications.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/find_notifications.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/find_notifications.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/find_notifications.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/find_notifications.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/find_notifications.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/find_notifications.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/find_notifications.ts index fcdeda608fe4e..b47ea348bd4d6 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/find_notifications.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/find_notifications.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { FindResult } from '../../../../../../../plugins/alerting/server'; +import { FindResult } from '../../../../../alerting/server'; import { NOTIFICATIONS_ID } from '../../../../common/constants'; import { FindNotificationParams } from './types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/get_signals_count.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/get_signals_count.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/get_signals_count.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/get_signals_count.ts index 7ff6a4e5164bd..69f37da1e225b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/get_signals_count.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/get_signals_count.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { buildSignalsSearchQuery } from './build_signals_query'; interface GetSignalsCount { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/read_notifications.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/read_notifications.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/read_notifications.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/read_notifications.test.ts index 834ad2460959c..961aac15c484d 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/read_notifications.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/read_notifications.test.ts @@ -5,7 +5,7 @@ */ import { readNotifications } from './read_notifications'; -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { getNotificationResult, getFindNotificationsResultWithSingleHit, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/read_notifications.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/read_notifications.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/read_notifications.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/read_notifications.ts index 87bdd6f3f40e1..c585c474556a1 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/read_notifications.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/read_notifications.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SanitizedAlert } from '../../../../../../../plugins/alerting/common'; +import { SanitizedAlert } from '../../../../../alerting/common'; import { ReadNotificationParams, isAlertType } from './types'; import { findNotifications } from './find_notifications'; import { INTERNAL_RULE_ALERT_ID_KEY } from '../../../../common/constants'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.test.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.test.ts index f537b22bac1eb..6244a4cc64e68 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.test.ts @@ -8,7 +8,7 @@ import { loggerMock } from 'src/core/server/logging/logger.mock'; import { getResult } from '../routes/__mocks__/request_responses'; import { rulesNotificationAlertType } from './rules_notification_alert_type'; import { buildSignalsSearchQuery } from './build_signals_query'; -import { alertsMock, AlertServicesMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsMock, AlertServicesMock } from '../../../../../../plugins/alerting/server/mocks'; import { NotificationExecutorOptions } from './types'; jest.mock('./build_signals_query'); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/rules_notification_alert_type.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/schedule_notification_actions.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/schedule_notification_actions.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/schedule_notification_actions.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/schedule_notification_actions.ts index 9f145af79ca90..a0bd5e092c6ea 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/schedule_notification_actions.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/schedule_notification_actions.ts @@ -5,7 +5,7 @@ */ import { mapKeys, snakeCase } from 'lodash/fp'; -import { AlertInstance } from '../../../../../../../plugins/alerting/server'; +import { AlertInstance } from '../../../../../alerting/server'; import { RuleTypeParams } from '../types'; export type NotificationRuleTypeParams = RuleTypeParams & { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/types.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/types.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/types.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/types.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/types.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/types.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/types.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/types.ts index 32a8737adc7c9..d740b79cb3b94 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/types.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/types.ts @@ -10,8 +10,8 @@ import { AlertType, State, AlertExecutorOptions, -} from '../../../../../../../plugins/alerting/server'; -import { Alert } from '../../../../../../../plugins/alerting/common'; +} from '../../../../../alerting/server'; +import { Alert } from '../../../../../alerting/common'; import { NOTIFICATIONS_ID } from '../../../../common/constants'; import { RuleAlertAction } from '../../../../common/detection_engine/types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/update_notifications.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/update_notifications.test.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/update_notifications.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/update_notifications.test.ts index e1f7526438c31..b9dc42b96696d 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/update_notifications.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/update_notifications.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { updateNotifications } from './update_notifications'; import { readNotifications } from './read_notifications'; import { createNotifications } from './create_notifications'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/update_notifications.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/update_notifications.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/update_notifications.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/update_notifications.ts index ac0de406aceb2..5889b0e4dcfb8 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/update_notifications.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/notifications/update_notifications.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { PartialAlert } from '../../../../../../../plugins/alerting/server'; +import { PartialAlert } from '../../../../../alerting/server'; import { readNotifications } from './read_notifications'; import { UpdateNotificationParams } from './types'; import { addTags } from './add_tags'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/utils.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/utils.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/utils.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/utils.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/utils.ts b/x-pack/plugins/siem/server/lib/detection_engine/notifications/utils.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/notifications/utils.ts rename to x-pack/plugins/siem/server/lib/detection_engine/notifications/utils.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/privileges/read_privileges.ts b/x-pack/plugins/siem/server/lib/detection_engine/privileges/read_privileges.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/privileges/read_privileges.ts rename to x-pack/plugins/siem/server/lib/detection_engine/privileges/read_privileges.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/index.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/index.ts similarity index 59% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/index.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/index.ts index 1ccd43c06aacc..a28eb6ba3ccaa 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/index.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/index.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { DEFAULT_SIGNALS_INDEX, SIGNALS_INDEX_KEY } from '../../../../../common/constants'; import { requestContextMock } from './request_context'; import { serverMock } from './server'; import { requestMock } from './request'; @@ -11,7 +12,11 @@ import { responseMock } from './response_factory'; export { requestMock, requestContextMock, responseMock, serverMock }; -export const createMockConfig = () => () => ({ - get: jest.fn(), - has: jest.fn(), +export const createMockConfig = () => ({ + enabled: true, + [SIGNALS_INDEX_KEY]: DEFAULT_SIGNALS_INDEX, + maxRuleImportExportSize: 10000, + maxRuleImportPayloadBytes: 10485760, + maxTimelineImportExportSize: 10000, + maxTimelineImportPayloadBytes: 10485760, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/request.ts similarity index 79% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/request.ts index 8856a3463aab3..5f9246db7dfd5 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/request.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { httpServerMock } from '../../../../../../../../../src/core/server/mocks'; +import { httpServerMock } from '../../../../../../../../src/core/server/mocks'; export const requestMock = { create: httpServerMock.createKibanaRequest, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_context.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_context.ts similarity index 79% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_context.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_context.ts index 2e5c29bc0221a..10efdb518f7b7 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_context.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_context.ts @@ -4,15 +4,15 @@ * you may not use this file except in compliance with the Elastic License. */ -import { RequestHandlerContext } from '../../../../../../../../../src/core/server'; +import { RequestHandlerContext } from '../../../../../../../../src/core/server'; import { coreMock, elasticsearchServiceMock, savedObjectsClientMock, -} from '../../../../../../../../../src/core/server/mocks'; -import { alertsClientMock } from '../../../../../../../../plugins/alerting/server/mocks'; -import { actionsClientMock } from '../../../../../../../../plugins/actions/server/mocks'; -import { licensingMock } from '../../../../../../../../plugins/licensing/server/mocks'; +} from '../../../../../../../../src/core/server/mocks'; +import { alertsClientMock } from '../../../../../../alerting/server/mocks'; +import { actionsClientMock } from '../../../../../../actions/server/mocks'; +import { licensingMock } from '../../../../../../licensing/server/mocks'; const createMockClients = () => ({ actionsClient: actionsClientMock.create(), diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts index 94097df48949f..8c97d4436a561 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/request_responses.ts @@ -5,7 +5,7 @@ */ import { SavedObjectsFindResponse } from 'kibana/server'; -import { ActionResult } from '../../../../../../../../plugins/actions/server'; +import { ActionResult } from '../../../../../../actions/server'; import { SignalsStatusRestParams, SignalsQueryRestParams, @@ -448,7 +448,7 @@ export const getResult = (): RuleAlertType => ({ references: ['http://www.example.com', 'https://ww.example.com'], note: '# Investigative notes', version: 1, - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/response_factory.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/response_factory.ts similarity index 79% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/response_factory.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/response_factory.ts index 3e0eda9961403..e6c03d382d9db 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/response_factory.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/response_factory.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { httpServerMock } from '../../../../../../../../../src/core/server/mocks'; +import { httpServerMock } from '../../../../../../../../src/core/server/mocks'; export const responseMock = { create: httpServerMock.createResponseFactory, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/server.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/server.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/server.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/server.ts index 824d1f2bec334..c08e626adb323 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/server.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/server.ts @@ -9,8 +9,8 @@ import { RouteConfig, KibanaRequest, RequestHandlerContext, -} from '../../../../../../../../../src/core/server'; -import { httpServiceMock } from '../../../../../../../../../src/core/server/mocks'; +} from '../../../../../../../../src/core/server'; +import { httpServiceMock } from '../../../../../../../../src/core/server/mocks'; import { requestContextMock } from './request_context'; import { responseMock as responseFactoryMock } from './response_factory'; import { requestMock } from '.'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/test_adapters.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/test_adapters.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/test_adapters.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/test_adapters.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/utils.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/utils.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/utils.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/utils.ts index c929b0718207d..6f628170271f3 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/__mocks__/utils.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/__mocks__/utils.ts @@ -138,7 +138,7 @@ export const getOutputRuleAlertForRest = (): Omit< ], }, ], - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/create_index_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/create_index_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/create_index_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/index/create_index_route.ts index 3195483013c19..cb48e35228858 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/create_index_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/create_index_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_INDEX_URL } from '../../../../../common/constants'; import { transformError, buildSiemResponse } from '../utils'; import { getIndexExists } from '../../index/get_index_exists'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/delete_index_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/delete_index_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/delete_index_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/index/delete_index_route.ts index c667e7ae9c463..5eff38b778492 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/delete_index_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/delete_index_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_INDEX_URL } from '../../../../../common/constants'; import { transformError, buildSiemResponse } from '../utils'; import { getIndexExists } from '../../index/get_index_exists'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/ecs_mapping.json b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/ecs_mapping.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/ecs_mapping.json rename to x-pack/plugins/siem/server/lib/detection_engine/routes/index/ecs_mapping.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/get_signals_template.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/get_signals_template.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/get_signals_template.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/index/get_signals_template.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/get_signals_template.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/get_signals_template.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/get_signals_template.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/index/get_signals_template.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/read_index_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/read_index_route.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/read_index_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/index/read_index_route.ts index 047176f155611..8ff8d7461ecd1 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/read_index_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/read_index_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_INDEX_URL } from '../../../../../common/constants'; import { transformError, buildSiemResponse } from '../utils'; import { getIndexExists } from '../../index/get_index_exists'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json rename to x-pack/plugins/siem/server/lib/detection_engine/routes/index/signals_mapping.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_policy.json b/x-pack/plugins/siem/server/lib/detection_engine/routes/index/signals_policy.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/index/signals_policy.json rename to x-pack/plugins/siem/server/lib/detection_engine/routes/index/signals_policy.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts index 3209f5ce9f519..ce44f71ef7217 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { securityMock } from '../../../../../../../../plugins/security/server/mocks'; +import { securityMock } from '../../../../../../security/server/mocks'; import { readPrivilegesRoute } from './read_privileges_route'; import { serverMock, requestContextMock } from '../__mocks__'; import { getPrivilegeRequest, getMockPrivilegesResult } from '../__mocks__/request_responses'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts index d86880de65386..7dbbe837e656d 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/privileges/read_privileges_route.ts @@ -6,7 +6,7 @@ import { merge } from 'lodash/fp'; -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_PRIVILEGES_URL } from '../../../../../common/constants'; import { SetupPlugins } from '../../../../plugin'; import { buildSiemResponse, transformError } from '../utils'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.ts index 3eba04debb21f..bfc8c9c54b2c0 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/add_prepackaged_rules_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_PREPACKAGED_URL } from '../../../../../common/constants'; import { getIndexExists } from '../../index/get_index_exists'; import { transformError, buildSiemResponse } from '../utils'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts index 5377e9039785e..2d7ddb79e5af5 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_bulk_route.ts @@ -6,7 +6,7 @@ import uuid from 'uuid'; -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { createRules } from '../../rules/create_rules'; import { RuleAlertParamsRest } from '../../types'; @@ -86,7 +86,7 @@ export const createRulesBulkRoute = (router: IRouter) => { timeline_id: timelineId, timeline_title: timelineTitle, version, - lists, + exceptions_list, } = payloadRule; const ruleIdOrUuid = ruleId ?? uuid.v4(); try { @@ -143,7 +143,7 @@ export const createRulesBulkRoute = (router: IRouter) => { references, note, version, - lists, + exceptions_list, actions: throttle === 'rule' ? actions : [], // Only enable actions if throttle is set to rule, otherwise we are a notification and should not enable it, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts index 9a329b78b8f12..1f0896686aca0 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/create_rules_route.ts @@ -6,7 +6,7 @@ import uuid from 'uuid'; -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { createRules } from '../../rules/create_rules'; import { IRuleSavedAttributesSavedObjectAttributes } from '../../rules/types'; @@ -66,7 +66,7 @@ export const createRulesRoute = (router: IRouter): void => { type, references, note, - lists, + exceptions_list, } = request.body; const siemResponse = buildSiemResponse(response); @@ -131,7 +131,7 @@ export const createRulesRoute = (router: IRouter): void => { references, note, version: 1, - lists, + exceptions_list, actions: throttle === 'rule' ? actions : [], // Only enable actions if throttle is rule, otherwise we are a notification and should not enable it, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts index 0c5ad2e060924..38748e287ab45 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_bulk_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter, RouteConfig, RequestHandler } from '../../../../../../../../../src/core/server'; +import { IRouter, RouteConfig, RequestHandler } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { queryRulesBulkSchema } from '../schemas/query_rules_bulk_schema'; import { rulesBulkSchema } from '../schemas/response/rules_bulk_schema'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.ts index 71724e3ba9b58..098d556741fed 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/delete_rules_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { deleteRules } from '../../rules/delete_rules'; import { queryRulesSchema } from '../schemas/query_rules_schema'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/export_rules_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/export_rules_route.ts similarity index 90% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/export_rules_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/export_rules_route.ts index 50eafe163c265..8433b74adf310 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/export_rules_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/export_rules_route.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; -import { LegacyServices } from '../../../../types'; +import { ConfigType } from '../../../..'; import { ExportRulesRequestParams } from '../../rules/types'; import { getNonPackagedRulesCount } from '../../rules/get_existing_prepackaged_rules'; import { exportRulesSchema, exportRulesQuerySchema } from '../schemas/export_rules_schema'; @@ -14,7 +14,7 @@ import { getExportByObjectIds } from '../../rules/get_export_by_object_ids'; import { getExportAll } from '../../rules/get_export_all'; import { transformError, buildRouteValidation, buildSiemResponse } from '../utils'; -export const exportRulesRoute = (router: IRouter, config: LegacyServices['config']) => { +export const exportRulesRoute = (router: IRouter, config: ConfigType) => { router.post( { path: `${DETECTION_ENGINE_RULES_URL}/_export`, @@ -35,7 +35,7 @@ export const exportRulesRoute = (router: IRouter, config: LegacyServices['config } try { - const exportSizeLimit = config().get('savedObjects.maxImportExportSize'); + const exportSizeLimit = config.maxRuleImportExportSize; if (request.body?.objects != null && request.body.objects.length > exportSizeLimit) { return siemResponse.error({ statusCode: 400, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.ts index 85555c1a57084..9661fac81497c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { findRules } from '../../rules/find_rules'; import { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.ts index 8eed146537718..6b54a25a1b1c4 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/find_rules_status_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { findRulesStatusesSchema } from '../schemas/find_rules_statuses_schema'; import { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.ts index 7f0bf4bf81179..67a54f3ba492a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/get_prepackaged_rules_status_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_PREPACKAGED_URL } from '../../../../../common/constants'; import { transformError, buildSiemResponse } from '../utils'; import { getPrepackagedRules } from '../../rules/get_prepackaged_rules'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.test.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.test.ts index 61f5e6faf1bdb..8c052cfdf4024 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.test.ts @@ -23,7 +23,6 @@ import { } from '../__mocks__/request_responses'; import { createMockConfig, requestContextMock, serverMock, requestMock } from '../__mocks__'; import { importRulesRoute } from './import_rules_route'; -import { DEFAULT_SIGNALS_INDEX } from '../../../../../common/constants'; import * as createRulesStreamFromNdJson from '../../rules/create_rules_stream_from_ndjson'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../feature_flags'; @@ -36,7 +35,7 @@ describe('import_rules_route', () => { unSetFeatureFlagsForTestsOnly(); }); - let config = createMockConfig(); + let config: ReturnType; let server: ReturnType; let request: ReturnType; let { clients, context } = requestContextMock.createTools(); @@ -51,30 +50,10 @@ describe('import_rules_route', () => { server = serverMock.create(); ({ clients, context } = requestContextMock.createTools()); + config = createMockConfig(); const hapiStream = buildHapiStream(ruleIdsToNdJsonString(['rule-1'])); request = getImportRulesRequest(hapiStream); - config = () => ({ - get: jest.fn(value => { - switch (value) { - case 'savedObjects.maxImportPayloadBytes': { - return 10000; - } - case 'savedObjects.maxImportExportSize': { - return 10000; - } - case 'xpack.siem.signalsIndex': { - return DEFAULT_SIGNALS_INDEX; - } - default: { - const dummyMock = jest.fn(); - return dummyMock(); - } - } - }), - has: jest.fn(), - }); - clients.clusterClient.callAsCurrentUser.mockResolvedValue(getNonEmptyIndex()); // index exists clients.alertsClient.find.mockResolvedValue(getEmptyFindResult()); // no extant rules diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts index 57ccc7a7806ac..527fab786910f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/import_rules_route.ts @@ -7,10 +7,10 @@ import { chunk } from 'lodash/fp'; import { extname } from 'path'; -import { IRouter } from '../../../../../../../../../src/core/server'; -import { createPromiseFromStreams } from '../../../../../../../../../src/legacy/utils/streams'; +import { IRouter } from '../../../../../../../../src/core/server'; +import { createPromiseFromStreams } from '../../../../../../../../src/legacy/utils/streams'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; -import { LegacyServices } from '../../../../types'; +import { ConfigType } from '../../../..'; import { createRules } from '../../rules/create_rules'; import { ImportRulesRequestParams } from '../../rules/types'; import { readRules } from '../../rules/read_rules'; @@ -38,7 +38,7 @@ type PromiseFromStreams = ImportRuleAlertRest | Error; const CHUNK_PARSED_OBJECT_SIZE = 10; -export const importRulesRoute = (router: IRouter, config: LegacyServices['config']) => { +export const importRulesRoute = (router: IRouter, config: ConfigType) => { router.post( { path: `${DETECTION_ENGINE_RULES_URL}/_import`, @@ -49,7 +49,7 @@ export const importRulesRoute = (router: IRouter, config: LegacyServices['config options: { tags: ['access:siem'], body: { - maxBytes: config().get('savedObjects.maxImportPayloadBytes'), + maxBytes: config.maxRuleImportPayloadBytes, output: 'stream', }, }, @@ -77,7 +77,7 @@ export const importRulesRoute = (router: IRouter, config: LegacyServices['config }); } - const objectLimit = config().get('savedObjects.maxImportExportSize'); + const objectLimit = config.maxRuleImportExportSize; const readStream = createRulesStreamFromNdJson(objectLimit); const parsedObjects = await createPromiseFromStreams([ request.body.file, @@ -138,7 +138,7 @@ export const importRulesRoute = (router: IRouter, config: LegacyServices['config timeline_id: timelineId, timeline_title: timelineTitle, version, - lists, + exceptions_list, } = parsedRule; try { @@ -195,7 +195,7 @@ export const importRulesRoute = (router: IRouter, config: LegacyServices['config references, note, version, - lists, + exceptions_list, actions: [], // Actions are not imported nor exported at this time }); resolve({ rule_id: ruleId, status_code: 200 }); @@ -232,7 +232,7 @@ export const importRulesRoute = (router: IRouter, config: LegacyServices['config references, note, version, - lists, + exceptions_list, anomalyThreshold, machineLearningJobId, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts index 8c0fceb7a5f29..e4236f4632dcd 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_bulk_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { IRuleSavedAttributesSavedObjectAttributes, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts index 9c5000d70e5fe..23469144e11f8 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/patch_rules_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { patchRules } from '../../rules/patch_rules'; import { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.ts index 77747448e94fd..4d23e0217f2e8 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/read_rules_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { getIdError } from './utils'; import { transformValidate } from './validate'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts index 36e15780f5cb3..6db91d74294fc 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_bulk_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { IRuleSavedAttributesSavedObjectAttributes, @@ -81,7 +81,7 @@ export const updateRulesBulkRoute = (router: IRouter) => { references, note, version, - lists, + exceptions_list, } = payloadRule; const finalIndex = outputIndex ?? siemClient.signalsIndex; const idOrRuleIdOrUnknown = id ?? ruleId ?? '(unknown id)'; @@ -121,7 +121,7 @@ export const updateRulesBulkRoute = (router: IRouter) => { references, note, version, - lists, + exceptions_list, actions, }); if (rule != null) { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.ts index 0444c757a9b31..7dbbe5a22ab46 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/update_rules_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_RULES_URL } from '../../../../../common/constants'; import { UpdateRuleAlertParamsRest, @@ -67,7 +67,7 @@ export const updateRulesRoute = (router: IRouter) => { references, note, version, - lists, + exceptions_list, } = request.body; const siemResponse = buildSiemResponse(response); @@ -117,7 +117,7 @@ export const updateRulesRoute = (router: IRouter) => { references, note, version, - lists, + exceptions_list, actions: throttle === 'rule' ? actions : [], // Only enable actions if throttle is rule, otherwise we are a notification and should not enable it }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/utils.test.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/utils.test.ts index 8b1b0cab3b2f2..ec9e84d4fa6bb 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/utils.test.ts @@ -22,12 +22,12 @@ import { INTERNAL_IDENTIFIER } from '../../../../../common/constants'; import { ImportRuleAlertRest, RuleAlertParamsRest, RuleTypeParams } from '../../types'; import { BulkError, ImportSuccessError } from '../utils'; import { getSimpleRule, getOutputRuleAlertForRest } from '../__mocks__/utils'; -import { createPromiseFromStreams } from '../../../../../../../../../src/legacy/utils/streams'; -import { PartialAlert } from '../../../../../../../../plugins/alerting/server'; -import { SanitizedAlert } from '../../../../../../../../plugins/alerting/server/types'; +import { createPromiseFromStreams } from '../../../../../../../../src/legacy/utils/streams'; +import { PartialAlert } from '../../../../../../alerting/server'; +import { SanitizedAlert } from '../../../../../../alerting/server/types'; +import { createRulesStreamFromNdJson } from '../../rules/create_rules_stream_from_ndjson'; import { RuleAlertType } from '../../rules/types'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../feature_flags'; -import { createRulesStreamFromNdJson } from '../../rules/create_rules_stream_from_ndjson'; type PromiseFromStreams = ImportRuleAlertRest | Error; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts index 790603fa8cfc1..67b0c4462655c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/utils.ts @@ -8,7 +8,7 @@ import { pickBy, countBy } from 'lodash/fp'; import { SavedObject, SavedObjectsFindResponse } from 'kibana/server'; import uuid from 'uuid'; -import { PartialAlert, FindResult } from '../../../../../../../../plugins/alerting/server'; +import { PartialAlert, FindResult } from '../../../../../../alerting/server'; import { INTERNAL_IDENTIFIER } from '../../../../../common/constants'; import { RuleAlertType, @@ -148,7 +148,7 @@ export const transformAlertToRule = ( last_failure_message: ruleStatus?.attributes.lastFailureMessage, last_success_message: ruleStatus?.attributes.lastSuccessMessage, // TODO: (LIST-FEATURE) Remove hasListsFeature() check once we have lists available for a release - lists: hasListsFeature() ? alert.params.lists : null, + exceptions_list: hasListsFeature() ? alert.params.exceptions_list : null, }); }; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/validate.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/validate.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/validate.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/validate.test.ts index 7537401e5a366..9069202d4d3aa 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/validate.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/validate.test.ts @@ -13,7 +13,7 @@ import { transformValidateBulkError, } from './validate'; import { getResult } from '../__mocks__/request_responses'; -import { FindResult } from '../../../../../../../../plugins/alerting/server'; +import { FindResult } from '../../../../../../alerting/server'; import { RulesSchema } from '../schemas/response/rules_schema'; import { BulkError } from '../utils'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../feature_flags'; @@ -71,7 +71,7 @@ export const ruleOutput: RulesSchema = { }, }, ], - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/validate.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/validate.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/validate.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/rules/validate.ts index 1f3d1ec856684..cfba40fc225a2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/rules/validate.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/rules/validate.ts @@ -9,8 +9,9 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import * as t from 'io-ts'; -import { PartialAlert, FindResult } from '../../../../../../../../plugins/alerting/server'; -import { formatErrors } from '../schemas/response/utils'; +import { formatErrors } from '../../../../utils/build_validation/format_errors'; +import { exactCheck } from '../../../../utils/build_validation/exact_check'; +import { PartialAlert, FindResult } from '../../../../../../alerting/server'; import { isAlertType, IRuleSavedAttributesSavedObjectAttributes, @@ -19,7 +20,6 @@ import { import { OutputRuleAlertRest } from '../../types'; import { createBulkErrorObject, BulkError } from '../utils'; import { rulesSchema, RulesSchema } from '../schemas/response/rules_schema'; -import { exactCheck } from '../schemas/response/exact_check'; import { transformFindAlerts, transform, transformAlertToRule } from './utils'; import { findRulesSchema } from '../schemas/response/find_rules_schema'; import { RuleActions } from '../../rule_actions/types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.test.ts index 8c741c937bf15..226dea7c20344 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertAction } from '../../../../../../../../plugins/alerting/common'; +import { AlertAction } from '../../../../../../alerting/common'; import { RuleAlertAction } from '../../../../../common/detection_engine/types'; import { ThreatParams, PrepackagedRules } from '../../types'; import { addPrepackagedRulesSchema } from './add_prepackaged_rules_schema'; @@ -1542,8 +1542,8 @@ describe('add prepackaged rules schema', () => { // on demand. Since they are per module, we have a an issue where the ENV variables do not take effect. It is better we change all the // schema's to be function calls to avoid global side effects or just wait until the feature is available. If you want to test this early, // you can remove the .skip and set your env variable of export ELASTIC_XPACK_SIEM_LISTS_FEATURE=true locally - describe.skip('lists', () => { - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and lists] does validate', () => { + describe.skip('exceptions_list', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and exceptions_list] does validate', () => { expect( addPrepackagedRulesSchema.validate>({ rule_id: 'rule-1', @@ -1558,7 +1558,7 @@ describe('add prepackaged rules schema', () => { risk_score: 50, note: '# some markdown', version: 1, - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -1594,7 +1594,7 @@ describe('add prepackaged rules schema', () => { ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty lists] does validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty exceptions_list] does validate', () => { expect( addPrepackagedRulesSchema.validate>({ rule_id: 'rule-1', @@ -1608,15 +1608,15 @@ describe('add prepackaged rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [], + exceptions_list: [], version: 1, }).error ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid lists] does NOT validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid exceptions_list] does NOT validate', () => { expect( - addPrepackagedRulesSchema.validate>>({ + addPrepackagedRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1628,17 +1628,17 @@ describe('add prepackaged rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [{ invalid_value: 'invalid value' }], + exceptions_list: [{ invalid_value: 'invalid value' }], version: 1, }).error.message ).toEqual( - 'child "lists" fails because ["lists" at position 0 fails because [child "field" fails because ["field" is required]]]' + 'child "exceptions_list" fails because ["exceptions_list" at position 0 fails because [child "field" fails because ["field" is required]]]' ); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent lists] does validate with empty lists', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent exceptions_list] does validate with empty exceptions_list', () => { expect( - addPrepackagedRulesSchema.validate>>({ + addPrepackagedRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1651,7 +1651,7 @@ describe('add prepackaged rules schema', () => { risk_score: 50, note: '# some markdown', version: 1, - }).value.lists + }).value.exceptions_list ).toEqual([]); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.ts index 006fc81e3ee87..0e82a9b979c7b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/add_prepackaged_rules_schema.ts @@ -114,5 +114,5 @@ export const addPrepackagedRulesSchema = Joi.object({ version: version.required(), // TODO: (LIST-FEATURE) Remove the hasListsFeatures once this is ready for release - lists: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), + exceptions_list: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_bulk_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_bulk_schema.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_bulk_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_bulk_schema.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_bulk_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_bulk_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_bulk_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_bulk_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.test.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.test.ts index e56e8e5fe34d3..1e2941015b735 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertAction } from '../../../../../../../../plugins/alerting/common'; +import { AlertAction } from '../../../../../../alerting/common'; import { createRulesSchema } from './create_rules_schema'; import { PatchRuleAlertParamsRest } from '../../rules/types'; import { RuleAlertAction } from '../../../../../common/detection_engine/types'; @@ -556,7 +556,9 @@ describe('create rules schema', () => { test('language does not validate with something made up', () => { expect( - createRulesSchema.validate>({ + createRulesSchema.validate< + Partial & { language: string }> + >({ rule_id: 'rule-1', output_index: '.siem-signals', risk_score: 50, @@ -1508,8 +1510,8 @@ describe('create rules schema', () => { // on demand. Since they are per module, we have a an issue where the ENV variables do not take effect. It is better we change all the // schema's to be function calls to avoid global side effects or just wait until the feature is available. If you want to test this early, // you can remove the .skip and set your env variable of export ELASTIC_XPACK_SIEM_LISTS_FEATURE=true locally - describe.skip('lists', () => { - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and lists] does validate', () => { + describe.skip('exceptions_list', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and exceptions_list] does validate', () => { expect( createRulesSchema.validate>({ rule_id: 'rule-1', @@ -1523,7 +1525,7 @@ describe('create rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -1559,7 +1561,7 @@ describe('create rules schema', () => { ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty lists] does validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty exceptions_list] does validate', () => { expect( createRulesSchema.validate>({ rule_id: 'rule-1', @@ -1573,14 +1575,14 @@ describe('create rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [], + exceptions_list: [], }).error ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid lists] does NOT validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid exceptions_list] does NOT validate', () => { expect( - createRulesSchema.validate>>({ + createRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1592,16 +1594,16 @@ describe('create rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [{ invalid_value: 'invalid value' }], + exceptions_list: [{ invalid_value: 'invalid value' }], }).error.message ).toEqual( - 'child "lists" fails because ["lists" at position 0 fails because [child "field" fails because ["field" is required]]]' + 'child "exceptions_list" fails because ["exceptions_list" at position 0 fails because [child "field" fails because ["field" is required]]]' ); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent lists] does validate with empty lists', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent exceptions_list] does validate with empty exceptions_list', () => { expect( - createRulesSchema.validate>>({ + createRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1613,7 +1615,7 @@ describe('create rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - }).value.lists + }).value.exceptions_list ).toEqual([]); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.ts index 5213f3faaf486..dec8b5ccbc790 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/create_rules_schema.ts @@ -98,5 +98,5 @@ export const createRulesSchema = Joi.object({ version: version.default(1), // TODO: (LIST-FEATURE) Remove the hasListsFeatures once this is ready for release - lists: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), + exceptions_list: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/export_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/export_rules_schema.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/export_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/export_rules_schema.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/export_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/export_rules_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/export_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/export_rules_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_schema.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_schema.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_statuses_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_statuses_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_statuses_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/find_rules_statuses_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.test.ts index 40f7b19ea12b3..d28530ffb789e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertAction } from '../../../../../../../../plugins/alerting/common'; +import { AlertAction } from '../../../../../../alerting/common'; import { importRulesSchema, importRulesQuerySchema, @@ -1729,8 +1729,8 @@ describe('import rules schema', () => { // on demand. Since they are per module, we have a an issue where the ENV variables do not take effect. It is better we change all the // schema's to be function calls to avoid global side effects or just wait until the feature is available. If you want to test this early, // you can remove the .skip and set your env variable of export ELASTIC_XPACK_SIEM_LISTS_FEATURE=true locally - describe.skip('lists', () => { - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and lists] does validate', () => { + describe.skip('exceptions_list', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and exceptions_list] does validate', () => { expect( importRulesSchema.validate>({ rule_id: 'rule-1', @@ -1744,7 +1744,7 @@ describe('import rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -1780,7 +1780,7 @@ describe('import rules schema', () => { ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty lists] does validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty exceptions_list] does validate', () => { expect( importRulesSchema.validate>({ rule_id: 'rule-1', @@ -1794,14 +1794,14 @@ describe('import rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [], + exceptions_list: [], }).error ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid lists] does NOT validate and lists is empty', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid exceptions_list] does NOT validate and exceptions_list is empty', () => { expect( - importRulesSchema.validate>>({ + importRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1813,16 +1813,16 @@ describe('import rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [{ invalid_value: 'invalid value' }], + exceptions_list: [{ invalid_value: 'invalid value' }], }).error.message ).toEqual( - 'child "lists" fails because ["lists" at position 0 fails because [child "field" fails because ["field" is required]]]' + 'child "exceptions_list" fails because ["exceptions_list" at position 0 fails because [child "field" fails because ["field" is required]]]' ); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent lists] does validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent exceptions_list] does validate', () => { expect( - importRulesSchema.validate>>({ + importRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1834,7 +1834,7 @@ describe('import rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - }).value.lists + }).value.exceptions_list ).toEqual([]); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.ts index 56aa45659fda7..d3c728ebac1a9 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/import_rules_schema.ts @@ -119,7 +119,7 @@ export const importRulesSchema = Joi.object({ updated_by, // TODO: (LIST-FEATURE) Remove the hasListsFeatures once this is ready for release - lists: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), + exceptions_list: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), }); export const importRulesQuerySchema = Joi.object({ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_bulk_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_bulk_schema.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_bulk_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_bulk_schema.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_bulk_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_bulk_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_bulk_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_bulk_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.test.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.test.ts index e01a8f40fcea4..755c0b2ccaa3f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertAction } from '../../../../../../../../plugins/alerting/common'; +import { AlertAction } from '../../../../../../alerting/common'; import { patchRulesSchema } from './patch_rules_schema'; import { PatchRuleAlertParamsRest } from '../../rules/types'; import { RuleAlertAction } from '../../../../../common/detection_engine/types'; @@ -572,7 +572,9 @@ describe('patch rules schema', () => { test('language does not validate with something made up', () => { expect( - patchRulesSchema.validate>({ + patchRulesSchema.validate< + Partial & { language: string }> + >({ id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1211,8 +1213,8 @@ describe('patch rules schema', () => { // on demand. Since they are per module, we have a an issue where the ENV variables do not take effect. It is better we change all the // schema's to be function calls to avoid global side effects or just wait until the feature is available. If you want to test this early, // you can remove the .skip and set your env variable of export ELASTIC_XPACK_SIEM_LISTS_FEATURE=true locally - describe.skip('lists', () => { - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and lists] does validate', () => { + describe.skip('exceptions_list', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and exceptions_list] does validate', () => { expect( patchRulesSchema.validate>({ rule_id: 'rule-1', @@ -1226,7 +1228,7 @@ describe('patch rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -1262,11 +1264,11 @@ describe('patch rules schema', () => { ).toBeFalsy(); }); - test('lists can be patched', () => { + test('exceptions_list can be patched', () => { expect( patchRulesSchema.validate>({ rule_id: 'some id', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -1299,7 +1301,7 @@ describe('patch rules schema', () => { ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty lists] does validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty exceptions_list] does validate', () => { expect( patchRulesSchema.validate>({ rule_id: 'rule-1', @@ -1313,14 +1315,14 @@ describe('patch rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [], + exceptions_list: [], }).error ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid lists] does NOT validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid exceptions_list] does NOT validate', () => { expect( - patchRulesSchema.validate>>({ + patchRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1332,16 +1334,16 @@ describe('patch rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [{ invalid_value: 'invalid value' }], + exceptions_list: [{ invalid_value: 'invalid value' }], }).error.message ).toEqual( - 'child "lists" fails because ["lists" at position 0 fails because [child "field" fails because ["field" is required]]]' + 'child "exceptions_list" fails because ["exceptions_list" at position 0 fails because [child "field" fails because ["field" is required]]]' ); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent lists] does validate with empty lists', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent exceptions_list] does validate with empty exceptions_list', () => { expect( - patchRulesSchema.validate>>({ + patchRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1353,7 +1355,7 @@ describe('patch rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - }).value.lists + }).value.exceptions_list ).toEqual([]); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.ts similarity index 93% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.ts index 52aefa29884c3..503bc64df237c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/patch_rules_schema.ts @@ -78,5 +78,5 @@ export const patchRulesSchema = Joi.object({ version, // TODO: (LIST-FEATURE) Remove the hasListsFeatures once this is ready for release - lists: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), + exceptions_list: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), }).xor('id', 'rule_id'); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_bulk_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_bulk_schema.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_bulk_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_bulk_schema.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_bulk_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_bulk_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_bulk_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_bulk_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_schema.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_schema.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_rules_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_signals_index_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_signals_index_schema.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_signals_index_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_signals_index_schema.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_signals_index_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_signals_index_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/query_signals_index_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/query_signals_index_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/__mocks__/utils.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/__mocks__/utils.ts similarity index 77% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/__mocks__/utils.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/__mocks__/utils.ts index d5ea950d163f5..fef6bcf42e49f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/__mocks__/utils.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/__mocks__/utils.ts @@ -4,32 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import * as t from 'io-ts'; -import { fold } from 'fp-ts/lib/Either'; import { RulesSchema } from '../rules_schema'; import { RulesBulkSchema } from '../rules_bulk_schema'; import { ErrorSchema } from '../error_schema'; import { FindRulesSchema } from '../find_rules_schema'; -import { formatErrors } from '../utils'; -import { pipe } from 'fp-ts/lib/pipeable'; - -interface Message { - errors: t.Errors; - schema: T | {}; -} - -const onLeft = (errors: t.Errors): Message => { - return { schema: {}, errors }; -}; - -const onRight = (schema: T): Message => { - return { - schema, - errors: [], - }; -}; - -export const foldLeftRight = fold(onLeft, onRight); export const ANCHOR_DATE = '2020-02-20T03:57:54.037Z'; @@ -63,7 +41,7 @@ export const getBaseResponsePayload = (anchorDate: string = ANCHOR_DATE): RulesS language: 'kuery', rule_id: 'query-rule-id', interval: '5m', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -127,18 +105,3 @@ export const getFindResponseSingle = (): FindRulesSchema => ({ total: 1, data: [getBaseResponsePayload()], }); - -/** - * Convenience utility to keep the error message handling within tests to be - * very concise. - * @param validation The validation to get the errors from - */ -export const getPaths =
(validation: t.Validation): string[] => { - return pipe( - validation, - fold( - errors => formatErrors(errors), - () => ['no errors'] - ) - ); -}; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.test.ts index 0eda2a7a13d96..fbd2382e2826d 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.test.ts @@ -15,17 +15,13 @@ import { addQueryFields, addMlFields, } from './check_type_dependents'; -import { - foldLeftRight, - getBaseResponsePayload, - getPaths, - getMlRuleResponsePayload, -} from './__mocks__/utils'; +import { getBaseResponsePayload, getMlRuleResponsePayload } from './__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; -import { exactCheck } from './exact_check'; import { RulesSchema } from './rules_schema'; import { TypeAndTimelineOnly } from './type_timeline_only_schema'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; +import { exactCheck } from '../../../../../utils/build_validation/exact_check'; describe('check_type_dependents', () => { beforeAll(() => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/check_type_dependents.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.test.ts similarity index 91% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.test.ts index 11d8b85f25920..6e159a792edb6 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.test.ts @@ -7,10 +7,11 @@ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; -import { exactCheck } from './exact_check'; -import { foldLeftRight, getErrorPayload, getPaths } from './__mocks__/utils'; +import { getErrorPayload } from './__mocks__/utils'; import { errorSchema, ErrorSchema } from './error_schema'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { exactCheck } from '../../../../../utils/build_validation/exact_check'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('error_schema', () => { beforeAll(() => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/error_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.test.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.test.ts index f5c1970ee8c55..68b67db595d76 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.test.ts @@ -5,17 +5,13 @@ */ import { findRulesSchema, FindRulesSchema } from './find_rules_schema'; -import { exactCheck } from './exact_check'; import { pipe } from 'fp-ts/lib/pipeable'; -import { - foldLeftRight, - getFindResponseSingle, - getBaseResponsePayload, - getPaths, -} from './__mocks__/utils'; +import { getFindResponseSingle, getBaseResponsePayload } from './__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; import { RulesSchema } from './rules_schema'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { getPaths, foldLeftRight } from '../../../../../utils/build_validation/__mocks__/utils'; +import { exactCheck } from '../../../../../utils/build_validation/exact_check'; describe('find_rules_schema', () => { beforeAll(() => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/find_rules_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.test.ts similarity index 86% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.test.ts index ce4bbf420a634..b0b863ebbbc0b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.test.ts @@ -4,13 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { exactCheck } from './exact_check'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from './__mocks__/utils'; -import { left } from 'fp-ts/lib/Either'; +import { left, Either } from 'fp-ts/lib/Either'; import { ImportRulesSchema, importRulesSchema } from './import_rules_schema'; import { ErrorSchema } from './error_schema'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { exactCheck } from '../../../../../utils/build_validation/exact_check'; +import { getPaths, foldLeftRight } from '../../../../../utils/build_validation/__mocks__/utils'; +import { Errors } from 'io-ts'; describe('import_rules_schema', () => { beforeAll(() => { @@ -79,13 +80,31 @@ describe('import_rules_schema', () => { }); test('it should NOT validate a success that is not a boolean', () => { + type UnsafeCastForTest = Either< + Errors, + { + success: string; + success_count: number; + errors: Array< + { + id?: string | undefined; + rule_id?: string | undefined; + } & { + error: { + status_code: number; + message: string; + }; + } + >; + } + >; const payload: Omit & { success: string } = { success: 'hello', success_count: 0, errors: [], }; const decoded = importRulesSchema.decode(payload); - const checked = exactCheck(payload, decoded); + const checked = exactCheck(payload, decoded as UnsafeCastForTest); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual(['Invalid value "hello" supplied to "success"']); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/import_rules_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.test.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.test.ts index 46667826416e1..827167c63fd58 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.test.ts @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ -import { exactCheck } from './exact_check'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from './__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; import { PrePackagedRulesSchema, prePackagedRulesSchema } from './prepackaged_rules_schema'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { exactCheck } from '../../../../../utils/build_validation/exact_check'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('prepackaged_rules_schema', () => { beforeAll(() => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.test.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.test.ts index 1c270ff402f75..a864667583c0a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.test.ts @@ -4,15 +4,15 @@ * you may not use this file except in compliance with the Elastic License. */ -import { exactCheck } from './exact_check'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from './__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; import { PrePackagedRulesStatusSchema, prePackagedRulesStatusSchema, } from './prepackaged_rules_status_schema'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { exactCheck } from '../../../../../utils/build_validation/exact_check'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('prepackaged_rules_schema', () => { beforeAll(() => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/prepackaged_rules_status_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.test.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.test.ts index 8dc97d727c4d1..9a7cf5e2c2871 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.test.ts @@ -7,17 +7,13 @@ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; -import { exactCheck } from './exact_check'; -import { - foldLeftRight, - getBaseResponsePayload, - getErrorPayload, - getPaths, -} from './__mocks__/utils'; +import { getBaseResponsePayload, getErrorPayload } from './__mocks__/utils'; import { RulesBulkSchema, rulesBulkSchema } from './rules_bulk_schema'; import { RulesSchema } from './rules_schema'; import { ErrorSchema } from './error_schema'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { exactCheck } from '../../../../../utils/build_validation/exact_check'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('prepackaged_rule_schema', () => { beforeAll(() => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_bulk_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.test.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.test.ts index fb9ff2c28dc44..82a6682e6461f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.test.ts @@ -7,10 +7,11 @@ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; -import { exactCheck } from './exact_check'; import { rulesSchema, RulesSchema, removeList } from './rules_schema'; -import { foldLeftRight, getBaseResponsePayload, getPaths } from './__mocks__/utils'; +import { getBaseResponsePayload } from './__mocks__/utils'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { exactCheck } from '../../../../../utils/build_validation/exact_check'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; export const ANCHOR_DATE = '2020-02-20T03:57:54.037Z'; @@ -207,7 +208,7 @@ describe('rules_schema', () => { }); // TODO: (LIST-FEATURE) Remove this test once the feature flag is deployed - test('it should remove lists when we need it to be removed because the feature is off but there exists a list in the data', () => { + test('it should remove exceptions_list when we need it to be removed because the feature is off but there exists a list in the data', () => { const payload = getBaseResponsePayload(); const decoded = rulesSchema.decode(payload); const listRemoved = removeList(decoded); @@ -246,9 +247,9 @@ describe('rules_schema', () => { }); }); - test('it should work with lists that are not there and not cause invalidation or errors', () => { + test('it should work with exceptions_list that are not there and not cause invalidation or errors', () => { const payload = getBaseResponsePayload(); - const { lists, ...payloadWithoutLists } = payload; + const { exceptions_list, ...payloadWithoutLists } = payload; const decoded = rulesSchema.decode(payloadWithoutLists); const listRemoved = removeList(decoded); const message = pipe(listRemoved, foldLeftRight); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.ts index 1574e8f5aa6e1..fb1ee8e670e31 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/rules_schema.ts @@ -87,7 +87,7 @@ export const requiredRulesSchema = t.type({ updated_at, created_by, version, - lists: ListsDefaultArray, + exceptions_list: ListsDefaultArray, }); export type RequiredRulesSchema = t.TypeOf; @@ -172,7 +172,7 @@ export const removeList = ( ): Either => { const onLeft = (errors: t.Errors): Either => left(errors); const onRight = (decodedValue: RequiredRulesSchema): Either => { - delete decodedValue.lists; + delete decodedValue.exceptions_list; return right(decodedValue); }; const folded = fold(onLeft, onRight); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/schemas.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/schemas.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/schemas.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/schemas.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.test.ts similarity index 93% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.test.ts index 68a3c8b303823..85fb124464487 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.test.ts @@ -7,10 +7,10 @@ import { left } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; -import { exactCheck } from './exact_check'; -import { foldLeftRight, getPaths } from './__mocks__/utils'; import { TypeAndTimelineOnly, typeAndTimelineOnlySchema } from './type_timeline_only_schema'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { exactCheck } from '../../../../../utils/build_validation/exact_check'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('prepackaged_rule_schema', () => { beforeAll(() => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/response/type_timeline_only_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/schemas.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/schemas.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/schemas.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/schemas.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/set_signal_status_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/set_signal_status_schema.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/set_signal_status_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/set_signal_status_schema.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/set_signal_status_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/set_signal_status_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/set_signal_status_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/set_signal_status_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.test.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.test.ts index fbafaf7f52ecb..ff62ea4443f3f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.test.ts @@ -6,8 +6,8 @@ import { IsoDateString } from './iso_date_string'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from '../response/__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('ios_date_string', () => { test('it should validate a iso string', () => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/iso_date_string.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.test.ts index e8a9c7b0886a1..2a97c8a4a143e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.test.ts @@ -6,8 +6,8 @@ import { ListsDefaultArray } from './lists_default_array'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from '../response/__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('lists_default_array', () => { test('it should validate an empty array', () => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.ts similarity index 74% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.ts index 85a38e296494a..743914ad070a2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/lists_default_array.ts @@ -7,10 +7,16 @@ import * as t from 'io-ts'; import { Either } from 'fp-ts/lib/Either'; -import { list_and as listAnd } from '../response/schemas'; +import { + list_and as listAnd, + list_values as listValues, + list_values_operator as listOperator, +} from '../response/schemas'; export type ListsDefaultArrayC = t.Type; -type List = t.TypeOf; +export type List = t.TypeOf; +export type ListValues = t.TypeOf; +export type ListOperator = t.TypeOf; /** * Types the ListsDefaultArray as: diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.test.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.test.ts index bc17303f24203..d6f21681df88f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.test.ts @@ -6,8 +6,8 @@ import { PositiveIntegerGreaterThanZero } from './positive_integer_greater_than_zero'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from '../response/__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('positive_integer_greater_than_zero', () => { test('it should validate a positive number', () => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/positive_integer_greater_than_zero.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/postive_integer.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/postive_integer.test.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/postive_integer.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/postive_integer.test.ts index cee451279663a..26441745a7f29 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/postive_integer.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/postive_integer.test.ts @@ -6,8 +6,8 @@ import { PositiveInteger } from './positive_integer'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from '../response/__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('positive_integer_greater_than_zero', () => { test('it should validate a positive number', () => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.test.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.test.ts index 3ae8415b4f170..76f722274ce23 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.test.ts @@ -6,8 +6,8 @@ import { ReferencesDefaultArray } from './references_default_array'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from '../response/__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('references_default_array', () => { test('it should validate an empty array', () => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/references_default_array.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.test.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.test.ts index ab3f80944489f..76e3445358dd9 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.test.ts @@ -6,8 +6,8 @@ import { RiskScore } from './risk_score'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from '../response/__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('risk_score', () => { test('it should validate a positive number', () => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/risk_score.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.test.ts similarity index 93% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.test.ts index 342e6f2db2e16..7b68dbcef2d7e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.test.ts @@ -6,8 +6,8 @@ import { UUID } from './uuid'; import { pipe } from 'fp-ts/lib/pipeable'; -import { foldLeftRight, getPaths } from '../response/__mocks__/utils'; import { left } from 'fp-ts/lib/Either'; +import { foldLeftRight, getPaths } from '../../../../../utils/build_validation/__mocks__/utils'; describe('uuid', () => { test('it should validate a uuid', () => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/types/uuid.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_bulk_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_bulk_schema.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_bulk_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_bulk_schema.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_bulk_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_bulk_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_bulk_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_bulk_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.test.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.test.ts index e8f9aad620ca0..b89df0fc0f3ab 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertAction } from '../../../../../../../../plugins/alerting/common'; +import { AlertAction } from '../../../../../../alerting/common'; import { updateRulesSchema } from './update_rules_schema'; import { PatchRuleAlertParamsRest } from '../../rules/types'; import { RuleAlertAction } from '../../../../../common/detection_engine/types'; @@ -575,7 +575,9 @@ describe('create rules schema', () => { test('language does not validate with something made up', () => { expect( - updateRulesSchema.validate>({ + updateRulesSchema.validate< + Partial & { language: string }> + >({ rule_id: 'rule-1', output_index: '.siem-signals', risk_score: 50, @@ -1534,8 +1536,8 @@ describe('create rules schema', () => { // on demand. Since they are per module, we have a an issue where the ENV variables do not take effect. It is better we change all the // schema's to be function calls to avoid global side effects or just wait until the feature is available. If you want to test this early, // you can remove the .skip and set your env variable of export ELASTIC_XPACK_SIEM_LISTS_FEATURE=true locally - describe.skip('lists', () => { - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and lists] does validate', () => { + describe.skip('exceptions_list', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and exceptions_list] does validate', () => { expect( updateRulesSchema.validate>({ rule_id: 'rule-1', @@ -1549,7 +1551,7 @@ describe('create rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -1582,7 +1584,7 @@ describe('create rules schema', () => { ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty lists] does validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and empty exceptions_list] does validate', () => { expect( updateRulesSchema.validate>({ rule_id: 'rule-1', @@ -1596,14 +1598,14 @@ describe('create rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [], + exceptions_list: [], }).error ).toBeFalsy(); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid lists] does NOT validate', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and invalid exceptions_list] does NOT validate', () => { expect( - updateRulesSchema.validate>>({ + updateRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1615,16 +1617,16 @@ describe('create rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - lists: [{ invalid_value: 'invalid value' }], + exceptions_list: [{ invalid_value: 'invalid value' }], }).error.message ).toEqual( - 'child "lists" fails because ["lists" at position 0 fails because [child "field" fails because ["field" is required]]]' + 'child "exceptions_list" fails because ["exceptions_list" at position 0 fails because [child "field" fails because ["field" is required]]]' ); }); - test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent lists] does validate with empty lists', () => { + test('[rule_id, description, from, to, index, name, severity, interval, type, filter, risk_score, note, and non-existent exceptions_list] does validate with empty exceptions_list', () => { expect( - updateRulesSchema.validate>>({ + updateRulesSchema.validate>>({ rule_id: 'rule-1', description: 'some description', from: 'now-5m', @@ -1636,7 +1638,7 @@ describe('create rules schema', () => { type: 'query', risk_score: 50, note: '# some markdown', - }).value.lists + }).value.exceptions_list ).toEqual([]); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.ts index f842c14f41ae6..b1b37801b644f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/schemas/update_rules_schema.ts @@ -107,5 +107,5 @@ export const updateRulesSchema = Joi.object({ version, // TODO: (LIST-FEATURE) Remove the hasListsFeatures once this is ready for release - lists: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), + exceptions_list: hasListsFeature() ? lists.default([]) : lists.forbidden().default([]), }).xor('id', 'rule_id'); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts index 2daf63c468593..c71761fcc39db 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/signals/open_close_signals_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_SIGNALS_STATUS_URL } from '../../../../../common/constants'; import { SignalsStatusRestParams } from '../../signals/types'; import { setSignalsStatusSchema } from '../schemas/set_signal_status_schema'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.ts index f05f494619b9c..fd02b3371ed38 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/signals/query_signals_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_QUERY_SIGNALS_URL } from '../../../../../common/constants'; import { SignalsQueryRestParams } from '../../signals/types'; import { querySignalsSchema } from '../schemas/query_signals_index_schema'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/tags/read_tags_route.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/tags/read_tags_route.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/tags/read_tags_route.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/tags/read_tags_route.ts index adabc62a9456f..2b885385521dd 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/tags/read_tags_route.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/tags/read_tags_route.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../../../../src/core/server'; +import { IRouter } from '../../../../../../../../src/core/server'; import { DETECTION_ENGINE_TAGS_URL } from '../../../../../common/constants'; import { transformError, buildSiemResponse } from '../utils'; import { readTags } from '../../tags/read_tags'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/utils.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/utils.test.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/utils.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/utils.test.ts index 9efe4e491968b..8af5df6056913 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/utils.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/utils.test.ts @@ -23,7 +23,7 @@ import { } from './utils'; import { responseMock } from './__mocks__'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../feature_flags'; -import { licensingMock } from '../../../../../../../plugins/licensing/server/mocks'; +import { licensingMock } from '../../../../../licensing/server/mocks'; describe('utils', () => { beforeAll(() => { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/utils.ts b/x-pack/plugins/siem/server/lib/detection_engine/routes/utils.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/utils.ts rename to x-pack/plugins/siem/server/lib/detection_engine/routes/utils.ts index e4015ad8bafa4..52493a9be9b8f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/utils.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/routes/utils.ts @@ -13,8 +13,8 @@ import { RouteValidationFunction, KibanaResponseFactory, CustomHttpResponseOptions, -} from '../../../../../../../../src/core/server'; -import { ILicense } from '../../../../../../../plugins/licensing/server'; +} from '../../../../../../../src/core/server'; +import { ILicense } from '../../../../../licensing/server'; import { MINIMUM_ML_LICENSE } from '../../../../common/constants'; import { RuleType } from '../../../../common/detection_engine/types'; import { isMlRule } from '../../../../common/detection_engine/ml_helpers'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/create_rule_actions_saved_object.ts b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/create_rule_actions_saved_object.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/create_rule_actions_saved_object.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rule_actions/create_rule_actions_saved_object.ts index 991690d901d8a..26c3b29ff2c51 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/create_rule_actions_saved_object.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/create_rule_actions_saved_object.ts @@ -5,7 +5,7 @@ */ import { RuleAlertAction } from '../../../../common/detection_engine/types'; -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { ruleActionsSavedObjectType } from './saved_object_mappings'; import { IRuleActionsAttributesSavedObjectAttributes } from './types'; import { getThrottleOptions, getRuleActionsFromSavedObject } from './utils'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/delete_rule_actions_saved_object.ts b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/delete_rule_actions_saved_object.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/delete_rule_actions_saved_object.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rule_actions/delete_rule_actions_saved_object.ts index 91489334940bd..251f9155f9331 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/delete_rule_actions_saved_object.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/delete_rule_actions_saved_object.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { ruleActionsSavedObjectType } from './saved_object_mappings'; import { getRuleActionsSavedObject } from './get_rule_actions_saved_object'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/get_rule_actions_saved_object.ts b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/get_rule_actions_saved_object.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/get_rule_actions_saved_object.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rule_actions/get_rule_actions_saved_object.ts index dad35f6cb1f96..83cd59f0a1cde 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/get_rule_actions_saved_object.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/get_rule_actions_saved_object.ts @@ -5,7 +5,7 @@ */ import { RuleAlertAction } from '../../../../common/detection_engine/types'; -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { ruleActionsSavedObjectType } from './saved_object_mappings'; import { IRuleActionsAttributesSavedObjectAttributes } from './types'; import { getRuleActionsFromSavedObject } from './utils'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/saved_object_mappings.ts b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/saved_object_mappings.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/saved_object_mappings.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rule_actions/saved_object_mappings.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/types.ts b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/types.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rule_actions/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/update_or_create_rule_actions_saved_object.ts b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/update_or_create_rule_actions_saved_object.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/update_or_create_rule_actions_saved_object.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rule_actions/update_or_create_rule_actions_saved_object.ts index d79c61f6200e3..3364827d397d2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/update_or_create_rule_actions_saved_object.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/update_or_create_rule_actions_saved_object.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { RuleAlertAction } from '../../../../common/detection_engine/types'; import { getRuleActionsSavedObject } from './get_rule_actions_saved_object'; import { createRuleActionsSavedObject } from './create_rule_actions_saved_object'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/update_rule_actions_saved_object.ts b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/update_rule_actions_saved_object.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/update_rule_actions_saved_object.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rule_actions/update_rule_actions_saved_object.ts index 2a2c84838ed93..c8a3b1bbc38ad 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/update_rule_actions_saved_object.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/update_rule_actions_saved_object.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { ruleActionsSavedObjectType } from './saved_object_mappings'; import { RulesActionsSavedObject } from './get_rule_actions_saved_object'; import { RuleAlertAction } from '../../../../common/detection_engine/types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/utils.ts b/x-pack/plugins/siem/server/lib/detection_engine/rule_actions/utils.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rule_actions/utils.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rule_actions/utils.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/add_tags.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/add_tags.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/add_tags.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/add_tags.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/add_tags.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/add_tags.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/add_tags.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/add_tags.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules.test.ts similarity index 88% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules.test.ts index a60f1d4177978..6710bf02aeb2b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules.test.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; -import { actionsClientMock } from '../../../../../../../plugins/actions/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; +import { actionsClientMock } from '../../../../../actions/server/mocks'; import { getMlResult } from '../routes/__mocks__/request_responses'; import { createRules } from './create_rules'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules.ts similarity index 86% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules.ts index 91effb4741b8b..a007fe35b407e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules.ts @@ -5,7 +5,7 @@ */ import { transformRuleToAlertAction } from '../../../../common/detection_engine/transform_actions'; -import { Alert } from '../../../../../../../plugins/alerting/common'; +import { Alert } from '../../../../../alerting/common'; import { APP_ID, SIGNALS_ID } from '../../../../common/constants'; import { CreateRuleParams } from './types'; import { addTags } from './add_tags'; @@ -42,11 +42,11 @@ export const createRules = async ({ references, note, version, - lists, + exceptions_list, actions, }: CreateRuleParams): Promise => { - // TODO: Remove this and use regular lists once the feature is stable for a release - const listsParam = hasListsFeature() ? { lists } : {}; + // TODO: Remove this and use regular exceptions_list once the feature is stable for a release + const exceptionsListParam = hasListsFeature() ? { exceptions_list } : {}; return alertsClient.create({ data: { name, @@ -79,7 +79,7 @@ export const createRules = async ({ references, note, version, - ...listsParam, + ...exceptionsListParam, }, schedule: { interval }, enabled, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts index 695057ccc2f70..8044692ab90b1 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.test.ts @@ -66,7 +66,7 @@ describe('create_rules_stream_from_ndjson', () => { immutable: false, query: '', language: 'kuery', - lists: [], + exceptions_list: [], max_signals: 100, tags: [], threat: [], @@ -92,7 +92,7 @@ describe('create_rules_stream_from_ndjson', () => { immutable: false, query: '', language: 'kuery', - lists: [], + exceptions_list: [], max_signals: 100, tags: [], threat: [], @@ -158,7 +158,7 @@ describe('create_rules_stream_from_ndjson', () => { language: 'kuery', max_signals: 100, tags: [], - lists: [], + exceptions_list: [], threat: [], throttle: null, references: [], @@ -183,7 +183,7 @@ describe('create_rules_stream_from_ndjson', () => { query: '', language: 'kuery', max_signals: 100, - lists: [], + exceptions_list: [], tags: [], threat: [], throttle: null, @@ -230,7 +230,7 @@ describe('create_rules_stream_from_ndjson', () => { query: '', language: 'kuery', max_signals: 100, - lists: [], + exceptions_list: [], tags: [], threat: [], throttle: null, @@ -256,7 +256,7 @@ describe('create_rules_stream_from_ndjson', () => { query: '', language: 'kuery', max_signals: 100, - lists: [], + exceptions_list: [], tags: [], threat: [], throttle: null, @@ -303,7 +303,7 @@ describe('create_rules_stream_from_ndjson', () => { query: '', language: 'kuery', max_signals: 100, - lists: [], + exceptions_list: [], tags: [], threat: [], throttle: null, @@ -330,7 +330,7 @@ describe('create_rules_stream_from_ndjson', () => { query: '', language: 'kuery', max_signals: 100, - lists: [], + exceptions_list: [], tags: [], threat: [], throttle: null, @@ -376,7 +376,7 @@ describe('create_rules_stream_from_ndjson', () => { query: '', language: 'kuery', max_signals: 100, - lists: [], + exceptions_list: [], tags: [], threat: [], throttle: null, @@ -405,7 +405,7 @@ describe('create_rules_stream_from_ndjson', () => { query: '', language: 'kuery', max_signals: 100, - lists: [], + exceptions_list: [], tags: [], threat: [], throttle: null, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts index 27008d17d2192..034813b8d100d 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/create_rules_stream_from_ndjson.ts @@ -9,7 +9,7 @@ import { createSplitStream, createMapStream, createConcatStream, -} from '../../../../../../../../src/legacy/utils/streams'; +} from '../../../../../../../src/legacy/utils/streams'; import { importRulesSchema } from '../routes/schemas/import_rules_schema'; import { BadRequestError } from '../errors/bad_request_error'; import { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/delete_rules.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/delete_rules.test.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/delete_rules.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/delete_rules.test.ts index 38fc1dc5d1930..68d01356a333a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/delete_rules.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/delete_rules.test.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { actionsClientMock } from '../../../../../../../plugins/actions/server/mocks'; -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { actionsClientMock } from '../../../../../actions/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { deleteRules } from './delete_rules'; import { readRules } from './read_rules'; jest.mock('./read_rules'); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/delete_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/delete_rules.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/delete_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/delete_rules.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/find_rules.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/find_rules.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/find_rules.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/find_rules.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/find_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/find_rules.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/find_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/find_rules.ts index f333a7c340705..ac600b0b5b218 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/find_rules.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/find_rules.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { FindResult } from '../../../../../../../plugins/alerting/server'; +import { FindResult } from '../../../../../alerting/server'; import { SIGNALS_ID } from '../../../../common/constants'; import { FindRuleParams } from './types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.test.ts index 9774d10a37d6f..d79b428a2f76d 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { getResult, getFindResultWithSingleHit, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.ts index b5e826ed42723..512164fc3d2e1 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_existing_prepackaged_rules.ts @@ -5,7 +5,7 @@ */ import { INTERNAL_IMMUTABLE_KEY } from '../../../../common/constants'; -import { AlertsClient } from '../../../../../../../plugins/alerting/server'; +import { AlertsClient } from '../../../../../alerting/server'; import { RuleAlertType, isAlertTypes } from './types'; import { findRules } from './find_rules'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_all.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_all.test.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_all.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_all.test.ts index dd004e3685b1d..6df250f1cf513 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_all.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_all.test.ts @@ -9,7 +9,7 @@ import { getFindResultWithSingleHit, FindHit, } from '../routes/__mocks__/request_responses'; -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { getExportAll } from './get_export_all'; import { unSetFeatureFlagsForTestsOnly, setFeatureFlagsForTestsOnly } from '../feature_flags'; @@ -79,7 +79,7 @@ describe('getExportAll', () => { throttle: 'no_actions', note: '# Investigative notes', version: 1, - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_all.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_all.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_all.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_all.ts index 40c07f28ea848..06e70f0bad184 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_all.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_all.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertsClient } from '../../../../../../../plugins/alerting/server'; +import { AlertsClient } from '../../../../../alerting/server'; import { getNonPackagedRules } from './get_existing_prepackaged_rules'; import { getExportDetailsNdjson } from './get_export_details_ndjson'; import { transformAlertsToRules } from '../routes/rules/utils'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.test.ts index 715cb23e8444a..092a9a8faf395 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.test.ts @@ -11,7 +11,7 @@ import { FindHit, } from '../routes/__mocks__/request_responses'; import * as readRules from './read_rules'; -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../feature_flags'; describe('get_export_by_object_ids', () => { @@ -87,7 +87,7 @@ describe('get_export_by_object_ids', () => { throttle: 'no_actions', note: '# Investigative notes', version: 1, - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -215,7 +215,7 @@ describe('get_export_by_object_ids', () => { throttle: 'no_actions', note: '# Investigative notes', version: 1, - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.ts index 048f09e95b062..02039b9de3c7a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_by_object_ids.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertsClient } from '../../../../../../../plugins/alerting/server'; +import { AlertsClient } from '../../../../../alerting/server'; import { getExportDetailsNdjson } from './get_export_details_ndjson'; import { isAlertType } from '../rules/types'; import { readRules } from './read_rules'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_details_ndjson.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_details_ndjson.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_details_ndjson.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_details_ndjson.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_details_ndjson.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_details_ndjson.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_export_details_ndjson.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_export_details_ndjson.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_prepackaged_rules.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_prepackaged_rules.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_prepackaged_rules.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_prepackaged_rules.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_prepackaged_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_prepackaged_rules.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_prepackaged_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_prepackaged_rules.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_rules_to_install.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_rules_to_install.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_rules_to_install.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_rules_to_install.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_rules_to_install.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_rules_to_install.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_rules_to_install.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_rules_to_install.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_rules_to_update.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_rules_to_update.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_rules_to_update.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_rules_to_update.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_rules_to_update.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/get_rules_to_update.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/get_rules_to_update.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/get_rules_to_update.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts similarity index 88% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts index 6d4bacb9cc243..3d3ed52b2feb2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/install_prepacked_rules.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Alert } from '../../../../../../../plugins/alerting/common'; -import { ActionsClient } from '../../../../../../../plugins/actions/server'; -import { AlertsClient } from '../../../../../../../plugins/alerting/server'; +import { Alert } from '../../../../../alerting/common'; +import { ActionsClient } from '../../../../../actions/server'; +import { AlertsClient } from '../../../../../alerting/server'; import { createRules } from './create_rules'; import { PrepackagedRules } from '../types'; @@ -46,7 +46,7 @@ export const installPrepackagedRules = ( references, note, version, - lists, + exceptions_list, } = rule; return [ ...acc, @@ -82,7 +82,7 @@ export const installPrepackagedRules = ( references, note, version, - lists, + exceptions_list, actions: [], // At this time there is no pre-packaged actions }), ]; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/patch_rules.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.test.ts similarity index 91% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/patch_rules.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.test.ts index 3108fc5f3b718..f93b0aceb5e6e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/patch_rules.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.test.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { savedObjectsClientMock } from '../../../../../../../../src/core/server/mocks'; -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; -import { actionsClientMock } from '../../../../../../../plugins/actions/server/mocks'; +import { savedObjectsClientMock } from '../../../../../../../src/core/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; +import { actionsClientMock } from '../../../../../actions/server/mocks'; import { getResult, getMlResult } from '../routes/__mocks__/request_responses'; import { patchRules } from './patch_rules'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts index 5c4889ec5fd68..c23f539b58160 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/patch_rules.ts @@ -5,7 +5,7 @@ */ import { defaults } from 'lodash/fp'; -import { PartialAlert } from '../../../../../../../plugins/alerting/server'; +import { PartialAlert } from '../../../../../alerting/server'; import { readRules } from './read_rules'; import { PatchRuleParams, IRuleSavedAttributesSavedObjectAttributes } from './types'; import { addTags } from './add_tags'; @@ -44,7 +44,7 @@ export const patchRules = async ({ references, note, version, - lists, + exceptions_list, anomalyThreshold, machineLearningJobId, }: PatchRuleParams): Promise => { @@ -78,7 +78,7 @@ export const patchRules = async ({ references, version, note, - lists, + exceptions_list, anomalyThreshold, machineLearningJobId, }); @@ -110,7 +110,7 @@ export const patchRules = async ({ references, note, version: calculatedVersion, - lists, + exceptions_list, anomalyThreshold, machineLearningJobId, } diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/403_response_to_a_post.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/403_response_to_a_post.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/403_response_to_a_post.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/403_response_to_a_post.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/405_response_method_not_allowed.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/405_response_method_not_allowed.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/405_response_method_not_allowed.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/405_response_method_not_allowed.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_adversary_behavior_detected.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_adversary_behavior_detected.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_adversary_behavior_detected.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_adversary_behavior_detected.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_detected.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_detected.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_detected.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_detected.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_prevented.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_prevented.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_prevented.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_dumping_prevented.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_detected.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_detected.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_detected.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_detected.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_prevented.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_prevented.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_prevented.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_cred_manipulation_prevented.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_detected.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_detected.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_detected.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_detected.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_prevented.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_prevented.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_prevented.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_exploit_prevented.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_detected.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_detected.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_detected.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_detected.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_prevented.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_prevented.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_prevented.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_malware_prevented.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_detected.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_detected.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_detected.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_detected.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_prevented.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_prevented.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_prevented.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_permission_theft_prevented.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_detected.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_detected.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_detected.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_detected.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_prevented.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_prevented.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_prevented.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_process_injection_prevented.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_detected.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_detected.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_detected.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_detected.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_prevented.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_prevented.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_prevented.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/elastic_endpoint_security_ransomware_prevented.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adding_the_hidden_file_attribute_with_via_attribexe.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adding_the_hidden_file_attribute_with_via_attribexe.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adding_the_hidden_file_attribute_with_via_attribexe.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adding_the_hidden_file_attribute_with_via_attribexe.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adobe_hijack_persistence.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adobe_hijack_persistence.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adobe_hijack_persistence.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_adobe_hijack_persistence.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_clearing_windows_event_logs.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_clearing_windows_event_logs.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_clearing_windows_event_logs.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_clearing_windows_event_logs.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_delete_volume_usn_journal_with_fsutil.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_delete_volume_usn_journal_with_fsutil.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_delete_volume_usn_journal_with_fsutil.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_delete_volume_usn_journal_with_fsutil.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_deleting_backup_catalogs_with_wbadmin.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_deleting_backup_catalogs_with_wbadmin.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_deleting_backup_catalogs_with_wbadmin.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_deleting_backup_catalogs_with_wbadmin.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_direct_outbound_smb_connection.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_direct_outbound_smb_connection.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_direct_outbound_smb_connection.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_direct_outbound_smb_connection.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_disable_windows_firewall_rules_with_netsh.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_disable_windows_firewall_rules_with_netsh.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_disable_windows_firewall_rules_with_netsh.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_disable_windows_firewall_rules_with_netsh.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_encoding_or_decoding_files_via_certutil.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_encoding_or_decoding_files_via_certutil.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_encoding_or_decoding_files_via_certutil.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_encoding_or_decoding_files_via_certutil.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_scheduled_task_commands.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_scheduled_task_commands.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_scheduled_task_commands.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_scheduled_task_commands.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_service_commands.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_service_commands.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_service_commands.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_local_service_commands.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msbuild_making_network_connections.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msbuild_making_network_connections.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msbuild_making_network_connections.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_msbuild_making_network_connections.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_mshta_making_network_connections.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_mshta_making_network_connections.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_mshta_making_network_connections.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_mshta_making_network_connections.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_psexec_lateral_movement_command.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_psexec_lateral_movement_command.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_psexec_lateral_movement_command.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_psexec_lateral_movement_command.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_office_child_process.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_office_child_process.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_office_child_process.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_office_child_process.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_outlook_child_process.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_outlook_child_process.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_outlook_child_process.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_suspicious_ms_outlook_child_process.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_system_shells_via_services.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_system_shells_via_services.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_system_shells_via_services.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_system_shells_via_services.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_network_connection_via_rundll32.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_network_connection_via_rundll32.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_network_connection_via_rundll32.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_network_connection_via_rundll32.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_parentchild_relationship.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_parentchild_relationship.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_parentchild_relationship.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_parentchild_relationship.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_process_network_connection.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_process_network_connection.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_process_network_connection.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_unusual_process_network_connection.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_account_creation.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_account_creation.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_account_creation.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_user_account_creation.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_vssadmin.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_vssadmin.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_vssadmin.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_vssadmin.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_wmic.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_wmic.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_wmic.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_volume_shadow_copy_deletion_via_wmic.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_windows_script_executing_powershell.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_windows_script_executing_powershell.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_windows_script_executing_powershell.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/eql_windows_script_executing_powershell.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_port_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_port_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_port_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_port_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_service.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_service.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_service.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_service.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_url_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_url_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_url_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_network_url_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_process_all_hosts.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_process_all_hosts.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_process_all_hosts.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_process_all_hosts.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_user_name.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_user_name.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_user_name.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_anomalous_user_name.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_hping_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_hping_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_hping_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_hping_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_iodine_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_iodine_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_iodine_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_iodine_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_kernel_module_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_kernel_module_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_kernel_module_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_kernel_module_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_mknod_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_mknod_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_mknod_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_mknod_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_netcat_network_connection.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_netcat_network_connection.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_netcat_network_connection.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_netcat_network_connection.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nmap_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nmap_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nmap_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nmap_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nping_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nping_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nping_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_nping_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_process_started_in_temp_directory.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_process_started_in_temp_directory.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_process_started_in_temp_directory.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_process_started_in_temp_directory.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_shell_activity_by_web_server.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_shell_activity_by_web_server.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_shell_activity_by_web_server.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_shell_activity_by_web_server.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_socat_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_socat_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_socat_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_socat_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_strace_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_strace_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_strace_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_strace_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_tcpdump_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_tcpdump_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_tcpdump_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_tcpdump_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_whoami_commmand.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_whoami_commmand.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_whoami_commmand.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/linux_whoami_commmand.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_dns_directly_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_dns_directly_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_dns_directly_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_dns_directly_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ftp_file_transfer_protocol_activity_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ftp_file_transfer_protocol_activity_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ftp_file_transfer_protocol_activity_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ftp_file_transfer_protocol_activity_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_irc_internet_relay_chat_protocol_activity_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_irc_internet_relay_chat_protocol_activity_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_irc_internet_relay_chat_protocol_activity_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_irc_internet_relay_chat_protocol_activity_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_nat_traversal_port_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_nat_traversal_port_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_nat_traversal_port_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_nat_traversal_port_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_26_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_26_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_26_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_26_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_8000_activity_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_8000_activity_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_8000_activity_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_port_8000_activity_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_pptp_point_to_point_tunneling_protocol_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_pptp_point_to_point_tunneling_protocol_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_pptp_point_to_point_tunneling_protocol_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_pptp_point_to_point_tunneling_protocol_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_proxy_port_activity_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_proxy_port_activity_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_proxy_port_activity_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_proxy_port_activity_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_from_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_from_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_from_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_from_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rdp_remote_desktop_protocol_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_from_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_from_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_from_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_from_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_rpc_remote_procedure_call_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smb_windows_file_sharing_activity_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smb_windows_file_sharing_activity_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smb_windows_file_sharing_activity_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smb_windows_file_sharing_activity_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smtp_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smtp_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smtp_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_smtp_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_sql_server_port_activity_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_sql_server_port_activity_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_sql_server_port_activity_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_sql_server_port_activity_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_from_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_from_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_from_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_from_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_ssh_secure_shell_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_telnet_port_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_telnet_port_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_telnet_port_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_telnet_port_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_tor_activity_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_tor_activity_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_tor_activity_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_tor_activity_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_from_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_from_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_from_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_from_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/network_vnc_virtual_network_computing_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/notice.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/null_user_agent.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/null_user_agent.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/null_user_agent.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/null_user_agent.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_dns_tunneling.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_dns_tunneling.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_dns_tunneling.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_dns_tunneling.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_dns_question.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_dns_question.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_dns_question.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_dns_question.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_server_domain.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_server_domain.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_server_domain.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_server_domain.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_urls.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_urls.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_urls.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_urls.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_user_agent.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_user_agent.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_user_agent.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/packetbeat_rare_user_agent.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/rare_process_by_host_linux.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/rare_process_by_host_linux.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/rare_process_by_host_linux.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/rare_process_by_host_linux.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/rare_process_by_host_windows.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/rare_process_by_host_windows.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/rare_process_by_host_windows.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/rare_process_by_host_windows.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/sqlmap_user_agent.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/sqlmap_user_agent.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/sqlmap_user_agent.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/sqlmap_user_agent.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/suspicious_login_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/suspicious_login_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/suspicious_login_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/suspicious_login_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_network_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_network_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_network_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_network_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_path_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_path_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_path_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_path_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_process_all_hosts.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_process_all_hosts.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_process_all_hosts.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_process_all_hosts.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_process_creation.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_process_creation.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_process_creation.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_process_creation.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_script.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_script.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_script.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_script.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_service.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_service.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_service.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_service.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_user_name.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_user_name.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_user_name.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_anomalous_user_name.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_certutil_network_connection.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_certutil_network_connection.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_certutil_network_connection.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_certutil_network_connection.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_prompt_connecting_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_prompt_connecting_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_prompt_connecting_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_prompt_connecting_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_powershell.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_powershell.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_powershell.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_powershell.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_svchost.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_svchost.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_svchost.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_command_shell_started_by_svchost.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_credential_dumping_msbuild.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_credential_dumping_msbuild.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_credential_dumping_msbuild.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_credential_dumping_msbuild.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_cve_2020_0601.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_cve_2020_0601.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_cve_2020_0601.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_cve_2020_0601.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_defense_evasion_via_filter_manager.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_defense_evasion_via_filter_manager.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_defense_evasion_via_filter_manager.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_defense_evasion_via_filter_manager.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_office_app.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_office_app.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_office_app.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_office_app.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_script.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_script.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_script.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_script.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_system_process.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_system_process.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_system_process.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_by_system_process.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_renamed.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_renamed.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_renamed.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_renamed.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_unusal_process.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_unusal_process.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_unusal_process.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_msbuild_started_unusal_process.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_compiled_html_file.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_compiled_html_file.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_compiled_html_file.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_compiled_html_file.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_net_com_assemblies.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_net_com_assemblies.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_net_com_assemblies.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_net_com_assemblies.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_regsvr32.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_regsvr32.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_regsvr32.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_regsvr32.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_trusted_developer_utilities.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_trusted_developer_utilities.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_trusted_developer_utilities.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_execution_via_trusted_developer_utilities.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_html_help_executable_program_connecting_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_html_help_executable_program_connecting_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_html_help_executable_program_connecting_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_html_help_executable_program_connecting_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_injection_msbuild.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_injection_msbuild.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_injection_msbuild.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_injection_msbuild.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_misc_lolbin_connecting_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_misc_lolbin_connecting_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_misc_lolbin_connecting_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_misc_lolbin_connecting_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_modification_of_boot_config.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_modification_of_boot_config.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_modification_of_boot_config.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_modification_of_boot_config.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_msxsl_network.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_msxsl_network.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_msxsl_network.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_msxsl_network.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_net_command_system_account.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_net_command_system_account.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_net_command_system_account.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_net_command_system_account.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_persistence_via_application_shimming.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_persistence_via_application_shimming.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_persistence_via_application_shimming.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_persistence_via_application_shimming.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_priv_escalation_via_accessibility_features.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_priv_escalation_via_accessibility_features.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_priv_escalation_via_accessibility_features.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_priv_escalation_via_accessibility_features.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_discovery_via_tasklist_command.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_discovery_via_tasklist_command.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_discovery_via_tasklist_command.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_process_discovery_via_tasklist_command.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_rare_user_runas_event.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_rare_user_runas_event.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_rare_user_runas_event.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_rare_user_runas_event.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_rare_user_type10_remote_login.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_rare_user_type10_remote_login.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_rare_user_type10_remote_login.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_rare_user_type10_remote_login.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_register_server_program_connecting_to_the_internet.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_register_server_program_connecting_to_the_internet.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_register_server_program_connecting_to_the_internet.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_register_server_program_connecting_to_the_internet.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_signed_binary_proxy_execution.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_pdf_reader.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_pdf_reader.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_pdf_reader.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_pdf_reader.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_process_started_by_a_script.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_process_started_by_a_script.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_process_started_by_a_script.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_suspicious_process_started_by_a_script.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_uac_bypass_event_viewer.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_uac_bypass_event_viewer.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_uac_bypass_event_viewer.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_uac_bypass_event_viewer.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_whoami_command_activity.json b/x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_whoami_command_activity.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_whoami_command_activity.json rename to x-pack/plugins/siem/server/lib/detection_engine/rules/prepackaged_rules/windows_whoami_command_activity.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/read_rules.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/read_rules.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/read_rules.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/read_rules.test.ts index 38a883329318b..600848948be0c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/read_rules.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/read_rules.test.ts @@ -5,7 +5,7 @@ */ import { readRules } from './read_rules'; -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { getResult, getFindResultWithSingleHit } from '../routes/__mocks__/request_responses'; export class TestError extends Error { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/read_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/read_rules.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/read_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/read_rules.ts index 94e4e6357a4a0..9e0d5b3d05b3f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/read_rules.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/read_rules.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SanitizedAlert } from '../../../../../../../plugins/alerting/common'; +import { SanitizedAlert } from '../../../../../alerting/common'; import { INTERNAL_RULE_ID_KEY } from '../../../../common/constants'; import { findRules } from './find_rules'; import { ReadRuleParams, isAlertType } from './types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/saved_object_mappings.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/saved_object_mappings.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/saved_object_mappings.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/saved_object_mappings.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/types.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/types.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/types.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/types.ts index b1bed5d716155..6fde199e0ba7d 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/types.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/types.ts @@ -13,10 +13,10 @@ import { SavedObjectsFindResponse, SavedObjectsClientContract, } from 'kibana/server'; -import { AlertsClient, PartialAlert } from '../../../../../../../plugins/alerting/server'; -import { Alert } from '../../../../../../../plugins/alerting/common'; +import { AlertsClient, PartialAlert } from '../../../../../alerting/server'; +import { Alert } from '../../../../../alerting/common'; import { SIGNALS_ID } from '../../../../common/constants'; -import { ActionsClient } from '../../../../../../../plugins/actions/server'; +import { ActionsClient } from '../../../../../actions/server'; import { RuleAlertParams, RuleTypeParams, RuleAlertParamsRest } from '../types'; export type PatchRuleAlertParamsRest = Partial & { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.test.ts similarity index 86% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.test.ts index 7a3f233475117..a9bbf75883d1f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.test.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { savedObjectsClientMock } from '../../../../../../../../src/core/server/mocks'; -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; -import { actionsClientMock } from '../../../../../../../plugins/actions/server/mocks'; +import { savedObjectsClientMock } from '../../../../../../../src/core/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; +import { actionsClientMock } from '../../../../../actions/server/mocks'; import { mockPrepackagedRule } from '../routes/__mocks__/request_responses'; import { updatePrepackagedRules } from './update_prepacked_rules'; import { patchRules } from './patch_rules'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.ts index 7eb0d8d1399be..b72b232c27f03 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_prepacked_rules.ts @@ -5,8 +5,8 @@ */ import { SavedObjectsClientContract } from 'kibana/server'; -import { ActionsClient } from '../../../../../../../plugins/actions/server'; -import { AlertsClient } from '../../../../../../../plugins/alerting/server'; +import { ActionsClient } from '../../../../../actions/server'; +import { AlertsClient } from '../../../../../alerting/server'; import { patchRules } from './patch_rules'; import { PrepackagedRules } from '../types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_rules.test.ts similarity index 91% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/update_rules.test.ts index 72f4cbcbe68e8..2565d269db478 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_rules.test.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { savedObjectsClientMock } from '../../../../../../../../src/core/server/mocks'; -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; -import { actionsClientMock } from '../../../../../../../plugins/actions/server/mocks'; +import { savedObjectsClientMock } from '../../../../../../../src/core/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; +import { actionsClientMock } from '../../../../../actions/server/mocks'; import { getResult, getMlResult } from '../routes/__mocks__/request_responses'; import { updateRules } from './update_rules'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_rules.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/update_rules.ts index 99326768ed33b..7ddbbd76b0661 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_rules.ts @@ -5,7 +5,7 @@ */ import { transformRuleToAlertAction } from '../../../../common/detection_engine/transform_actions'; -import { PartialAlert } from '../../../../../../../plugins/alerting/server'; +import { PartialAlert } from '../../../../../alerting/server'; import { readRules } from './read_rules'; import { IRuleSavedAttributesSavedObjectAttributes, UpdateRuleParams } from './types'; import { addTags } from './add_tags'; @@ -44,7 +44,7 @@ export const updateRules = async ({ references, version, note, - lists, + exceptions_list, anomalyThreshold, machineLearningJobId, actions, @@ -83,8 +83,8 @@ export const updateRules = async ({ machineLearningJobId, }); - // TODO: Remove this and use regular lists once the feature is stable for a release - const listsParam = hasListsFeature() ? { lists } : {}; + // TODO: Remove this and use regular exceptions_list once the feature is stable for a release + const exceptionsListParam = hasListsFeature() ? { exceptions_list } : {}; const update = await alertsClient.update({ id: rule.id, @@ -120,7 +120,7 @@ export const updateRules = async ({ version: calculatedVersion, anomalyThreshold, machineLearningJobId, - ...listsParam, + ...exceptionsListParam, }, }, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules_notifications.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_rules_notifications.ts similarity index 93% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules_notifications.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/update_rules_notifications.ts index 994a54048b71a..ddcd34b18cae9 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/update_rules_notifications.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/rules/update_rules_notifications.ts @@ -5,7 +5,7 @@ */ import { RuleAlertAction } from '../../../../common/detection_engine/types'; -import { AlertsClient, AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertsClient, AlertServices } from '../../../../../alerting/server'; import { updateOrCreateRuleActionsSavedObject } from '../rule_actions/update_or_create_rule_actions_saved_object'; import { updateNotifications } from '../notifications/update_notifications'; import { RuleActions } from '../rule_actions/types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/utils.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/utils.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/utils.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/utils.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/utils.ts b/x-pack/plugins/siem/server/lib/detection_engine/rules/utils.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/rules/utils.ts rename to x-pack/plugins/siem/server/lib/detection_engine/rules/utils.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/add_prepackaged_rules.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/add_prepackaged_rules.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/add_prepackaged_rules.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/add_prepackaged_rules.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/check_env_variables.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/check_env_variables.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/check_env_variables.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/check_env_variables.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/convert_saved_search_to_rules.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/convert_saved_search_to_rules.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/convert_saved_search_to_rules.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/convert_saved_search_to_rules.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_actions.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_actions.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_actions.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_actions.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_alert_tasks.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_alert_tasks.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_alert_tasks.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_alert_tasks.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_alerts.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_alerts.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_alerts.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_alerts.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_api_keys.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_api_keys.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_api_keys.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_api_keys.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_statuses.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_statuses.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_all_statuses.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_all_statuses.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_bulk.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_bulk.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_bulk.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_bulk.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_rule_by_id.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_rule_by_id.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_rule_by_id.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_rule_by_id.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_rule_by_rule_id.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_rule_by_rule_id.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_rule_by_rule_id.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_rule_by_rule_id.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_signal_index.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_signal_index.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/delete_signal_index.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/delete_signal_index.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/export_rules.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/export_rules.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/export_rules.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/export_rules.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/export_rules_by_rule_id.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/export_rules_by_rule_id.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/export_rules_by_rule_id.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/export_rules_by_rule_id.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/export_rules_by_rule_id_to_file.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/export_rules_by_rule_id_to_file.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/export_rules_by_rule_id_to_file.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/export_rules_by_rule_id_to_file.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/export_rules_to_file.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/export_rules_to_file.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/export_rules_to_file.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/export_rules_to_file.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_rule_by_filter.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/find_rule_by_filter.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_rule_by_filter.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/find_rule_by_filter.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_rules.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/find_rules.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_rules.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/find_rules.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_rules_sort.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/find_rules_sort.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_rules_sort.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/find_rules_sort.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_rules_statuses_by_ids.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/find_rules_statuses_by_ids.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_rules_statuses_by_ids.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/find_rules_statuses_by_ids.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_saved_object.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/find_saved_object.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/find_saved_object.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/find_saved_object.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_action_instances.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_action_instances.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_action_instances.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_action_instances.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_action_types.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_action_types.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_action_types.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_action_types.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_alert_instances.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_alert_instances.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_alert_instances.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_alert_instances.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_alert_tasks.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_alert_tasks.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_alert_tasks.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_alert_tasks.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_alert_types.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_alert_types.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_alert_types.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_alert_types.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_prepackaged_rules_status.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_prepackaged_rules_status.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_prepackaged_rules_status.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_prepackaged_rules_status.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_privileges.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_privileges.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_privileges.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_privileges.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_rule_by_id.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_rule_by_id.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_rule_by_id.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_rule_by_id.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_rule_by_rule_id.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_rule_by_rule_id.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_rule_by_rule_id.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_rule_by_rule_id.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_saved_objects.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_saved_objects.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_saved_objects.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_saved_objects.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_signal_index.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_signal_index.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_signal_index.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_signal_index.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_tags.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/get_tags.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/get_tags.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/get_tags.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/hard_reset.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/hard_reset.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/hard_reset.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/hard_reset.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/import_rules.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/import_rules.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/import_rules.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/import_rules.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/import_rules_no_overwrite.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/import_rules_no_overwrite.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/import_rules_no_overwrite.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/import_rules_no_overwrite.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/patch_rule.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/patch_rule.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/patch_rule.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/patch_rule.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/patch_rule_bulk.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/patch_rule_bulk.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/patch_rule_bulk.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/patch_rule_bulk.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/post_rule.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/post_rule.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/post_rule.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/post_rule.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/post_rule_bulk.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/post_rule_bulk.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/post_rule_bulk.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/post_rule_bulk.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/post_signal_index.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/post_signal_index.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/post_signal_index.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/post_signal_index.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/post_x_rules.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/post_x_rules.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/post_x_rules.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/post_x_rules.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/regen_prepackge_rules_index.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/regen_prepackge_rules_index.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/regen_prepackge_rules_index.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/regen_prepackge_rules_index.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/delete_by_rule_id.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/delete_by_rule_id.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/delete_by_rule_id.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/delete_by_rule_id.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/multiple_ruleid_queries.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/multiple_ruleid_queries.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/multiple_ruleid_queries.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/multiple_ruleid_queries.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/multiple_simplest_queries.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/multiple_simplest_queries.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/multiple_simplest_queries.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/multiple_simplest_queries.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/patch_names.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/patch_names.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/patch_names.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/bulk/patch_names.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/export/ruleid_queries.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/export/ruleid_queries.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/export/ruleid_queries.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/export/ruleid_queries.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/import/multiple_ruleid_queries.ndjson b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/import/multiple_ruleid_queries.ndjson similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/import/multiple_ruleid_queries.ndjson rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/import/multiple_ruleid_queries.ndjson diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/README.md b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/README.md similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/README.md rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/README.md diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/disable_rule.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/disable_rule.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/disable_rule.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/disable_rule.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/enabled_rule.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/enabled_rule.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/enabled_rule.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/enabled_rule.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_update_risk_score_by_id.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_update_risk_score_by_id.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_update_risk_score_by_id.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_update_risk_score_by_id.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_update_risk_score_by_rule_id.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_update_risk_score_by_rule_id.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_update_risk_score_by_rule_id.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_update_risk_score_by_rule_id.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_updated_name.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_updated_name.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_updated_name.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/simplest_updated_name.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_interval.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_interval.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_interval.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_interval.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_list.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_list.json similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_list.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_list.json index 4db8724db4e13..8d831f3a961d8 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_list.json +++ b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_list.json @@ -1,6 +1,6 @@ { "rule_id": "query-with-list", - "lists": [ + "exceptions_list": [ { "field": "source.ip", "values_operator": "excluded", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_machine_learning.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_machine_learning.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_machine_learning.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_machine_learning.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_note.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_note.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_note.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_note.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_query_everything.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_query_everything.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_query_everything.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_query_everything.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_tags.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_tags.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_tags.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_tags.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_timelineid.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_timelineid.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_timelineid.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_timelineid.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_version.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_version.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_version.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/patches/update_version.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/README.md b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/README.md similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/README.md rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/README.md diff --git a/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_and.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_and.json new file mode 100644 index 0000000000000..1575a712e2cba --- /dev/null +++ b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_and.json @@ -0,0 +1,35 @@ +{ + "name": "List - and", + "description": "Query with a list that includes and. This rule should only produce signals when host.name exists and when both event.module is endgame and event.category is anything other than file", + "rule_id": "query-with-list-and", + "risk_score": 1, + "severity": "high", + "type": "query", + "query": "host.name: *", + "interval": "30s", + "language": "kuery", + "exceptions_list": [ + { + "field": "event.module", + "values_operator": "excluded", + "values_type": "match", + "values": [ + { + "name": "endgame" + } + ], + "and": [ + { + "field": "event.category", + "values_operator": "included", + "values_type": "match", + "values": [ + { + "name": "file" + } + ] + } + ] + } + ] +} diff --git a/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_excluded.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_excluded.json new file mode 100644 index 0000000000000..4e6d9403a276f --- /dev/null +++ b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_excluded.json @@ -0,0 +1,23 @@ +{ + "name": "List - excluded", + "description": "Query with a list of values_operator excluded. This rule should only produce signals when host.name exists and event.module is suricata", + "rule_id": "query-with-list-excluded", + "risk_score": 1, + "severity": "high", + "type": "query", + "query": "host.name: *", + "interval": "30s", + "language": "kuery", + "exceptions_list": [ + { + "field": "event.module", + "values_operator": "excluded", + "values_type": "match", + "values": [ + { + "name": "suricata" + } + ] + } + ] +} diff --git a/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_exists.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_exists.json new file mode 100644 index 0000000000000..97beace37633f --- /dev/null +++ b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_exists.json @@ -0,0 +1,18 @@ +{ + "name": "List - exists", + "description": "Query with a list that includes exists. This rule should only produce signals when host.name exists and event.action does not exist", + "rule_id": "query-with-list-exists", + "risk_score": 1, + "severity": "high", + "type": "query", + "query": "host.name: *", + "interval": "30s", + "language": "kuery", + "exceptions_list": [ + { + "field": "event.action", + "values_operator": "included", + "values_type": "exists" + } + ] +} diff --git a/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_list.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_list.json new file mode 100644 index 0000000000000..ad0585b5a2ec5 --- /dev/null +++ b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_list.json @@ -0,0 +1,54 @@ +{ + "name": "Query with a list", + "description": "Query with a list. This rule should only produce signals when either host.name exists and event.module is system and user.name is zeek or gdm OR when host.name exists and event.module is not endgame or zeek or system.", + "rule_id": "query-with-list", + "risk_score": 2, + "severity": "high", + "type": "query", + "query": "host.name: *", + "interval": "30s", + "language": "kuery", + "exceptions_list": [ + { + "field": "event.module", + "values_operator": "excluded", + "values_type": "match", + "values": [ + { + "name": "system" + } + ], + "and": [ + { + "field": "user.name", + "values_operator": "excluded", + "values_type": "match_all", + "values": [ + { + "name": "zeek" + }, + { + "name": "gdm" + } + ] + } + ] + }, + { + "field": "event.module", + "values_operator": "included", + "values_type": "match_all", + "values": [ + { + "name": "endgame" + }, + { + "name": "zeek" + }, + { + "name": "system" + } + ] + } + ] +} diff --git a/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_match.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_match.json new file mode 100644 index 0000000000000..6e6880cc28f24 --- /dev/null +++ b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_match.json @@ -0,0 +1,23 @@ +{ + "name": "List - match", + "description": "Query with a list that includes match. This rule should only produce signals when host.name exists and event.module is not suricata", + "rule_id": "query-with-list-match", + "risk_score": 1, + "severity": "high", + "type": "query", + "query": "host.name: *", + "interval": "30s", + "language": "kuery", + "exceptions_list": [ + { + "field": "event.module", + "values_operator": "included", + "values_type": "match", + "values": [ + { + "name": "suricata" + } + ] + } + ] +} diff --git a/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_match_all.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_match_all.json new file mode 100644 index 0000000000000..44cc26ac3315e --- /dev/null +++ b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_match_all.json @@ -0,0 +1,26 @@ +{ + "name": "List - match_all", + "description": "Query with a list that includes match_all. This rule should only produce signals when host.name exists and event.module is not suricata or auditd", + "rule_id": "query-with-list-match-all", + "risk_score": 1, + "severity": "high", + "type": "query", + "query": "host.name: *", + "interval": "30s", + "language": "kuery", + "exceptions_list": [ + { + "field": "event.module", + "values_operator": "included", + "values_type": "match_all", + "values": [ + { + "name": "suricata" + }, + { + "name": "auditd" + } + ] + } + ] +} diff --git a/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_or.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_or.json new file mode 100644 index 0000000000000..9c4eda559d5bc --- /dev/null +++ b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/lists/query_with_or.json @@ -0,0 +1,32 @@ +{ + "name": "List - or", + "description": "Query with a list that includes or. This rule should only produce signals when host.name exists and event.module is suricata OR when host.name exists and event.category is file", + "rule_id": "query-with-list-or", + "risk_score": 1, + "severity": "high", + "type": "query", + "query": "host.name: *", + "interval": "30s", + "exceptions_list": [ + { + "field": "event.module", + "values_operator": "excluded", + "values_type": "match", + "values": [ + { + "name": "suricata" + } + ] + }, + { + "field": "event.category", + "values_operator": "excluded", + "values_type": "match", + "values": [ + { + "name": "file" + } + ] + } + ] +} diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_disabled.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_disabled.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_disabled.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_disabled.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_lucene.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_lucene.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_lucene.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_lucene.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_mitre_attack.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_mitre_attack.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_mitre_attack.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_mitre_attack.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_timelineid.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_timelineid.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_timelineid.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_timelineid.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_everything.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_everything.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_everything.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_everything.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_filter.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_filter.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_filter.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_filter.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_machine_learning.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_machine_learning.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_machine_learning.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_machine_learning.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_meta_data.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_meta_data.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_meta_data.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_meta_data.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_note.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_note.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_note.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_note.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_rule_id.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_rule_id.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_rule_id.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_rule_id.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_tags.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_tags.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_tags.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/query_with_tags.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/simplest_filters.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/simplest_filters.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/simplest_filters.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/simplest_filters.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/simplest_query.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/simplest_query.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/queries/simplest_query.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/queries/simplest_query.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/README.md b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/README.md similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/README.md rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/README.md diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_by_rule_id.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_by_rule_id.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_by_rule_id.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_by_rule_id.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_everything.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_everything.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_everything.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_everything.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_filters.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_filters.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_filters.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_filters.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_query.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_query.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_query.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_query.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_query_filter.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_query_filter.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_query_filter.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/saved_query_with_query_filter.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/simplest_saved_query.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/simplest_saved_query.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/simplest_saved_query.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/saved_queries/simplest_saved_query.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/README.md b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/README.md similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/README.md rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/README.md diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/imports/multiple_ruleid_queries_corrupted.ndjson b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/imports/multiple_ruleid_queries_corrupted.ndjson similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/imports/multiple_ruleid_queries_corrupted.ndjson rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/imports/multiple_ruleid_queries_corrupted.ndjson diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/filter_with_empty_query.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/filter_with_empty_query.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/filter_with_empty_query.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/filter_with_empty_query.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/filter_without_query.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/filter_without_query.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/filter_without_query.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/filter_without_query.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_filter_ui_meatadata_lucene.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_filter_ui_meatadata_lucene.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_filter_ui_meatadata_lucene.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_filter_ui_meatadata_lucene.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_filter_ui_metadata.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_filter_ui_metadata.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_filter_ui_metadata.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_filter_ui_metadata.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_with_errors.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_with_errors.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_with_errors.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/query_with_errors.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/saved_query_ui_meta_empty_query.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/saved_query_ui_meta_empty_query.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/saved_query_ui_meta_empty_query.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/queries/saved_query_ui_meta_empty_query.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/README.md b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/README.md similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/README.md rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/README.md diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/query_single_id.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/query_single_id.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/query_single_id.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/query_single_id.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/signal_on_signal_depth_1.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/signal_on_signal_depth_1.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/signal_on_signal_depth_1.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/signal_on_signal_depth_1.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/signal_on_signal_depth_2.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/signal_on_signal_depth_2.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/signal_on_signal_depth_2.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/depth_test/signal_on_signal_depth_2.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/README.md b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/README.md similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/README.md rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/README.md diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/query_single_id.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/query_single_id.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/query_single_id.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/query_single_id.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/signal_on_signal.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/signal_on_signal.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/signal_on_signal.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/test_cases/signals_on_signals/halting_test/signal_on_signal.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/README.md b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/README.md similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/README.md rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/README.md diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/disable_rule.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/disable_rule.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/disable_rule.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/disable_rule.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/enabled_rule.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/enabled_rule.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/enabled_rule.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/enabled_rule.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_update_risk_score_by_id.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_update_risk_score_by_id.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_update_risk_score_by_id.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_update_risk_score_by_id.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_update_risk_score_by_rule_id.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_update_risk_score_by_rule_id.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_update_risk_score_by_rule_id.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_update_risk_score_by_rule_id.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_updated_name.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_updated_name.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_updated_name.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/simplest_updated_name.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_interval.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_interval.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_interval.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_interval.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_list.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_list.json similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_list.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_list.json index 66b198974f574..df22dff5c046e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_list.json +++ b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_list.json @@ -6,7 +6,7 @@ "severity": "high", "type": "query", "query": "user.name: root or user.name: admin", - "lists": [ + "exceptions_list": [ { "field": "source.ip", "values_operator": "excluded", diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_machine_learning.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_machine_learning.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_machine_learning.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_machine_learning.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_note.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_note.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_note.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_note.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_query_everything.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_query_everything.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_query_everything.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_query_everything.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_tags.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_tags.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_tags.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_tags.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_timelineid.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_timelineid.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_timelineid.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_timelineid.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_version.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_version.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_version.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/rules/updates/update_version.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signal_index_exists.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/signal_index_exists.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signal_index_exists.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/signal_index_exists.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/aggs_signals.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/aggs_signals.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/aggs_signals.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/aggs_signals.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/put_signal_doc.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/put_signal_doc.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/put_signal_doc.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/put_signal_doc.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/query_signals.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/query_signals.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/query_signals.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/query_signals.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/sample_signal.json b/x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/sample_signal.json similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/sample_signal.json rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/sample_signal.json diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/set_status_with_id.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/set_status_with_id.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/set_status_with_id.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/set_status_with_id.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/set_status_with_query.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/set_status_with_query.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/signals/set_status_with_query.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/signals/set_status_with_query.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/update_rule.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/update_rule.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/update_rule.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/update_rule.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/update_rule_bulk.sh b/x-pack/plugins/siem/server/lib/detection_engine/scripts/update_rule_bulk.sh similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/scripts/update_rule_bulk.sh rename to x-pack/plugins/siem/server/lib/detection_engine/scripts/update_rule_bulk.sh diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts index 3bdcc3f92f44c..731fffcac1bb0 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/__mocks__/es_results.ts @@ -9,8 +9,8 @@ import { Logger, SavedObject, SavedObjectsFindResponse, -} from '../../../../../../../../../src/core/server'; -import { loggingServiceMock } from '../../../../../../../../../src/core/server/mocks'; +} from '../../../../../../../../src/core/server'; +import { loggingServiceMock } from '../../../../../../../../src/core/server/mocks'; import { RuleTypeParams, OutputRuleAlertRest } from '../../types'; import { IRuleStatusAttributes } from '../../rules/types'; import { ruleStatusSavedObjectType } from '../../../../saved_objects'; @@ -44,7 +44,7 @@ export const sampleRuleAlertParams = ( meta: undefined, threat: undefined, version: 1, - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -86,7 +86,7 @@ export const sampleDocNoSortId = (someUuid: string = sampleIdGuid): SignalSource _id: someUuid, _source: { someKey: 'someValue', - '@timestamp': 'someTimeStamp', + '@timestamp': '2020-04-20T21:27:45+0000', }, }); @@ -97,7 +97,7 @@ export const sampleDocNoSortIdNoVersion = (someUuid: string = sampleIdGuid): Sig _id: someUuid, _source: { someKey: 'someValue', - '@timestamp': 'someTimeStamp', + '@timestamp': '2020-04-20T21:27:45+0000', }, }); @@ -109,7 +109,7 @@ export const sampleDocWithSortId = (someUuid: string = sampleIdGuid): SignalSour _id: someUuid, _source: { someKey: 'someValue', - '@timestamp': 'someTimeStamp', + '@timestamp': '2020-04-20T21:27:45+0000', }, sort: ['1234567891111'], }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/__mocks__/rule_status_saved_objects_client.mock.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/__mocks__/rule_status_saved_objects_client.mock.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/__mocks__/rule_status_saved_objects_client.mock.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/__mocks__/rule_status_saved_objects_client.mock.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts index f1729e35ce1f0..df9d282b71e5e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.test.ts @@ -59,7 +59,7 @@ describe('buildBulkBody', () => { depth: 1, }, ], - original_time: 'someTimeStamp', + original_time: '2020-04-20T21:27:45+0000', status: 'open', rule: { actions: [], @@ -90,7 +90,7 @@ describe('buildBulkBody', () => { version: 1, created_at: fakeSignalSourceHit.signal.rule?.created_at, updated_at: fakeSignalSourceHit.signal.rule?.updated_at, - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -185,7 +185,7 @@ describe('buildBulkBody', () => { depth: 1, }, ], - original_time: 'someTimeStamp', + original_time: '2020-04-20T21:27:45+0000', status: 'open', rule: { actions: [], @@ -216,7 +216,7 @@ describe('buildBulkBody', () => { created_at: fakeSignalSourceHit.signal.rule?.created_at, updated_at: fakeSignalSourceHit.signal.rule?.updated_at, throttle: 'no_actions', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -309,7 +309,7 @@ describe('buildBulkBody', () => { depth: 1, }, ], - original_time: 'someTimeStamp', + original_time: '2020-04-20T21:27:45+0000', status: 'open', rule: { actions: [], @@ -340,7 +340,7 @@ describe('buildBulkBody', () => { created_at: fakeSignalSourceHit.signal.rule?.created_at, updated_at: fakeSignalSourceHit.signal.rule?.updated_at, throttle: 'no_actions', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -426,7 +426,7 @@ describe('buildBulkBody', () => { depth: 1, }, ], - original_time: 'someTimeStamp', + original_time: '2020-04-20T21:27:45+0000', status: 'open', rule: { actions: [], @@ -457,7 +457,7 @@ describe('buildBulkBody', () => { updated_at: fakeSignalSourceHit.signal.rule?.updated_at, created_at: fakeSignalSourceHit.signal.rule?.created_at, throttle: 'no_actions', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_bulk_body.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_event_type_signal.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_event_type_signal.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_event_type_signal.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_event_type_signal.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_event_type_signal.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_event_type_signal.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_event_type_signal.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_event_type_signal.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_events_query.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_events_query.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_events_query.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_events_query.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_events_query.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_events_query.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_events_query.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_events_query.ts diff --git a/x-pack/plugins/siem/server/lib/detection_engine/signals/build_exceptions_query.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_exceptions_query.test.ts new file mode 100644 index 0000000000000..ec8db77dac725 --- /dev/null +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_exceptions_query.test.ts @@ -0,0 +1,1318 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { + buildQueryExceptions, + buildExceptions, + operatorBuilder, + buildExists, + buildMatch, + buildMatchAll, + evaluateValues, + formatQuery, + getLanguageBooleanOperator, +} from './build_exceptions_query'; +import { List } from '../routes/schemas/types/lists_default_array'; + +describe('build_exceptions_query', () => { + describe('getLanguageBooleanOperator', () => { + test('it returns value as uppercase if language is "lucene"', () => { + const result = getLanguageBooleanOperator({ language: 'lucene', value: 'not' }); + + expect(result).toEqual('NOT'); + }); + + test('it returns value as is if language is "kuery"', () => { + const result = getLanguageBooleanOperator({ language: 'kuery', value: 'not' }); + + expect(result).toEqual('not'); + }); + }); + + describe('operatorBuilder', () => { + describe('kuery', () => { + test('it returns "not " when operator is "excluded"', () => { + const operator = operatorBuilder({ operator: 'excluded', language: 'kuery' }); + + expect(operator).toEqual(' and '); + }); + + test('it returns empty string when operator is "included"', () => { + const operator = operatorBuilder({ operator: 'included', language: 'kuery' }); + + expect(operator).toEqual(' and not '); + }); + }); + + describe('lucene', () => { + test('it returns "NOT " when operator is "excluded"', () => { + const operator = operatorBuilder({ operator: 'excluded', language: 'lucene' }); + + expect(operator).toEqual(' AND '); + }); + + test('it returns empty string when operator is "included"', () => { + const operator = operatorBuilder({ operator: 'included', language: 'lucene' }); + + expect(operator).toEqual(' AND NOT '); + }); + }); + }); + + describe('buildExists', () => { + describe('kuery', () => { + test('it returns formatted wildcard string when operator is "excluded"', () => { + const query = buildExists({ operator: 'excluded', field: 'host.name', language: 'kuery' }); + + expect(query).toEqual(' and host.name:*'); + }); + + test('it returns formatted wildcard string when operator is "included"', () => { + const query = buildExists({ operator: 'included', field: 'host.name', language: 'kuery' }); + + expect(query).toEqual(' and not host.name:*'); + }); + }); + + describe('lucene', () => { + test('it returns formatted wildcard string when operator is "excluded"', () => { + const query = buildExists({ operator: 'excluded', field: 'host.name', language: 'lucene' }); + + expect(query).toEqual(' AND _exists_host.name'); + }); + + test('it returns formatted wildcard string when operator is "included"', () => { + const query = buildExists({ operator: 'included', field: 'host.name', language: 'lucene' }); + + expect(query).toEqual(' AND NOT _exists_host.name'); + }); + }); + }); + + describe('buildMatch', () => { + describe('kuery', () => { + test('it returns empty string if no items in "values"', () => { + const query = buildMatch({ + operator: 'included', + field: 'host.name', + values: [], + language: 'kuery', + }); + + expect(query).toEqual(''); + }); + + test('it returns formatted string when operator is "included"', () => { + const values = [ + { + name: 'suricata', + }, + ]; + const query = buildMatch({ + operator: 'included', + field: 'host.name', + values, + language: 'kuery', + }); + + expect(query).toEqual(' and not host.name:suricata'); + }); + + test('it returns formatted string when operator is "excluded"', () => { + const values = [ + { + name: 'suricata', + }, + ]; + const query = buildMatch({ + operator: 'excluded', + field: 'host.name', + values, + language: 'kuery', + }); + + expect(query).toEqual(' and host.name:suricata'); + }); + + // TODO: need to clean up types and maybe restrict values to one if type is 'match' + test('it returns formatted string when "values" includes more than one item', () => { + const values = [ + { + name: 'suricata', + }, + { + name: 'auditd', + }, + ]; + const query = buildMatch({ + operator: 'included', + field: 'host.name', + values, + language: 'kuery', + }); + + expect(query).toEqual(' and not host.name:suricata'); + }); + }); + + describe('lucene', () => { + test('it returns formatted string when operator is "included"', () => { + const values = [ + { + name: 'suricata', + }, + ]; + const query = buildMatch({ + operator: 'included', + field: 'host.name', + values, + language: 'lucene', + }); + + expect(query).toEqual(' AND NOT host.name:suricata'); + }); + + test('it returns formatted string when operator is "excluded"', () => { + const values = [ + { + name: 'suricata', + }, + ]; + const query = buildMatch({ + operator: 'excluded', + field: 'host.name', + values, + language: 'lucene', + }); + + expect(query).toEqual(' AND host.name:suricata'); + }); + + // TODO: need to clean up types and maybe restrict values to one if type is 'match' + test('it returns formatted string when "values" includes more than one item', () => { + const values = [ + { + name: 'suricata', + }, + { + name: 'auditd', + }, + ]; + const query = buildMatch({ + operator: 'included', + field: 'host.name', + values, + language: 'lucene', + }); + + expect(query).toEqual(' AND NOT host.name:suricata'); + }); + }); + }); + + describe('buildMatchAll', () => { + describe('kuery', () => { + test('it returns empty string if given an empty array for "values"', () => { + const exceptionSegment = buildMatchAll({ + operator: 'included', + field: 'host.name', + values: [], + language: 'kuery', + }); + + expect(exceptionSegment).toEqual(''); + }); + + test('it returns formatted string when "values" includes only one item', () => { + const values = [ + { + name: 'suricata', + }, + ]; + const exceptionSegment = buildMatchAll({ + operator: 'included', + field: 'host.name', + values, + language: 'kuery', + }); + + expect(exceptionSegment).toEqual(' and not host.name:suricata'); + }); + + test('it returns formatted string when operator is "included"', () => { + const values = [ + { + name: 'suricata', + }, + { + name: 'auditd', + }, + ]; + const exceptionSegment = buildMatchAll({ + operator: 'included', + field: 'host.name', + values, + language: 'kuery', + }); + + expect(exceptionSegment).toEqual(' and not host.name:(suricata or auditd)'); + }); + + test('it returns formatted string when operator is "excluded"', () => { + const values = [ + { + name: 'suricata', + }, + { + name: 'auditd', + }, + ]; + const exceptionSegment = buildMatchAll({ + operator: 'excluded', + field: 'host.name', + values, + language: 'kuery', + }); + + expect(exceptionSegment).toEqual(' and host.name:(suricata or auditd)'); + }); + }); + + describe('lucene', () => { + test('it returns formatted string when operator is "included"', () => { + const values = [ + { + name: 'suricata', + }, + { + name: 'auditd', + }, + ]; + const exceptionSegment = buildMatchAll({ + operator: 'included', + field: 'host.name', + values, + language: 'lucene', + }); + + expect(exceptionSegment).toEqual(' AND NOT host.name:(suricata OR auditd)'); + }); + + test('it returns formatted string when operator is "excluded"', () => { + const values = [ + { + name: 'suricata', + }, + { + name: 'auditd', + }, + ]; + const exceptionSegment = buildMatchAll({ + operator: 'excluded', + field: 'host.name', + values, + language: 'lucene', + }); + + expect(exceptionSegment).toEqual(' AND host.name:(suricata OR auditd)'); + }); + + test('it returns formatted string when "values" includes only one item', () => { + const values = [ + { + name: 'suricata', + }, + ]; + const exceptionSegment = buildMatchAll({ + operator: 'included', + field: 'host.name', + values, + language: 'lucene', + }); + + expect(exceptionSegment).toEqual(' AND NOT host.name:suricata'); + }); + }); + }); + + describe('evaluateValues', () => { + describe('kuery', () => { + test('it returns formatted wildcard string when "type" is "exists"', () => { + const list: List = { + values_operator: 'included', + values_type: 'exists', + field: 'host.name', + }; + const result = evaluateValues({ + list, + language: 'kuery', + }); + + expect(result).toEqual(' and not host.name:*'); + }); + + test('it returns formatted string when "type" is "match"', () => { + const list: List = { + values_operator: 'included', + values_type: 'match', + field: 'host.name', + values: [{ name: 'suricata' }], + }; + const result = evaluateValues({ + list, + language: 'kuery', + }); + + expect(result).toEqual(' and not host.name:suricata'); + }); + + test('it returns formatted string when "type" is "match_all"', () => { + const list: List = { + values_operator: 'included', + values_type: 'match_all', + field: 'host.name', + values: [ + { + name: 'suricata', + }, + { + name: 'auditd', + }, + ], + }; + + const result = evaluateValues({ + list, + language: 'kuery', + }); + + expect(result).toEqual(' and not host.name:(suricata or auditd)'); + }); + }); + + describe('lucene', () => { + describe('kuery', () => { + test('it returns formatted wildcard string when "type" is "exists"', () => { + const list: List = { + values_operator: 'included', + values_type: 'exists', + field: 'host.name', + }; + const result = evaluateValues({ + list, + language: 'lucene', + }); + + expect(result).toEqual(' AND NOT _exists_host.name'); + }); + + test('it returns formatted string when "type" is "match"', () => { + const list: List = { + values_operator: 'included', + values_type: 'match', + field: 'host.name', + values: [{ name: 'suricata' }], + }; + const result = evaluateValues({ + list, + language: 'lucene', + }); + + expect(result).toEqual(' AND NOT host.name:suricata'); + }); + + test('it returns formatted string when "type" is "match_all"', () => { + const list: List = { + values_operator: 'included', + values_type: 'match_all', + field: 'host.name', + values: [ + { + name: 'suricata', + }, + { + name: 'auditd', + }, + ], + }; + + const result = evaluateValues({ + list, + language: 'lucene', + }); + + expect(result).toEqual(' AND NOT host.name:(suricata OR auditd)'); + }); + }); + }); + }); + + describe('formatQuery', () => { + test('it returns query if "exceptions" is empty array', () => { + const formattedQuery = formatQuery({ exceptions: [], query: 'a:*', language: 'kuery' }); + + expect(formattedQuery).toEqual('a:*'); + }); + + test('it returns expected query string when single exception in array', () => { + const formattedQuery = formatQuery({ + exceptions: [' and b:(value-1 or value-2) and not c:*'], + query: 'a:*', + language: 'kuery', + }); + + expect(formattedQuery).toEqual('(a:* and b:(value-1 or value-2) and not c:*)'); + }); + + test('it returns expected query string when multiple exceptions in array', () => { + const formattedQuery = formatQuery({ + exceptions: [' and b:(value-1 or value-2) and not c:*', ' and not d:*'], + query: 'a:*', + language: 'kuery', + }); + + expect(formattedQuery).toEqual( + '(a:* and b:(value-1 or value-2) and not c:*) or (a:* and not d:*)' + ); + }); + }); + + describe('buildExceptions', () => { + test('it returns empty array if empty lists array passed in', () => { + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists: [], + }); + + expect(query).toEqual([]); + }); + + test('it returns expected query when more than one item in list', () => { + // Equal to query && !(b && !c) -> (query AND NOT b) OR (query AND c) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value-1', + }, + { + name: 'value-2', + }, + ], + }, + { + field: 'c', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'value-3', + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and not b:(value-1 or value-2)', ' and c:value-3']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list item includes nested "and" value', () => { + // Equal to query && !(b || !c) -> (query AND NOT b AND c) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value-1', + }, + { + name: 'value-2', + }, + ], + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'value-3', + }, + ], + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and not b:(value-1 or value-2) and c:value-3']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list item includes nested "and" value of empty array', () => { + // Equal to query && !(b || !c) -> (query AND NOT b AND c) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value-1', + }, + { + name: 'value-2', + }, + ], + and: [], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and not b:(value-1 or value-2)']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list item includes nested "and" value of null', () => { + // Equal to query && !(b || !c) -> (query AND NOT b AND c) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value-1', + }, + { + name: 'value-2', + }, + ], + and: undefined, + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and not b:(value-1 or value-2)']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes multiple items and nested "and" values', () => { + // Equal to query && !((b || !c) && d) -> (query AND NOT b AND c) OR (query AND NOT d) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value-1', + }, + { + name: 'value-2', + }, + ], + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'value-3', + }, + ], + }, + ], + }, + { + field: 'd', + values_operator: 'included', + values_type: 'exists', + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and not b:(value-1 or value-2) and c:value-3', ' and not d:*']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when language is "lucene"', () => { + // Equal to query && !((b || !c) && !d) -> (query AND NOT b AND c) OR (query AND d) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value-1', + }, + { + name: 'value-2', + }, + ], + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'value-3', + }, + ], + }, + ], + }, + { + field: 'e', + values_operator: 'excluded', + values_type: 'exists', + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'lucene', + lists, + }); + const expectedQuery = [' AND NOT b:(value-1 OR value-2) AND c:value-3', ' AND _exists_e']; + + expect(query).toEqual(expectedQuery); + }); + + describe('exists', () => { + test('it returns expected query when list includes single list item with values_operator of "included"', () => { + // Equal to query && !(b) -> (query AND NOT b) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'exists', + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and not b:*']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes single list item with values_operator of "excluded"', () => { + // Equal to query && !(!b) -> (query AND b) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'excluded', + values_type: 'exists', + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and b:*']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes list item with "and" values', () => { + // Equal to query && !(!b || !c) -> (query AND b AND c) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'excluded', + values_type: 'exists', + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'exists', + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and b:* and c:*']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes multiple items', () => { + // Equal to query && !((b || !c || d) && e) -> (query AND NOT b AND c AND NOT d) OR (query AND NOT e) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'exists', + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'exists', + }, + { + field: 'd', + values_operator: 'included', + values_type: 'exists', + }, + ], + }, + { + field: 'e', + values_operator: 'included', + values_type: 'exists', + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and not b:* and c:* and not d:*', ' and not e:*']; + + expect(query).toEqual(expectedQuery); + }); + }); + + describe('match', () => { + test('it returns expected query when list includes single list item with values_operator of "included"', () => { + // Equal to query && !(b) -> (query AND NOT b) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match', + values: [ + { + name: 'value', + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and not b:value']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes single list item with values_operator of "excluded"', () => { + // Equal to query && !(!b) -> (query AND b) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'value', + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and b:value']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes list item with "and" values', () => { + // Equal to query && !(!b || !c) -> (query AND b AND c) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'value', + }, + ], + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'valueC', + }, + ], + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and b:value and c:valueC']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes multiple items', () => { + // Equal to query && !((b || !c || d) && e) -> (query AND NOT b AND c AND NOT d) OR (query AND NOT e) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match', + values: [ + { + name: 'value', + }, + ], + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'valueC', + }, + ], + }, + { + field: 'd', + values_operator: 'included', + values_type: 'match', + values: [ + { + name: 'valueC', + }, + ], + }, + ], + }, + { + field: 'e', + values_operator: 'included', + values_type: 'match', + values: [ + { + name: 'valueC', + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [ + ' and not b:value and c:valueC and not d:valueC', + ' and not e:valueC', + ]; + + expect(query).toEqual(expectedQuery); + }); + }); + + describe('match_all', () => { + test('it returns expected query when list includes single list item with values_operator of "included"', () => { + // Equal to query && !(b) -> (query AND NOT b) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value', + }, + { + name: 'value-1', + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and not b:(value or value-1)']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes single list item with values_operator of "excluded"', () => { + // Equal to query && !(!b) -> (query AND b) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'excluded', + values_type: 'match_all', + values: [ + { + name: 'value', + }, + { + name: 'value-1', + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and b:(value or value-1)']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes list item with "and" values', () => { + // Equal to query && !(!b || c) -> (query AND b AND NOT c) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'excluded', + values_type: 'match_all', + values: [ + { + name: 'value', + }, + { + name: 'value-1', + }, + ], + and: [ + { + field: 'c', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'valueC', + }, + { + name: 'value-2', + }, + ], + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [' and b:(value or value-1) and not c:(valueC or value-2)']; + + expect(query).toEqual(expectedQuery); + }); + + test('it returns expected query when list includes multiple items', () => { + // Equal to query && !((b || !c || d) && e) -> ((query AND NOT b AND c AND NOT d) OR (query AND NOT e) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value', + }, + { + name: 'value-1', + }, + ], + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'match_all', + values: [ + { + name: 'valueC', + }, + { + name: 'value-2', + }, + ], + }, + { + field: 'd', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'valueD', + }, + { + name: 'value-3', + }, + ], + }, + ], + }, + { + field: 'e', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'valueE', + }, + { + name: 'value-4', + }, + ], + }, + ]; + const query = buildExceptions({ + query: 'a:*', + language: 'kuery', + lists, + }); + const expectedQuery = [ + ' and not b:(value or value-1) and c:(valueC or value-2) and not d:(valueD or value-3)', + ' and not e:(valueE or value-4)', + ]; + + expect(query).toEqual(expectedQuery); + }); + }); + }); + + describe('buildQueryExceptions', () => { + test('it returns original query if no lists exist', () => { + const query = buildQueryExceptions({ + query: 'host.name: *', + language: 'kuery', + lists: undefined, + }); + const expectedQuery = 'host.name: *'; + + expect(query).toEqual([{ query: expectedQuery, language: 'kuery' }]); + }); + + test('it returns original query if lists is empty array', () => { + const query = buildQueryExceptions({ query: 'host.name: *', language: 'kuery', lists: [] }); + const expectedQuery = 'host.name: *'; + + expect(query).toEqual([{ query: expectedQuery, language: 'kuery' }]); + }); + + test('it returns original query if lists is null', () => { + const query = buildQueryExceptions({ query: 'host.name: *', language: 'kuery', lists: null }); + const expectedQuery = 'host.name: *'; + + expect(query).toEqual([{ query: expectedQuery, language: 'kuery' }]); + }); + + test('it returns original query if lists is undefined', () => { + const query = buildQueryExceptions({ + query: 'host.name: *', + language: 'kuery', + lists: undefined, + }); + const expectedQuery = 'host.name: *'; + + expect(query).toEqual([{ query: expectedQuery, language: 'kuery' }]); + }); + + test('it returns expected query when lists exist and language is "kuery"', () => { + // Equal to query && !((b || !c || d) && e) -> ((query AND NOT b AND c AND NOT d) OR (query AND NOT e) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value', + }, + { + name: 'value-1', + }, + ], + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'match_all', + values: [ + { + name: 'valueC', + }, + { + name: 'value-2', + }, + ], + }, + { + field: 'd', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'valueD', + }, + { + name: 'value-3', + }, + ], + }, + ], + }, + { + field: 'e', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'valueE', + }, + { + name: 'value-4', + }, + ], + }, + ]; + const query = buildQueryExceptions({ query: 'a:*', language: 'kuery', lists }); + const expectedQuery = + '(a:* and not b:(value or value-1) and c:(valueC or value-2) and not d:(valueD or value-3)) or (a:* and not e:(valueE or value-4))'; + + expect(query).toEqual([{ query: expectedQuery, language: 'kuery' }]); + }); + + test('it returns expected query when lists exist and language is "lucene"', () => { + // Equal to query && !((b || !c || d) && e) -> ((query AND NOT b AND c AND NOT d) OR (query AND NOT e) + // https://www.dcode.fr/boolean-expressions-calculator + const lists: List[] = [ + { + field: 'b', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'value', + }, + { + name: 'value-1', + }, + ], + and: [ + { + field: 'c', + values_operator: 'excluded', + values_type: 'match_all', + values: [ + { + name: 'valueC', + }, + { + name: 'value-2', + }, + ], + }, + { + field: 'd', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'valueD', + }, + { + name: 'value-3', + }, + ], + }, + ], + }, + { + field: 'e', + values_operator: 'included', + values_type: 'match_all', + values: [ + { + name: 'valueE', + }, + { + name: 'value-4', + }, + ], + }, + ]; + const query = buildQueryExceptions({ query: 'a:*', language: 'lucene', lists }); + const expectedQuery = + '(a:* AND NOT b:(value OR value-1) AND c:(valueC OR value-2) AND NOT d:(valueD OR value-3)) OR (a:* AND NOT e:(valueE OR value-4))'; + + expect(query).toEqual([{ query: expectedQuery, language: 'lucene' }]); + }); + }); +}); diff --git a/x-pack/plugins/siem/server/lib/detection_engine/signals/build_exceptions_query.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_exceptions_query.ts new file mode 100644 index 0000000000000..7a1564bb69546 --- /dev/null +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_exceptions_query.ts @@ -0,0 +1,203 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { Query } from '../../../../../../../src/plugins/data/server'; +import { List, ListOperator, ListValues } from '../routes/schemas/types/lists_default_array'; +import { RuleAlertParams, Language } from '../types'; + +type Operators = 'and' | 'or' | 'not'; +type LuceneOperators = 'AND' | 'OR' | 'NOT'; + +export const getLanguageBooleanOperator = ({ + language, + value, +}: { + language: Language; + value: Operators; +}): Operators | LuceneOperators => { + switch (language) { + case 'lucene': + const luceneValues: Record = { and: 'AND', or: 'OR', not: 'NOT' }; + + return luceneValues[value]; + case 'kuery': + return value; + default: + return value; + } +}; + +export const operatorBuilder = ({ + operator, + language, +}: { + operator: ListOperator; + language: Language; +}): string => { + const and = getLanguageBooleanOperator({ + language, + value: 'and', + }); + const or = getLanguageBooleanOperator({ + language, + value: 'not', + }); + + switch (operator) { + case 'excluded': + return ` ${and} `; + case 'included': + return ` ${and} ${or} `; + default: + return ''; + } +}; + +export const buildExists = ({ + operator, + field, + language, +}: { + operator: ListOperator; + field: string; + language: Language; +}): string => { + const exceptionOperator = operatorBuilder({ operator, language }); + + switch (language) { + case 'kuery': + return `${exceptionOperator}${field}:*`; + case 'lucene': + return `${exceptionOperator}_exists_${field}`; + default: + return ''; + } +}; + +export const buildMatch = ({ + operator, + field, + values, + language, +}: { + operator: ListOperator; + field: string; + values: ListValues[]; + language: Language; +}): string => { + if (values.length > 0) { + const exceptionOperator = operatorBuilder({ operator, language }); + const [exception] = values; + + return `${exceptionOperator}${field}:${exception.name}`; + } else { + return ''; + } +}; + +export const buildMatchAll = ({ + operator, + field, + values, + language, +}: { + operator: ListOperator; + field: string; + values: ListValues[]; + language: Language; +}): string => { + switch (values.length) { + case 0: + return ''; + case 1: + return buildMatch({ operator, field, values, language }); + default: + const or = getLanguageBooleanOperator({ language, value: 'or' }); + const exceptionOperator = operatorBuilder({ operator, language }); + const matchAllValues = values.map(value => { + return value.name; + }); + + return `${exceptionOperator}${field}:(${matchAllValues.join(` ${or} `)})`; + } +}; + +export const evaluateValues = ({ list, language }: { list: List; language: Language }): string => { + const { values_operator: operator, values_type: type, field, values } = list; + switch (type) { + case 'exists': + return buildExists({ operator, field, language }); + case 'match': + return buildMatch({ operator, field, values: values ?? [], language }); + case 'match_all': + return buildMatchAll({ operator, field, values: values ?? [], language }); + default: + return ''; + } +}; + +export const formatQuery = ({ + exceptions, + query, + language, +}: { + exceptions: string[]; + query: string; + language: Language; +}): string => { + if (exceptions.length > 0) { + const or = getLanguageBooleanOperator({ language, value: 'or' }); + const formattedExceptions = exceptions.map(exception => { + return `(${query}${exception})`; + }); + + return formattedExceptions.join(` ${or} `); + } else { + return query; + } +}; + +export const buildExceptions = ({ + query, + lists, + language, +}: { + query: string; + lists: List[]; + language: Language; +}): string[] => { + return lists.reduce((accum, listItem) => { + const { and, ...exceptionDetails } = { ...listItem }; + const andExceptionsSegments = and ? buildExceptions({ query, lists: and, language }) : []; + const exceptionSegment = evaluateValues({ list: exceptionDetails, language }); + const exception = [...exceptionSegment, ...andExceptionsSegments]; + + return [...accum, exception.join('')]; + }, []); +}; + +export const buildQueryExceptions = ({ + query, + language, + lists, +}: { + query: string; + language: Language; + lists: RuleAlertParams['exceptions_list']; +}): Query[] => { + if (lists && lists !== null) { + const exceptions = buildExceptions({ lists, language, query }); + const formattedQuery = formatQuery({ exceptions, language, query }); + + return [ + { + query: formattedQuery, + language, + }, + ]; + } else { + return [{ query, language }]; + } +}; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts index e5183ed4df7bd..b3586c884d0c7 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_rule.test.ts @@ -79,7 +79,7 @@ describe('buildRule', () => { query: 'host.name: Braden', }, ], - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -162,7 +162,7 @@ describe('buildRule', () => { updated_at: rule.updated_at, created_at: rule.created_at, throttle: 'no_actions', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', @@ -244,7 +244,7 @@ describe('buildRule', () => { updated_at: rule.updated_at, created_at: rule.created_at, throttle: 'no_actions', - lists: [ + exceptions_list: [ { field: 'source.ip', values_operator: 'included', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_rule.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_rule.ts index 9c375d7d45d5e..93d4e5e7719b2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_rule.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_rule.ts @@ -72,7 +72,7 @@ export const buildRule = ({ version: ruleParams.version, created_at: createdAt, updated_at: updatedAt, - lists: ruleParams.lists, + exceptions_list: ruleParams.exceptions_list, machine_learning_job_id: ruleParams.machineLearningJobId, anomaly_threshold: ruleParams.anomalyThreshold, }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_signal.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_signal.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_signal.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_signal.test.ts index 0a50c33fbbfe4..f3f4ab60e4db6 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_signal.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_signal.test.ts @@ -41,7 +41,7 @@ describe('buildSignal', () => { depth: 1, }, ], - original_time: 'someTimeStamp', + original_time: '2020-04-20T21:27:45+0000', status: 'open', rule: { created_by: 'elastic', @@ -101,7 +101,7 @@ describe('buildSignal', () => { depth: 1, }, ], - original_time: 'someTimeStamp', + original_time: '2020-04-20T21:27:45+0000', original_event: { action: 'socket_opened', dataset: 'socket', @@ -173,7 +173,7 @@ describe('buildSignal', () => { depth: 1, }, ], - original_time: 'someTimeStamp', + original_time: '2020-04-20T21:27:45+0000', original_event: { action: 'socket_opened', dataset: 'socket', diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_signal.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/build_signal.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/build_signal.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/build_signal.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.ts index ba8938f116fc6..d298f1cc7cbc6 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/bulk_create_ml_signals.ts @@ -7,8 +7,8 @@ import { flow, set, omit } from 'lodash/fp'; import { SearchResponse } from 'elasticsearch'; -import { Logger } from '../../../../../../../../src/core/server'; -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { Logger } from '../../../../../../../src/core/server'; +import { AlertServices } from '../../../../../alerting/server'; import { RuleAlertAction } from '../../../../common/detection_engine/types'; import { RuleTypeParams, RefreshTypes } from '../types'; import { singleBulkCreate, SingleBulkCreateResponse } from './single_bulk_create'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/find_ml_signals.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/find_ml_signals.ts similarity index 91% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/find_ml_signals.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/find_ml_signals.ts index b7f752e6ba5e0..8ac5a6cde39cc 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/find_ml_signals.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/find_ml_signals.ts @@ -6,7 +6,7 @@ import dateMath from '@elastic/datemath'; -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { getAnomalies } from '../../machine_learning'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_filter.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_filter.test.ts similarity index 78% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_filter.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/get_filter.test.ts index 510667b211d25..35ec1950cedaa 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_filter.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_filter.test.ts @@ -6,7 +6,7 @@ import { getQueryFilter, getFilter } from './get_filter'; import { PartialFilter } from '../types'; -import { alertsMock, AlertServicesMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks'; describe('get_filter', () => { let servicesMock: AlertServicesMock; @@ -35,7 +35,7 @@ describe('get_filter', () => { describe('getQueryFilter', () => { test('it should work with an empty filter as kuery', () => { - const esQuery = getQueryFilter('host.name: linux', 'kuery', [], ['auditbeat-*']); + const esQuery = getQueryFilter('host.name: linux', 'kuery', [], ['auditbeat-*'], []); expect(esQuery).toEqual({ bool: { must: [], @@ -60,7 +60,7 @@ describe('get_filter', () => { }); test('it should work with an empty filter as lucene', () => { - const esQuery = getQueryFilter('host.name: linux', 'lucene', [], ['auditbeat-*']); + const esQuery = getQueryFilter('host.name: linux', 'lucene', [], ['auditbeat-*'], []); expect(esQuery).toEqual({ bool: { must: [ @@ -102,7 +102,8 @@ describe('get_filter', () => { }, }, ], - ['auditbeat-*'] + ['auditbeat-*'], + [] ); expect(esQuery).toEqual({ bool: { @@ -145,7 +146,8 @@ describe('get_filter', () => { }, }, ], - ['auditbeat-*'] + ['auditbeat-*'], + [] ); expect(esQuery).toEqual({ bool: { @@ -194,7 +196,8 @@ describe('get_filter', () => { 'host.name: windows', 'kuery', [query, exists], - ['auditbeat-*'] + ['auditbeat-*'], + [] ); expect(esQuery).toEqual({ bool: { @@ -252,7 +255,8 @@ describe('get_filter', () => { }, }, ], - ['auditbeat-*'] + ['auditbeat-*'], + [] ); expect(esQuery).toEqual({ bool: { @@ -300,7 +304,8 @@ describe('get_filter', () => { }, }, ], - ['auditbeat-*'] + ['auditbeat-*'], + [] ); expect(esQuery).toEqual({ bool: { @@ -349,7 +354,8 @@ describe('get_filter', () => { }, }, ], - ['auditbeat-*'] + ['auditbeat-*'], + [] ); expect(esQuery).toEqual({ bool: { @@ -368,6 +374,108 @@ describe('get_filter', () => { }, }); }); + + test('it should work with a list', () => { + const esQuery = getQueryFilter( + 'host.name: linux', + 'kuery', + [], + ['auditbeat-*'], + [ + { + field: 'event.module', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'suricata', + }, + ], + }, + ] + ); + expect(esQuery).toEqual({ + bool: { + filter: [ + { + bool: { + filter: [ + { + bool: { + minimum_should_match: 1, + should: [ + { + match: { + 'host.name': 'linux', + }, + }, + ], + }, + }, + { + bool: { + minimum_should_match: 1, + should: [ + { + match: { + 'event.module': 'suricata', + }, + }, + ], + }, + }, + ], + }, + }, + ], + must: [], + must_not: [], + should: [], + }, + }); + }); + + test('it should work with an empty list', () => { + const esQuery = getQueryFilter('host.name: linux', 'kuery', [], ['auditbeat-*'], []); + expect(esQuery).toEqual({ + bool: { + filter: [ + { bool: { minimum_should_match: 1, should: [{ match: { 'host.name': 'linux' } }] } }, + ], + must: [], + must_not: [], + should: [], + }, + }); + }); + + test('it should work when lists has value null', () => { + const esQuery = getQueryFilter('host.name: linux', 'kuery', [], ['auditbeat-*'], null); + expect(esQuery).toEqual({ + bool: { + filter: [ + { bool: { minimum_should_match: 1, should: [{ match: { 'host.name': 'linux' } }] } }, + ], + must: [], + must_not: [], + should: [], + }, + }); + }); + + test('it should work when lists has value undefined', () => { + const esQuery = getQueryFilter('host.name: linux', 'kuery', [], ['auditbeat-*'], undefined); + expect(esQuery).toEqual({ + bool: { + filter: [ + { bool: { minimum_should_match: 1, should: [{ match: { 'host.name': 'linux' } }] } }, + ], + must: [], + must_not: [], + should: [], + }, + }); + }); }); describe('getFilter', () => { @@ -380,6 +488,7 @@ describe('get_filter', () => { savedId: undefined, services: servicesMock, index: ['auditbeat-*'], + lists: undefined, }); expect(filter).toEqual({ bool: { @@ -414,6 +523,7 @@ describe('get_filter', () => { savedId: undefined, services: servicesMock, index: ['auditbeat-*'], + lists: undefined, }) ).rejects.toThrow('query, filters, and index parameter should be defined'); }); @@ -428,6 +538,7 @@ describe('get_filter', () => { savedId: undefined, services: servicesMock, index: ['auditbeat-*'], + lists: undefined, }) ).rejects.toThrow('query, filters, and index parameter should be defined'); }); @@ -442,6 +553,7 @@ describe('get_filter', () => { savedId: undefined, services: servicesMock, index: undefined, + lists: undefined, }) ).rejects.toThrow('query, filters, and index parameter should be defined'); }); @@ -455,6 +567,7 @@ describe('get_filter', () => { savedId: 'some-id', services: servicesMock, index: ['auditbeat-*'], + lists: undefined, }); expect(filter).toEqual({ bool: { @@ -478,6 +591,7 @@ describe('get_filter', () => { savedId: undefined, services: servicesMock, index: ['auditbeat-*'], + lists: undefined, }) ).rejects.toThrow('savedId parameter should be defined'); }); @@ -492,6 +606,7 @@ describe('get_filter', () => { savedId: 'some-id', services: servicesMock, index: undefined, + lists: undefined, }) ).rejects.toThrow('savedId parameter should be defined'); }); @@ -506,6 +621,7 @@ describe('get_filter', () => { savedId: 'some-id', services: servicesMock, index: undefined, + lists: undefined, }) ).rejects.toThrow('Unsupported Rule of type "machine_learning" supplied to getFilter'); }); @@ -515,7 +631,8 @@ describe('get_filter', () => { '(event.module:suricata and event.kind:alert) and suricata.eve.alert.signature_id: (2610182 or 2610183 or 2610184 or 2610185 or 2610186 or 2610187)', 'kuery', [], - ['my custom index'] + ['my custom index'], + [] ); expect(esQuery).toEqual({ bool: { @@ -644,5 +761,68 @@ describe('get_filter', () => { }, }); }); + + test('returns a query when given a list', async () => { + const filter = await getFilter({ + type: 'query', + filters: undefined, + language: 'kuery', + query: 'host.name: siem', + savedId: undefined, + services: servicesMock, + index: ['auditbeat-*'], + lists: [ + { + field: 'event.module', + values_operator: 'excluded', + values_type: 'match', + values: [ + { + name: 'suricata', + }, + ], + }, + ], + }); + expect(filter).toEqual({ + bool: { + filter: [ + { + bool: { + filter: [ + { + bool: { + minimum_should_match: 1, + should: [ + { + match: { + 'host.name': 'siem', + }, + }, + ], + }, + }, + { + bool: { + minimum_should_match: 1, + should: [ + { + match: { + 'event.module': 'suricata', + }, + }, + ], + }, + }, + ], + }, + }, + ], + must: [], + must_not: [], + should: [], + }, + }); + }); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_filter.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_filter.ts similarity index 83% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_filter.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/get_filter.ts index 82a50222dc351..d8fdab55bddeb 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_filter.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_filter.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { assertUnreachable } from '../../../utils/build_query'; import { Filter, @@ -12,22 +12,25 @@ import { esQuery, esFilters, IIndexPattern, -} from '../../../../../../../../src/plugins/data/server'; -import { PartialFilter, RuleAlertParams } from '../types'; +} from '../../../../../../../src/plugins/data/server'; +import { PartialFilter, RuleAlertParams, Language } from '../types'; import { BadRequestError } from '../errors/bad_request_error'; +import { buildQueryExceptions } from './build_exceptions_query'; export const getQueryFilter = ( query: string, - language: string, + language: Language, filters: PartialFilter[], - index: string[] + index: string[], + lists: RuleAlertParams['exceptions_list'] ) => { const indexPattern = { fields: [], title: index.join(), } as IIndexPattern; - const queries: Query[] = [{ query, language }]; + const queries: Query[] = buildQueryExceptions({ query, language, lists }); + const config = { allowLeadingWildcards: true, queryStringOptions: { analyze_wildcard: true }, @@ -45,18 +48,19 @@ export const getQueryFilter = ( interface GetFilterArgs { type: RuleAlertParams['type']; filters: PartialFilter[] | undefined | null; - language: string | undefined | null; + language: Language | undefined | null; query: string | undefined | null; savedId: string | undefined | null; services: AlertServices; index: string[] | undefined | null; + lists: RuleAlertParams['exceptions_list']; } interface QueryAttributes { // NOTE: doesn't match Query interface query: { query: string; - language: string; + language: Language; }; filters: PartialFilter[]; } @@ -69,11 +73,12 @@ export const getFilter = async ({ services, type, query, + lists, }: GetFilterArgs): Promise => { switch (type) { case 'query': { if (query != null && language != null && index != null) { - return getQueryFilter(query, language, filters || [], index); + return getQueryFilter(query, language, filters || [], index, lists); } else { throw new BadRequestError('query, filters, and index parameter should be defined'); } @@ -90,13 +95,14 @@ export const getFilter = async ({ savedObject.attributes.query.query, savedObject.attributes.query.language, savedObject.attributes.filters, - index + index, + lists ); } catch (err) { // saved object does not exist, so try and fall back if the user pushed // any additional language, query, filters, etc... if (query != null && language != null && index != null) { - return getQueryFilter(query, language, filters || [], index); + return getQueryFilter(query, language, filters || [], index, lists); } else { // user did not give any additional fall back mechanism for generating a rule // rethrow error for activity monitoring diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.test.ts similarity index 89% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.test.ts index ccd882228d4de..6fc99ada16ece 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.test.ts @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; +import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks'; +import { DEFAULT_INDEX_KEY, DEFAULT_INDEX_PATTERN } from '../../../../common/constants'; import { getInputIndex } from './get_input_output_index'; -import { defaultIndexPattern } from '../../../../default_index_pattern'; -import { alertsMock, AlertServicesMock } from '../../../../../../../plugins/alerting/server/mocks'; describe('get_input_output_index', () => { let servicesMock: AlertServicesMock; @@ -78,7 +77,7 @@ describe('get_input_output_index', () => { }, })); const inputIndex = await getInputIndex(servicesMock, '8.0.0', null); - expect(inputIndex).toEqual(defaultIndexPattern); + expect(inputIndex).toEqual(DEFAULT_INDEX_PATTERN); }); test('Returns a saved object inputIndex default from constants if inputIndex passed in is undefined and the key is also null', async () => { @@ -91,17 +90,17 @@ describe('get_input_output_index', () => { }, })); const inputIndex = await getInputIndex(servicesMock, '8.0.0', undefined); - expect(inputIndex).toEqual(defaultIndexPattern); + expect(inputIndex).toEqual(DEFAULT_INDEX_PATTERN); }); test('Returns a saved object inputIndex default from constants if both passed in inputIndex and configuration attributes are missing and the index is undefined', async () => { const inputIndex = await getInputIndex(servicesMock, '8.0.0', undefined); - expect(inputIndex).toEqual(defaultIndexPattern); + expect(inputIndex).toEqual(DEFAULT_INDEX_PATTERN); }); test('Returns a saved object inputIndex default from constants if both passed in inputIndex and configuration attributes are missing and the index is null', async () => { const inputIndex = await getInputIndex(servicesMock, '8.0.0', null); - expect(inputIndex).toEqual(defaultIndexPattern); + expect(inputIndex).toEqual(DEFAULT_INDEX_PATTERN); }); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.ts similarity index 75% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.ts index c93990e25b52b..85e3eeac476e4 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_input_output_index.ts @@ -4,9 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertServices } from '../../../../../../../plugins/alerting/server'; -import { defaultIndexPattern } from '../../../../default_index_pattern'; -import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; +import { DEFAULT_INDEX_KEY, DEFAULT_INDEX_PATTERN } from '../../../../common/constants'; +import { AlertServices } from '../../../../../alerting/server'; export const getInputIndex = async ( services: AlertServices, @@ -22,7 +21,7 @@ export const getInputIndex = async ( if (configuration.attributes != null && configuration.attributes[DEFAULT_INDEX_KEY] != null) { return configuration.attributes[DEFAULT_INDEX_KEY]; } else { - return defaultIndexPattern; + return DEFAULT_INDEX_PATTERN; } } }; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_or_create_rule_statuses.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_or_create_rule_statuses.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_or_create_rule_statuses.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/get_or_create_rule_statuses.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_rule_status_saved_objects.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/get_rule_status_saved_objects.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/get_rule_status_saved_objects.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/get_rule_status_saved_objects.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_messages.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/rule_messages.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_messages.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/rule_messages.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_messages.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/rule_messages.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_messages.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/rule_messages.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_status_saved_objects_client.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/rule_status_saved_objects_client.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_status_saved_objects_client.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/rule_status_saved_objects_client.ts index 11cbf67304409..5f76889f238a1 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_status_saved_objects_client.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/rule_status_saved_objects_client.ts @@ -10,7 +10,7 @@ import { SavedObjectsUpdateResponse, SavedObjectsFindOptions, SavedObjectsFindResponse, -} from '../../../../../../../../src/core/server'; +} from '../../../../../../../src/core/server'; import { ruleStatusSavedObjectType } from '../rules/saved_object_mappings'; import { IRuleStatusAttributes } from '../rules/types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_status_service.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/rule_status_service.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_status_service.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/rule_status_service.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_status_service.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/rule_status_service.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/rule_status_service.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/rule_status_service.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts similarity index 88% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts index 9e2f36fe2653a..2cb23b05f6a9b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.test.ts @@ -16,7 +16,7 @@ import { } from './__mocks__/es_results'; import { searchAfterAndBulkCreate } from './search_after_bulk_create'; import { DEFAULT_SIGNALS_INDEX } from '../../../../common/constants'; -import { alertsMock, AlertServicesMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks'; import uuid from 'uuid'; describe('searchAfterAndBulkCreate', () => { @@ -30,7 +30,7 @@ describe('searchAfterAndBulkCreate', () => { test('if successful with empty search results', async () => { const sampleParams = sampleRuleAlertParams(); - const { success, createdSignalsCount } = await searchAfterAndBulkCreate({ + const { success, createdSignalsCount, lastLookBackDate } = await searchAfterAndBulkCreate({ someResult: sampleEmptyDocSearchResults(), ruleParams: sampleParams, services: mockService, @@ -55,6 +55,7 @@ describe('searchAfterAndBulkCreate', () => { expect(mockService.callCluster).toHaveBeenCalledTimes(0); expect(success).toEqual(true); expect(createdSignalsCount).toEqual(0); + expect(lastLookBackDate).toBeNull(); }); test('if successful iteration of while loop with maxDocs', async () => { @@ -105,7 +106,7 @@ describe('searchAfterAndBulkCreate', () => { }, ], }); - const { success, createdSignalsCount } = await searchAfterAndBulkCreate({ + const { success, createdSignalsCount, lastLookBackDate } = await searchAfterAndBulkCreate({ someResult: repeatedSearchResultsWithSortId(3, 1, someGuids.slice(6, 9)), ruleParams: sampleParams, services: mockService, @@ -130,13 +131,14 @@ describe('searchAfterAndBulkCreate', () => { expect(mockService.callCluster).toHaveBeenCalledTimes(5); expect(success).toEqual(true); expect(createdSignalsCount).toEqual(3); + expect(lastLookBackDate).toEqual(new Date('2020-04-20T21:27:45+0000')); }); test('if unsuccessful first bulk create', async () => { const someGuids = Array.from({ length: 4 }).map(x => uuid.v4()); const sampleParams = sampleRuleAlertParams(10); mockService.callCluster.mockResolvedValue(sampleBulkCreateDuplicateResult); - const { success, createdSignalsCount } = await searchAfterAndBulkCreate({ + const { success, createdSignalsCount, lastLookBackDate } = await searchAfterAndBulkCreate({ someResult: repeatedSearchResultsWithSortId(4, 1, someGuids), ruleParams: sampleParams, services: mockService, @@ -161,6 +163,7 @@ describe('searchAfterAndBulkCreate', () => { expect(mockLogger.error).toHaveBeenCalled(); expect(success).toEqual(false); expect(createdSignalsCount).toEqual(1); + expect(lastLookBackDate).toEqual(new Date('2020-04-20T21:27:45+0000')); }); test('if unsuccessful iteration of searchAfterAndBulkCreate due to empty sort ids', async () => { @@ -179,7 +182,7 @@ describe('searchAfterAndBulkCreate', () => { }, ], }); - const { success, createdSignalsCount } = await searchAfterAndBulkCreate({ + const { success, createdSignalsCount, lastLookBackDate } = await searchAfterAndBulkCreate({ someResult: sampleDocSearchResultsNoSortId(), ruleParams: sampleParams, services: mockService, @@ -204,6 +207,7 @@ describe('searchAfterAndBulkCreate', () => { expect(mockLogger.error).toHaveBeenCalled(); expect(success).toEqual(false); expect(createdSignalsCount).toEqual(1); + expect(lastLookBackDate).toEqual(new Date('2020-04-20T21:27:45+0000')); }); test('if unsuccessful iteration of searchAfterAndBulkCreate due to empty sort ids and 0 total hits', async () => { @@ -222,7 +226,7 @@ describe('searchAfterAndBulkCreate', () => { }, ], }); - const { success, createdSignalsCount } = await searchAfterAndBulkCreate({ + const { success, createdSignalsCount, lastLookBackDate } = await searchAfterAndBulkCreate({ someResult: sampleDocSearchResultsNoSortIdNoHits(), ruleParams: sampleParams, services: mockService, @@ -246,6 +250,7 @@ describe('searchAfterAndBulkCreate', () => { }); expect(success).toEqual(true); expect(createdSignalsCount).toEqual(1); + expect(lastLookBackDate).toEqual(new Date('2020-04-20T21:27:45+0000')); }); test('if successful iteration of while loop with maxDocs and search after returns results with no sort ids', async () => { @@ -267,7 +272,7 @@ describe('searchAfterAndBulkCreate', () => { ], }) .mockResolvedValueOnce(sampleDocSearchResultsNoSortId()); - const { success, createdSignalsCount } = await searchAfterAndBulkCreate({ + const { success, createdSignalsCount, lastLookBackDate } = await searchAfterAndBulkCreate({ someResult: repeatedSearchResultsWithSortId(4, 1, someGuids), ruleParams: sampleParams, services: mockService, @@ -291,6 +296,7 @@ describe('searchAfterAndBulkCreate', () => { }); expect(success).toEqual(true); expect(createdSignalsCount).toEqual(1); + expect(lastLookBackDate).toEqual(new Date('2020-04-20T21:27:45+0000')); }); test('if successful iteration of while loop with maxDocs and search after returns empty results with no sort ids', async () => { @@ -312,7 +318,7 @@ describe('searchAfterAndBulkCreate', () => { ], }) .mockResolvedValueOnce(sampleEmptyDocSearchResults()); - const { success, createdSignalsCount } = await searchAfterAndBulkCreate({ + const { success, createdSignalsCount, lastLookBackDate } = await searchAfterAndBulkCreate({ someResult: repeatedSearchResultsWithSortId(4, 1, someGuids), ruleParams: sampleParams, services: mockService, @@ -336,6 +342,7 @@ describe('searchAfterAndBulkCreate', () => { }); expect(success).toEqual(true); expect(createdSignalsCount).toEqual(1); + expect(lastLookBackDate).toEqual(new Date('2020-04-20T21:27:45+0000')); }); test('if returns false when singleSearchAfter throws an exception', async () => { @@ -359,7 +366,7 @@ describe('searchAfterAndBulkCreate', () => { .mockImplementation(() => { throw Error('Fake Error'); }); - const { success, createdSignalsCount } = await searchAfterAndBulkCreate({ + const { success, createdSignalsCount, lastLookBackDate } = await searchAfterAndBulkCreate({ someResult: repeatedSearchResultsWithSortId(4, 1, someGuids), ruleParams: sampleParams, services: mockService, @@ -383,5 +390,6 @@ describe('searchAfterAndBulkCreate', () => { }); expect(success).toEqual(false); expect(createdSignalsCount).toEqual(1); + expect(lastLookBackDate).toEqual(new Date('2020-04-20T21:27:45+0000')); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts index 3a964cb91fbdb..acf3e9bfb055c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/search_after_bulk_create.ts @@ -4,10 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { RuleAlertAction } from '../../../../common/detection_engine/types'; import { RuleTypeParams, RefreshTypes } from '../types'; -import { Logger } from '../../../../../../../../src/core/server'; +import { Logger } from '../../../../../../../src/core/server'; import { singleSearchAfter } from './single_search_after'; import { singleBulkCreate } from './single_bulk_create'; import { SignalSearchResponse } from './types'; @@ -98,13 +98,15 @@ export const searchAfterAndBulkCreate = async ({ tags, throttle, }); - toReturn.lastLookBackDate = - someResult.hits.hits.length > 0 - ? new Date(someResult.hits.hits[someResult.hits.hits.length - 1]?._source['@timestamp']) - : null; - if (createdItemsCount) { + + if (createdItemsCount > 0) { toReturn.createdSignalsCount = createdItemsCount; + toReturn.lastLookBackDate = + someResult.hits.hits.length > 0 + ? new Date(someResult.hits.hits[someResult.hits.hits.length - 1]?._source['@timestamp']) + : null; } + if (bulkCreateDuration) { toReturn.bulkCreateTimes.push(bulkCreateDuration); } diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/siem_rule_action_groups.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/siem_rule_action_groups.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/siem_rule_action_groups.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/siem_rule_action_groups.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_params_schema.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/signal_params_schema.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_params_schema.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/signal_params_schema.ts index 58dd53b6447c5..81a6ce9b08f02 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_params_schema.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/signal_params_schema.ts @@ -39,5 +39,5 @@ export const signalParamsSchema = () => type: schema.string(), references: schema.arrayOf(schema.string(), { defaultValue: [] }), version: schema.number({ defaultValue: 1 }), - lists: schema.maybe(schema.arrayOf(schema.object({}, { unknowns: 'allow' }))), + exceptions_list: schema.maybe(schema.arrayOf(schema.object({}, { unknowns: 'allow' }))), }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts index 31b407da111ea..7eecc5cb9bad0 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.test.ts @@ -8,7 +8,7 @@ import moment from 'moment'; import { loggerMock } from 'src/core/server/logging/logger.mock'; import { getResult, getMlResult } from '../routes/__mocks__/request_responses'; import { signalRulesAlertType } from './signal_rule_alert_type'; -import { alertsMock, AlertServicesMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks'; import { ruleStatusServiceFactory } from './rule_status_service'; import { getGapBetweenRuns } from './utils'; import { RuleExecutorOptions } from './types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts index 0357f906f8035..137603741dc8f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts @@ -66,6 +66,7 @@ export const signalRulesAlertType = ({ query, to, type, + exceptions_list, } = params; const searchAfterSize = Math.min(maxSignals, DEFAULT_SEARCH_AFTER_PAGE_SIZE); let hasError: boolean = false; @@ -200,6 +201,7 @@ export const signalRulesAlertType = ({ savedId, services, index: inputIndex, + lists: exceptions_list, }); const noReIndex = buildEventsSearchQuery({ diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts index 3401d7417ec62..6f3cc6e708fce 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.test.ts @@ -18,7 +18,7 @@ import { } from './__mocks__/es_results'; import { DEFAULT_SIGNALS_INDEX } from '../../../../common/constants'; import { singleBulkCreate, filterDuplicateRules } from './single_bulk_create'; -import { alertsMock, AlertServicesMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks'; describe('singleBulkCreate', () => { const mockService: AlertServicesMock = alertsMock.createAlertServices(); @@ -300,7 +300,7 @@ describe('singleBulkCreate', () => { _id: 'e1e08ddc-5e37-49ff-a258-5393aa44435a', _source: { someKey: 'someValue', - '@timestamp': 'someTimeStamp', + '@timestamp': '2020-04-20T21:27:45+0000', signal: { parent: { rule: '04128c15-0d1b-4716-a4c5-46997ac7f3bd', @@ -334,7 +334,7 @@ describe('singleBulkCreate', () => { test('filter duplicate rules will return back search responses if they do not have a signal and will NOT filter the source out', () => { const ancestors = sampleDocWithAncestors(); - ancestors.hits.hits[0]._source = { '@timestamp': 'some timestamp' }; + ancestors.hits.hits[0]._source = { '@timestamp': '2020-04-20T21:27:45+0000' }; const filtered = filterDuplicateRules('04128c15-0d1b-4716-a4c5-46997ac7f3bd', ancestors); expect(filtered).toEqual([ { @@ -343,7 +343,7 @@ describe('singleBulkCreate', () => { _score: 100, _version: 1, _id: 'e1e08ddc-5e37-49ff-a258-5393aa44435a', - _source: { '@timestamp': 'some timestamp' }, + _source: { '@timestamp': '2020-04-20T21:27:45+0000' }, }, ]); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts index 4373a35cac0c5..c098a4b68450d 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/single_bulk_create.ts @@ -6,13 +6,13 @@ import { countBy, isEmpty } from 'lodash'; import { performance } from 'perf_hooks'; -import { AlertServices } from '../../../../../../../plugins/alerting/server'; +import { AlertServices } from '../../../../../alerting/server'; import { SignalSearchResponse, BulkResponse } from './types'; import { RuleAlertAction } from '../../../../common/detection_engine/types'; import { RuleTypeParams, RefreshTypes } from '../types'; import { generateId, makeFloatString, errorAggregator } from './utils'; import { buildBulkBody } from './build_bulk_body'; -import { Logger } from '../../../../../../../../src/core/server'; +import { Logger } from '../../../../../../../src/core/server'; interface SingleBulkCreateParams { someResult: SignalSearchResponse; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_search_after.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/single_search_after.test.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_search_after.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/single_search_after.test.ts index dbeab70595e4f..580080966457e 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_search_after.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/single_search_after.test.ts @@ -10,7 +10,7 @@ import { sampleDocSearchResultsWithSortId, } from './__mocks__/es_results'; import { singleSearchAfter } from './single_search_after'; -import { alertsMock, AlertServicesMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsMock, AlertServicesMock } from '../../../../../alerting/server/mocks'; describe('singleSearchAfter', () => { const mockService: AlertServicesMock = alertsMock.createAlertServices(); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_search_after.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/single_search_after.ts similarity index 91% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_search_after.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/single_search_after.ts index 6fc8fe4bd24d9..8071c18713c19 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/single_search_after.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/single_search_after.ts @@ -5,8 +5,8 @@ */ import { performance } from 'perf_hooks'; -import { AlertServices } from '../../../../../../../plugins/alerting/server'; -import { Logger } from '../../../../../../../../src/core/server'; +import { AlertServices } from '../../../../../alerting/server'; +import { Logger } from '../../../../../../../src/core/server'; import { SignalSearchResponse } from './types'; import { buildEventsSearchQuery } from './build_events_query'; import { makeFloatString } from './utils'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/types.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/types.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/types.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/types.ts index a7556d992d20a..b493bab8b4610 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/types.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/types.ts @@ -4,14 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ +import { AlertType, State, AlertExecutorOptions } from '../../../../../alerting/server'; import { RuleAlertAction } from '../../../../common/detection_engine/types'; import { RuleAlertParams, OutputRuleAlertRest } from '../types'; import { SearchResponse } from '../../types'; -import { - AlertType, - State, - AlertExecutorOptions, -} from '../../../../../../../plugins/alerting/server'; export interface SignalsParams { signalIds: string[] | undefined | null; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/utils.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/utils.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/utils.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/utils.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/utils.ts b/x-pack/plugins/siem/server/lib/detection_engine/signals/utils.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/utils.ts rename to x-pack/plugins/siem/server/lib/detection_engine/signals/utils.ts index 077d3a9279c5e..f06c765073d78 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/utils.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/signals/utils.ts @@ -6,7 +6,8 @@ import { createHash } from 'crypto'; import moment from 'moment'; import dateMath from '@elastic/datemath'; -import { parseDuration } from '../../../../../../../plugins/alerting/server'; + +import { parseDuration } from '../../../../../alerting/server'; import { BulkResponse, BulkResponseErrorAggregation } from './types'; export const generateId = ( diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/tags/read_tags.test.ts b/x-pack/plugins/siem/server/lib/detection_engine/tags/read_tags.test.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/tags/read_tags.test.ts rename to x-pack/plugins/siem/server/lib/detection_engine/tags/read_tags.test.ts index 80c107c991bb7..d29d885f9797a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/tags/read_tags.test.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/tags/read_tags.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { alertsClientMock } from '../../../../../../../plugins/alerting/server/mocks'; +import { alertsClientMock } from '../../../../../alerting/server/mocks'; import { getResult, getFindResultWithMultiHits } from '../routes/__mocks__/request_responses'; import { INTERNAL_RULE_ID_KEY, INTERNAL_IDENTIFIER } from '../../../../common/constants'; import { readRawTags, readTags, convertTagsToSet, convertToTags, isTags } from './read_tags'; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/tags/read_tags.ts b/x-pack/plugins/siem/server/lib/detection_engine/tags/read_tags.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/tags/read_tags.ts rename to x-pack/plugins/siem/server/lib/detection_engine/tags/read_tags.ts index d343bca8c97bb..addd373712850 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/tags/read_tags.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/tags/read_tags.ts @@ -6,7 +6,7 @@ import { has } from 'lodash/fp'; import { INTERNAL_IDENTIFIER } from '../../../../common/constants'; -import { AlertsClient } from '../../../../../../../plugins/alerting/server'; +import { AlertsClient } from '../../../../../alerting/server'; import { findRules } from '../rules/find_rules'; export interface TagType { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/types.ts b/x-pack/plugins/siem/server/lib/detection_engine/types.ts similarity index 91% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/types.ts rename to x-pack/plugins/siem/server/lib/detection_engine/types.ts index 035f1b10ff8b2..f2026804da51a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/types.ts +++ b/x-pack/plugins/siem/server/lib/detection_engine/types.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { CallAPIOptions } from '../../../../../../../src/core/server'; -import { Filter } from '../../../../../../../src/plugins/data/server'; +import { CallAPIOptions } from '../../../../../../src/core/server'; +import { Filter } from '../../../../../../src/plugins/data/server'; import { IRuleStatusAttributes } from './rules/types'; import { ListsDefaultArraySchema } from './routes/schemas/types/lists_default_array'; import { RuleAlertAction, RuleType } from '../../../common/detection_engine/types'; @@ -24,7 +24,7 @@ export interface ThreatParams { technique: IMitreAttack[]; } -// Notice below we are using lists: ListsDefaultArraySchema[]; which is coming directly from the response output section. +// Notice below we are using lists: ListsAndArraySchema[]; which is coming directly from the response output section. // TODO: Eventually this whole RuleAlertParams will be replaced with io-ts. For now we can slowly strangle it out and reduce duplicate types // We don't have the input types defined through io-ts just yet but as we being introducing types from there we will more and more remove // types and share them between input and output schema but have an input Rule Schema and an output Rule Schema. @@ -34,6 +34,8 @@ export interface Meta { kibana_siem_app_url?: string | undefined; } +export type Language = 'kuery' | 'lucene'; + export interface RuleAlertParams { actions: RuleAlertAction[]; anomalyThreshold: number | undefined; @@ -47,7 +49,7 @@ export interface RuleAlertParams { index: string[] | undefined | null; interval: string; ruleId: string | undefined | null; - language: string | undefined | null; + language: Language | undefined | null; maxSignals: number; machineLearningJobId: string | undefined; riskScore: number; @@ -66,7 +68,7 @@ export interface RuleAlertParams { type: RuleType; version: number; throttle: string | undefined | null; - lists: ListsDefaultArraySchema | null | undefined; + exceptions_list: ListsDefaultArraySchema | null | undefined; } export type RuleTypeParams = Omit< diff --git a/x-pack/legacy/plugins/siem/server/lib/ecs_fields/extend_map.test.ts b/x-pack/plugins/siem/server/lib/ecs_fields/extend_map.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ecs_fields/extend_map.test.ts rename to x-pack/plugins/siem/server/lib/ecs_fields/extend_map.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/ecs_fields/extend_map.ts b/x-pack/plugins/siem/server/lib/ecs_fields/extend_map.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ecs_fields/extend_map.ts rename to x-pack/plugins/siem/server/lib/ecs_fields/extend_map.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/ecs_fields/index.ts b/x-pack/plugins/siem/server/lib/ecs_fields/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ecs_fields/index.ts rename to x-pack/plugins/siem/server/lib/ecs_fields/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/events/elasticsearch_adapter.test.ts b/x-pack/plugins/siem/server/lib/events/elasticsearch_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/events/elasticsearch_adapter.test.ts rename to x-pack/plugins/siem/server/lib/events/elasticsearch_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/events/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/events/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/events/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/events/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/events/index.ts b/x-pack/plugins/siem/server/lib/events/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/events/index.ts rename to x-pack/plugins/siem/server/lib/events/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/events/mock.ts b/x-pack/plugins/siem/server/lib/events/mock.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/events/mock.ts rename to x-pack/plugins/siem/server/lib/events/mock.ts index 3eb841cbad411..f5fb2f481ca77 100644 --- a/x-pack/legacy/plugins/siem/server/lib/events/mock.ts +++ b/x-pack/plugins/siem/server/lib/events/mock.ts @@ -5,7 +5,7 @@ */ import { cloneDeep } from 'lodash/fp'; -import { defaultIndexPattern } from '../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../common/constants'; import { RequestDetailsOptions } from './types'; export const mockResponseSearchTimelineDetails = { @@ -185,7 +185,7 @@ export const mockResponseSearchTimelineDetails = { export const mockOptions: RequestDetailsOptions = { indexName: 'auditbeat-8.0.0-2019.03.29-000003', eventId: 'TUfUymkBCQofM5eXGBYL', - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, }; export const mockRequest = { diff --git a/x-pack/legacy/plugins/siem/server/lib/events/query.dsl.ts b/x-pack/plugins/siem/server/lib/events/query.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/events/query.dsl.ts rename to x-pack/plugins/siem/server/lib/events/query.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/events/query.last_event_time.dsl.ts b/x-pack/plugins/siem/server/lib/events/query.last_event_time.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/events/query.last_event_time.dsl.ts rename to x-pack/plugins/siem/server/lib/events/query.last_event_time.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/events/types.ts b/x-pack/plugins/siem/server/lib/events/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/events/types.ts rename to x-pack/plugins/siem/server/lib/events/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/framework/index.ts b/x-pack/plugins/siem/server/lib/framework/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/framework/index.ts rename to x-pack/plugins/siem/server/lib/framework/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/framework/kibana_framework_adapter.ts b/x-pack/plugins/siem/server/lib/framework/kibana_framework_adapter.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/framework/kibana_framework_adapter.ts rename to x-pack/plugins/siem/server/lib/framework/kibana_framework_adapter.ts index 6b41426e047ca..762416149c0fb 100644 --- a/x-pack/legacy/plugins/siem/server/lib/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/siem/server/lib/framework/kibana_framework_adapter.ts @@ -13,9 +13,9 @@ import { KibanaResponseFactory, RequestHandlerContext, KibanaRequest, -} from '../../../../../../../src/core/server'; -import { IndexPatternsFetcher } from '../../../../../../../src/plugins/data/server'; -import { AuthenticatedUser } from '../../../../../../plugins/security/common/model'; +} from '../../../../../../src/core/server'; +import { IndexPatternsFetcher } from '../../../../../../src/plugins/data/server'; +import { AuthenticatedUser } from '../../../../security/common/model'; import { CoreSetup, SetupPlugins } from '../../plugin'; import { diff --git a/x-pack/legacy/plugins/siem/server/lib/framework/types.ts b/x-pack/plugins/siem/server/lib/framework/types.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/framework/types.ts rename to x-pack/plugins/siem/server/lib/framework/types.ts index 7d049d1dcd195..abe572df87063 100644 --- a/x-pack/legacy/plugins/siem/server/lib/framework/types.ts +++ b/x-pack/plugins/siem/server/lib/framework/types.ts @@ -7,8 +7,8 @@ import { IndicesGetMappingParams } from 'elasticsearch'; import { GraphQLSchema } from 'graphql'; -import { RequestHandlerContext, KibanaRequest } from '../../../../../../../src/core/server'; -import { AuthenticatedUser } from '../../../../../../plugins/security/common/model'; +import { RequestHandlerContext, KibanaRequest } from '../../../../../../src/core/server'; +import { AuthenticatedUser } from '../../../../security/common/model'; import { ESQuery } from '../../../common/typed_json'; import { PaginationInput, diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/elasticsearch_adapter.test.ts b/x-pack/plugins/siem/server/lib/hosts/elasticsearch_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/hosts/elasticsearch_adapter.test.ts rename to x-pack/plugins/siem/server/lib/hosts/elasticsearch_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/hosts/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/hosts/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/hosts/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/helpers.test.ts b/x-pack/plugins/siem/server/lib/hosts/helpers.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/hosts/helpers.test.ts rename to x-pack/plugins/siem/server/lib/hosts/helpers.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/helpers.ts b/x-pack/plugins/siem/server/lib/hosts/helpers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/hosts/helpers.ts rename to x-pack/plugins/siem/server/lib/hosts/helpers.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/index.ts b/x-pack/plugins/siem/server/lib/hosts/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/hosts/index.ts rename to x-pack/plugins/siem/server/lib/hosts/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/mock.ts b/x-pack/plugins/siem/server/lib/hosts/mock.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/hosts/mock.ts rename to x-pack/plugins/siem/server/lib/hosts/mock.ts index 6b72c4a5a2843..30082990b55f9 100644 --- a/x-pack/legacy/plugins/siem/server/lib/hosts/mock.ts +++ b/x-pack/plugins/siem/server/lib/hosts/mock.ts @@ -4,9 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { DEFAULT_INDEX_PATTERN } from '../../../common/constants'; import { Direction, HostsFields } from '../../graphql/types'; -import { defaultIndexPattern } from '../../../default_index_pattern'; - import { HostOverviewRequestOptions, HostLastFirstSeenRequestOptions, @@ -14,7 +13,7 @@ import { } from '.'; export const mockGetHostsOptions: HostsRequestOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { container: 'docker.container.name', @@ -297,7 +296,7 @@ export const mockGetHostOverviewOptions: HostOverviewRequestOptions = { }, }, timerange: { interval: '12h', to: 1554824274610, from: 1554737874610 }, - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, fields: [ '_id', 'host.architecture', @@ -501,7 +500,7 @@ export const mockGetHostOverviewResult = { }; export const mockGetHostLastFirstSeenOptions: HostLastFirstSeenRequestOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { container: 'docker.container.name', diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/query.detail_host.dsl.ts b/x-pack/plugins/siem/server/lib/hosts/query.detail_host.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/hosts/query.detail_host.dsl.ts rename to x-pack/plugins/siem/server/lib/hosts/query.detail_host.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/query.hosts.dsl.ts b/x-pack/plugins/siem/server/lib/hosts/query.hosts.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/hosts/query.hosts.dsl.ts rename to x-pack/plugins/siem/server/lib/hosts/query.hosts.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/query.last_first_seen_host.dsl.ts b/x-pack/plugins/siem/server/lib/hosts/query.last_first_seen_host.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/hosts/query.last_first_seen_host.dsl.ts rename to x-pack/plugins/siem/server/lib/hosts/query.last_first_seen_host.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/hosts/types.ts b/x-pack/plugins/siem/server/lib/hosts/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/hosts/types.ts rename to x-pack/plugins/siem/server/lib/hosts/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/index_fields/elasticsearch_adapter.test.ts b/x-pack/plugins/siem/server/lib/index_fields/elasticsearch_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/index_fields/elasticsearch_adapter.test.ts rename to x-pack/plugins/siem/server/lib/index_fields/elasticsearch_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/index_fields/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/index_fields/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/index_fields/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/index_fields/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/index_fields/index.ts b/x-pack/plugins/siem/server/lib/index_fields/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/index_fields/index.ts rename to x-pack/plugins/siem/server/lib/index_fields/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/index_fields/mock.ts b/x-pack/plugins/siem/server/lib/index_fields/mock.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/index_fields/mock.ts rename to x-pack/plugins/siem/server/lib/index_fields/mock.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/index_fields/types.ts b/x-pack/plugins/siem/server/lib/index_fields/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/index_fields/types.ts rename to x-pack/plugins/siem/server/lib/index_fields/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/ip_details/elasticsearch_adapter.test.ts b/x-pack/plugins/siem/server/lib/ip_details/elasticsearch_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ip_details/elasticsearch_adapter.test.ts rename to x-pack/plugins/siem/server/lib/ip_details/elasticsearch_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/ip_details/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/ip_details/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ip_details/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/ip_details/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/ip_details/index.ts b/x-pack/plugins/siem/server/lib/ip_details/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ip_details/index.ts rename to x-pack/plugins/siem/server/lib/ip_details/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/ip_details/mock.ts b/x-pack/plugins/siem/server/lib/ip_details/mock.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ip_details/mock.ts rename to x-pack/plugins/siem/server/lib/ip_details/mock.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/ip_details/query_overview.dsl.ts b/x-pack/plugins/siem/server/lib/ip_details/query_overview.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ip_details/query_overview.dsl.ts rename to x-pack/plugins/siem/server/lib/ip_details/query_overview.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/ip_details/query_users.dsl.ts b/x-pack/plugins/siem/server/lib/ip_details/query_users.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ip_details/query_users.dsl.ts rename to x-pack/plugins/siem/server/lib/ip_details/query_users.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/ip_details/types.ts b/x-pack/plugins/siem/server/lib/ip_details/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/ip_details/types.ts rename to x-pack/plugins/siem/server/lib/ip_details/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/elasticsearch_adapter.test.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/elasticsearch_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/elasticsearch_adapter.test.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/elasticsearch_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/helpers.test.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/helpers.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/helpers.test.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/helpers.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/helpers.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/helpers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/helpers.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/helpers.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/index.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/index.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/mock.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/mock.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/mock.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/mock.ts index ed9fbf0ba0646..a5affea2842a6 100644 --- a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/mock.ts +++ b/x-pack/plugins/siem/server/lib/kpi_hosts/mock.ts @@ -4,14 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { defaultIndexPattern } from '../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../common/constants'; import { RequestBasicOptions } from '../framework/types'; const FROM = new Date('2019-05-03T13:24:00.660Z').valueOf(); const TO = new Date('2019-05-04T13:24:00.660Z').valueOf(); export const mockKpiHostsOptions: RequestBasicOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { container: 'docker.container.name', @@ -27,7 +27,7 @@ export const mockKpiHostsOptions: RequestBasicOptions = { }; export const mockKpiHostDetailsOptions: RequestBasicOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { container: 'docker.container.name', @@ -290,7 +290,7 @@ export const mockKpiHostsResponse = { export const mockKpiHostsResponseNodata = { responses: [null, null, null] }; const mockMsearchHeader = { - index: defaultIndexPattern, + index: DEFAULT_INDEX_PATTERN, allowNoIndices: true, ignoreUnavailable: true, }; diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_authentication.dsl.test.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/query_authentication.dsl.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_authentication.dsl.test.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/query_authentication.dsl.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_authentication.dsl.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/query_authentication.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_authentication.dsl.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/query_authentication.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_hosts.dsl.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/query_hosts.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_hosts.dsl.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/query_hosts.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_unique_ips.dsl.test.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/query_unique_ips.dsl.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_unique_ips.dsl.test.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/query_unique_ips.dsl.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_unique_ips.dsl.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/query_unique_ips.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/query_unique_ips.dsl.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/query_unique_ips.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_hosts/types.ts b/x-pack/plugins/siem/server/lib/kpi_hosts/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_hosts/types.ts rename to x-pack/plugins/siem/server/lib/kpi_hosts/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/elastic_adapter.test.ts b/x-pack/plugins/siem/server/lib/kpi_network/elastic_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/elastic_adapter.test.ts rename to x-pack/plugins/siem/server/lib/kpi_network/elastic_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/kpi_network/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/kpi_network/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/helpers.ts b/x-pack/plugins/siem/server/lib/kpi_network/helpers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/helpers.ts rename to x-pack/plugins/siem/server/lib/kpi_network/helpers.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/index.ts b/x-pack/plugins/siem/server/lib/kpi_network/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/index.ts rename to x-pack/plugins/siem/server/lib/kpi_network/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/mock.ts b/x-pack/plugins/siem/server/lib/kpi_network/mock.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/mock.ts rename to x-pack/plugins/siem/server/lib/kpi_network/mock.ts index 7d86769de09f1..cc0849ccdf1d2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/kpi_network/mock.ts +++ b/x-pack/plugins/siem/server/lib/kpi_network/mock.ts @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { defaultIndexPattern } from '../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../common/constants'; import { RequestBasicOptions } from '../framework/types'; export const mockOptions: RequestBasicOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { container: 'docker.container.name', diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/query_dns.dsl.ts b/x-pack/plugins/siem/server/lib/kpi_network/query_dns.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/query_dns.dsl.ts rename to x-pack/plugins/siem/server/lib/kpi_network/query_dns.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/query_network_events.ts b/x-pack/plugins/siem/server/lib/kpi_network/query_network_events.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/query_network_events.ts rename to x-pack/plugins/siem/server/lib/kpi_network/query_network_events.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/query_tls_handshakes.dsl.ts b/x-pack/plugins/siem/server/lib/kpi_network/query_tls_handshakes.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/query_tls_handshakes.dsl.ts rename to x-pack/plugins/siem/server/lib/kpi_network/query_tls_handshakes.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/query_unique_flow.ts b/x-pack/plugins/siem/server/lib/kpi_network/query_unique_flow.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/query_unique_flow.ts rename to x-pack/plugins/siem/server/lib/kpi_network/query_unique_flow.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/query_unique_private_ips.dsl.ts b/x-pack/plugins/siem/server/lib/kpi_network/query_unique_private_ips.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/query_unique_private_ips.dsl.ts rename to x-pack/plugins/siem/server/lib/kpi_network/query_unique_private_ips.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/kpi_network/types.ts b/x-pack/plugins/siem/server/lib/kpi_network/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/kpi_network/types.ts rename to x-pack/plugins/siem/server/lib/kpi_network/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/machine_learning/index.ts b/x-pack/plugins/siem/server/lib/machine_learning/index.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/machine_learning/index.ts rename to x-pack/plugins/siem/server/lib/machine_learning/index.ts index aa83df15f68d4..35789b5e202e2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/machine_learning/index.ts +++ b/x-pack/plugins/siem/server/lib/machine_learning/index.ts @@ -6,8 +6,8 @@ import { SearchResponse } from 'elasticsearch'; -import { AlertServices } from '../../../../../../plugins/alerting/server'; -import { AnomalyRecordDoc as Anomaly } from '../../../../../../plugins/ml/common/types/anomalies'; +import { AlertServices } from '../../../../alerting/server'; +import { AnomalyRecordDoc as Anomaly } from '../../../../ml/common/types/anomalies'; export { Anomaly }; export type AnomalyResults = SearchResponse; diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/elasticseatch_adapter.test.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/elasticseatch_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/elasticseatch_adapter.test.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/elasticseatch_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/index.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/index.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/mock.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/mock.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/mock.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/mock.ts index 3e51e926bea87..1d1ebfff936d2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/mock.ts +++ b/x-pack/plugins/siem/server/lib/matrix_histogram/mock.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { defaultIndexPattern } from '../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../common/constants'; import { HistogramType } from '../../graphql/types'; export const mockAlertsHistogramDataResponse = { @@ -111,7 +111,7 @@ export const mockOptions = { to: 9999, from: 1234, }, - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, filterQuery: '', stackByField: 'event.module', histogramType: HistogramType.alerts, diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query.anomalies_over_time.dsl.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/query.anomalies_over_time.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query.anomalies_over_time.dsl.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/query.anomalies_over_time.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query.authentications_over_time.dsl.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/query.authentications_over_time.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query.authentications_over_time.dsl.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/query.authentications_over_time.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query.events_over_time.dsl.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/query.events_over_time.dsl.ts similarity index 83% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query.events_over_time.dsl.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/query.events_over_time.dsl.ts index 3a4281b980cc4..63649a1064b02 100644 --- a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query.events_over_time.dsl.ts +++ b/x-pack/plugins/siem/server/lib/matrix_histogram/query.events_over_time.dsl.ts @@ -3,9 +3,13 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + +import { showAllOthersBucket } from '../../../common/constants'; import { createQueryFilterClauses, calculateTimeSeriesInterval } from '../../utils/build_query'; import { MatrixHistogramRequestOptions } from '../framework'; +import * as i18n from './translations'; + export const buildEventsOverTimeQuery = ({ filterQuery, timerange: { from, to }, @@ -41,11 +45,19 @@ export const buildEventsOverTimeQuery = ({ }, }, }; + + const missing = + stackByField != null && showAllOthersBucket.includes(stackByField) + ? { + missing: stackByField?.endsWith('.ip') ? '0.0.0.0' : i18n.ALL_OTHERS, + } + : {}; + return { eventActionGroup: { terms: { field: stackByField, - missing: 'All others', + ...missing, order: { _count: 'desc', }, diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query_alerts.dsl.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/query_alerts.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query_alerts.dsl.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/query_alerts.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query_dns_histogram.dsl.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/query_dns_histogram.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/query_dns_histogram.dsl.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/query_dns_histogram.dsl.ts diff --git a/x-pack/legacy/plugins/logstash/public/services/security/logstash_security.js b/x-pack/plugins/siem/server/lib/matrix_histogram/translations.ts old mode 100755 new mode 100644 similarity index 55% rename from x-pack/legacy/plugins/logstash/public/services/security/logstash_security.js rename to x-pack/plugins/siem/server/lib/matrix_histogram/translations.ts index 0949038c9b6c7..413acaa2d4b0a --- a/x-pack/legacy/plugins/logstash/public/services/security/logstash_security.js +++ b/x-pack/plugins/siem/server/lib/matrix_histogram/translations.ts @@ -4,10 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { xpackInfo } from 'plugins/xpack_main/services/xpack_info'; +import { i18n } from '@kbn/i18n'; -export const logstashSecurity = { - isSecurityEnabled() { - return Boolean(xpackInfo.get(`features.security`)); - }, -}; +export const ALL_OTHERS = i18n.translate( + 'xpack.siem.detectionEngine.signals.histogram.allOthersGroupingLabel', + { + defaultMessage: 'All others', + } +); diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/types.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/types.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/matrix_histogram/utils.ts b/x-pack/plugins/siem/server/lib/matrix_histogram/utils.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/matrix_histogram/utils.ts rename to x-pack/plugins/siem/server/lib/matrix_histogram/utils.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/network/__snapshots__/elastic_adapter.test.ts.snap b/x-pack/plugins/siem/server/lib/network/__snapshots__/elastic_adapter.test.ts.snap similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/network/__snapshots__/elastic_adapter.test.ts.snap rename to x-pack/plugins/siem/server/lib/network/__snapshots__/elastic_adapter.test.ts.snap diff --git a/x-pack/legacy/plugins/siem/server/lib/network/elastic_adapter.test.ts b/x-pack/plugins/siem/server/lib/network/elastic_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/network/elastic_adapter.test.ts rename to x-pack/plugins/siem/server/lib/network/elastic_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/network/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/network/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/network/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/network/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/network/index.ts b/x-pack/plugins/siem/server/lib/network/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/network/index.ts rename to x-pack/plugins/siem/server/lib/network/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/network/mock.ts b/x-pack/plugins/siem/server/lib/network/mock.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/network/mock.ts rename to x-pack/plugins/siem/server/lib/network/mock.ts index 7ea692f27ef04..38e82a4f19dca 100644 --- a/x-pack/legacy/plugins/siem/server/lib/network/mock.ts +++ b/x-pack/plugins/siem/server/lib/network/mock.ts @@ -4,13 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import { defaultIndexPattern } from '../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../common/constants'; import { Direction, FlowTargetSourceDest, NetworkTopTablesFields } from '../../graphql/types'; import { NetworkTopNFlowRequestOptions } from '.'; export const mockOptions: NetworkTopNFlowRequestOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { container: 'docker.container.name', diff --git a/x-pack/legacy/plugins/siem/server/lib/network/query_dns.dsl.ts b/x-pack/plugins/siem/server/lib/network/query_dns.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/network/query_dns.dsl.ts rename to x-pack/plugins/siem/server/lib/network/query_dns.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/network/query_http.dsl.ts b/x-pack/plugins/siem/server/lib/network/query_http.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/network/query_http.dsl.ts rename to x-pack/plugins/siem/server/lib/network/query_http.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/network/query_top_countries.dsl.ts b/x-pack/plugins/siem/server/lib/network/query_top_countries.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/network/query_top_countries.dsl.ts rename to x-pack/plugins/siem/server/lib/network/query_top_countries.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/network/query_top_n_flow.dsl.ts b/x-pack/plugins/siem/server/lib/network/query_top_n_flow.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/network/query_top_n_flow.dsl.ts rename to x-pack/plugins/siem/server/lib/network/query_top_n_flow.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/network/types.ts b/x-pack/plugins/siem/server/lib/network/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/network/types.ts rename to x-pack/plugins/siem/server/lib/network/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/note/saved_object.ts b/x-pack/plugins/siem/server/lib/note/saved_object.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/note/saved_object.ts rename to x-pack/plugins/siem/server/lib/note/saved_object.ts index 23162f38bffba..2b94fd4516786 100644 --- a/x-pack/legacy/plugins/siem/server/lib/note/saved_object.ts +++ b/x-pack/plugins/siem/server/lib/note/saved_object.ts @@ -12,8 +12,8 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { map, fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; -import { SavedObjectsFindOptions } from '../../../../../../../src/core/server'; -import { AuthenticatedUser } from '../../../../../../plugins/security/common/model'; +import { SavedObjectsFindOptions } from '../../../../../../src/core/server'; +import { AuthenticatedUser } from '../../../../security/common/model'; import { UNAUTHENTICATED_USER } from '../../../common/constants'; import { PageInfoNote, diff --git a/x-pack/legacy/plugins/siem/server/lib/note/saved_object_mappings.ts b/x-pack/plugins/siem/server/lib/note/saved_object_mappings.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/note/saved_object_mappings.ts rename to x-pack/plugins/siem/server/lib/note/saved_object_mappings.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/note/types.ts b/x-pack/plugins/siem/server/lib/note/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/note/types.ts rename to x-pack/plugins/siem/server/lib/note/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/overview/elastic_adapter.test.ts b/x-pack/plugins/siem/server/lib/overview/elastic_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/overview/elastic_adapter.test.ts rename to x-pack/plugins/siem/server/lib/overview/elastic_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/overview/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/overview/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/overview/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/overview/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/overview/index.ts b/x-pack/plugins/siem/server/lib/overview/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/overview/index.ts rename to x-pack/plugins/siem/server/lib/overview/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/overview/mock.ts b/x-pack/plugins/siem/server/lib/overview/mock.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/overview/mock.ts rename to x-pack/plugins/siem/server/lib/overview/mock.ts index 410b4d90b1e78..51d8a258569a8 100644 --- a/x-pack/legacy/plugins/siem/server/lib/overview/mock.ts +++ b/x-pack/plugins/siem/server/lib/overview/mock.ts @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { defaultIndexPattern } from '../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../common/constants'; import { RequestBasicOptions } from '../framework/types'; export const mockOptionsNetwork: RequestBasicOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { container: 'docker.container.name', @@ -79,7 +79,7 @@ export const mockResultNetwork = { }; export const mockOptionsHost: RequestBasicOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { container: 'docker.container.name', diff --git a/x-pack/legacy/plugins/siem/server/lib/overview/query.dsl.ts b/x-pack/plugins/siem/server/lib/overview/query.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/overview/query.dsl.ts rename to x-pack/plugins/siem/server/lib/overview/query.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/overview/types.ts b/x-pack/plugins/siem/server/lib/overview/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/overview/types.ts rename to x-pack/plugins/siem/server/lib/overview/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/pinned_event/saved_object.ts b/x-pack/plugins/siem/server/lib/pinned_event/saved_object.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/pinned_event/saved_object.ts rename to x-pack/plugins/siem/server/lib/pinned_event/saved_object.ts index a95c1da197f57..7fc23d86d8218 100644 --- a/x-pack/legacy/plugins/siem/server/lib/pinned_event/saved_object.ts +++ b/x-pack/plugins/siem/server/lib/pinned_event/saved_object.ts @@ -10,8 +10,8 @@ import { pipe } from 'fp-ts/lib/pipeable'; import { map, fold } from 'fp-ts/lib/Either'; import { identity } from 'fp-ts/lib/function'; -import { SavedObjectsFindOptions } from '../../../../../../../src/core/server'; -import { AuthenticatedUser } from '../../../../../../plugins/security/common/model'; +import { SavedObjectsFindOptions } from '../../../../../../src/core/server'; +import { AuthenticatedUser } from '../../../../security/common/model'; import { UNAUTHENTICATED_USER } from '../../../common/constants'; import { FrameworkRequest } from '../framework'; import { diff --git a/x-pack/legacy/plugins/siem/server/lib/pinned_event/saved_object_mappings.ts b/x-pack/plugins/siem/server/lib/pinned_event/saved_object_mappings.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/pinned_event/saved_object_mappings.ts rename to x-pack/plugins/siem/server/lib/pinned_event/saved_object_mappings.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/pinned_event/types.ts b/x-pack/plugins/siem/server/lib/pinned_event/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/pinned_event/types.ts rename to x-pack/plugins/siem/server/lib/pinned_event/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/source_status/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/source_status/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/source_status/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/source_status/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/source_status/index.ts b/x-pack/plugins/siem/server/lib/source_status/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/source_status/index.ts rename to x-pack/plugins/siem/server/lib/source_status/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/source_status/query.dsl.ts b/x-pack/plugins/siem/server/lib/source_status/query.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/source_status/query.dsl.ts rename to x-pack/plugins/siem/server/lib/source_status/query.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/source_status/types.ts b/x-pack/plugins/siem/server/lib/source_status/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/source_status/types.ts rename to x-pack/plugins/siem/server/lib/source_status/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/sources/configuration.test.ts b/x-pack/plugins/siem/server/lib/sources/configuration.test.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/lib/sources/configuration.test.ts rename to x-pack/plugins/siem/server/lib/sources/configuration.test.ts index b1b149d17a9f5..00fca7b77de49 100644 --- a/x-pack/legacy/plugins/siem/server/lib/sources/configuration.test.ts +++ b/x-pack/plugins/siem/server/lib/sources/configuration.test.ts @@ -4,9 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import { DEFAULT_INDEX_PATTERN } from '../../../common/constants'; import { InmemoryConfigurationAdapter } from '../configuration/inmemory_configuration_adapter'; -import { defaultIndexPattern } from '../../../default_index_pattern'; - import { ConfigurationSourcesAdapter } from './configuration'; import { PartialSourceConfiguration } from './types'; @@ -76,7 +75,7 @@ describe('the ConfigurationSourcesAdapter', () => { new InmemoryConfigurationAdapter({ sources: { sourceOne: { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, fields: { container: 'DIFFERENT_CONTAINER_FIELD', }, diff --git a/x-pack/legacy/plugins/siem/server/lib/sources/configuration.ts b/x-pack/plugins/siem/server/lib/sources/configuration.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/sources/configuration.ts rename to x-pack/plugins/siem/server/lib/sources/configuration.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/sources/index.ts b/x-pack/plugins/siem/server/lib/sources/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/sources/index.ts rename to x-pack/plugins/siem/server/lib/sources/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/sources/types.ts b/x-pack/plugins/siem/server/lib/sources/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/sources/types.ts rename to x-pack/plugins/siem/server/lib/sources/types.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/convert_saved_object_to_savedtimeline.ts b/x-pack/plugins/siem/server/lib/timeline/convert_saved_object_to_savedtimeline.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/timeline/convert_saved_object_to_savedtimeline.ts rename to x-pack/plugins/siem/server/lib/timeline/convert_saved_object_to_savedtimeline.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/create_timelines_stream_from_ndjson.ts b/x-pack/plugins/siem/server/lib/timeline/create_timelines_stream_from_ndjson.ts similarity index 97% rename from x-pack/legacy/plugins/siem/server/lib/timeline/create_timelines_stream_from_ndjson.ts rename to x-pack/plugins/siem/server/lib/timeline/create_timelines_stream_from_ndjson.ts index 16654b2863ee5..abe8de9bf5b94 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/create_timelines_stream_from_ndjson.ts +++ b/x-pack/plugins/siem/server/lib/timeline/create_timelines_stream_from_ndjson.ts @@ -13,7 +13,7 @@ import { createConcatStream, createSplitStream, createMapStream, -} from '../../../../../../../src/legacy/utils'; +} from '../../../../../../src/legacy/utils'; import { parseNdjsonStrings, filterExportedCounts, diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/pick_saved_timeline.ts b/x-pack/plugins/siem/server/lib/timeline/pick_saved_timeline.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/lib/timeline/pick_saved_timeline.ts rename to x-pack/plugins/siem/server/lib/timeline/pick_saved_timeline.ts index 5b60086ae81b6..19adb7ac1045a 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/pick_saved_timeline.ts +++ b/x-pack/plugins/siem/server/lib/timeline/pick_saved_timeline.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AuthenticatedUser } from '../../../../../../plugins/security/common/model'; +import { AuthenticatedUser } from '../../../../security/common/model'; import { UNAUTHENTICATED_USER } from '../../../common/constants'; import { SavedTimeline } from './types'; diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/__mocks__/import_timelines.ts b/x-pack/plugins/siem/server/lib/timeline/routes/__mocks__/import_timelines.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/__mocks__/import_timelines.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/__mocks__/import_timelines.ts index 74d3744e29299..686f2b491cf88 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/__mocks__/import_timelines.ts +++ b/x-pack/plugins/siem/server/lib/timeline/routes/__mocks__/import_timelines.ts @@ -163,13 +163,6 @@ export const mockParsedTimelineObject = omit( mockUniqueParsedObjects[0] ); -export const mockConfig = { - get: () => { - return 100000000; - }, - has: jest.fn(), -}; - export const mockGetCurrentUser = { user: { username: 'mockUser', diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/__mocks__/request_responses.ts b/x-pack/plugins/siem/server/lib/timeline/routes/__mocks__/request_responses.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/__mocks__/request_responses.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/__mocks__/request_responses.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/export_timelines_route.test.ts b/x-pack/plugins/siem/server/lib/timeline/routes/export_timelines_route.test.ts similarity index 80% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/export_timelines_route.test.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/export_timelines_route.test.ts index 4eadede40f5d9..2bccb7c393837 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/export_timelines_route.test.ts +++ b/x-pack/plugins/siem/server/lib/timeline/routes/export_timelines_route.test.ts @@ -16,6 +16,7 @@ import { serverMock, requestContextMock, requestMock, + createMockConfig, } from '../../detection_engine/routes/__mocks__'; import { TIMELINE_EXPORT_URL } from '../../../../common/constants'; import { convertSavedObjectToSavedNote } from '../../note/saved_object'; @@ -41,14 +42,6 @@ jest.mock('../../pinned_event/saved_object', () => { describe('export timelines', () => { let server: ReturnType; let { clients, context } = requestContextMock.createTools(); - const config = jest.fn().mockImplementation(() => { - return { - get: () => { - return 100; - }, - has: jest.fn(), - }; - }); beforeEach(() => { server = serverMock.create(); @@ -61,7 +54,7 @@ describe('export timelines', () => { ((convertSavedObjectToSavedPinnedEvent as unknown) as jest.Mock).mockReturnValue( mockPinnedEvents() ); - exportTimelinesRoute(server.router, config); + exportTimelinesRoute(server.router, createMockConfig()); }); describe('status codes', () => { @@ -92,7 +85,7 @@ describe('export timelines', () => { const result = server.validate(request); expect(result.badRequest.mock.calls[0][0]).toEqual( - 'Invalid value undefined supplied to : { ids: Array }/ids: Array' + 'Invalid value "undefined" supplied to "ids"' ); }); @@ -105,11 +98,7 @@ describe('export timelines', () => { const result = server.validate(request); expect(result.badRequest.mock.calls[1][0]).toEqual( - [ - 'Invalid value undefined supplied to : { file_name: string, exclude_export_details: ("true" | "false") }/file_name: string', - 'Invalid value undefined supplied to : { file_name: string, exclude_export_details: ("true" | "false") }/exclude_export_details: ("true" | "false")/0: "true"', - 'Invalid value undefined supplied to : { file_name: string, exclude_export_details: ("true" | "false") }/exclude_export_details: ("true" | "false")/1: "false"', - ].join('\n') + 'Invalid value "undefined" supplied to "file_name",Invalid value "undefined" supplied to "exclude_export_details",Invalid value "undefined" supplied to "exclude_export_details"' ); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/export_timelines_route.ts b/x-pack/plugins/siem/server/lib/timeline/routes/export_timelines_route.ts similarity index 87% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/export_timelines_route.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/export_timelines_route.ts index fa849c1c325a9..c59f6eb6ce3da 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/export_timelines_route.ts +++ b/x-pack/plugins/siem/server/lib/timeline/routes/export_timelines_route.ts @@ -5,11 +5,11 @@ */ import { set as _set } from 'lodash/fp'; -import { IRouter } from '../../../../../../../../src/core/server'; -import { LegacyServices } from '../../../types'; -import { transformError, buildSiemResponse } from '../../detection_engine/routes/utils'; import { TIMELINE_EXPORT_URL } from '../../../../common/constants'; +import { IRouter } from '../../../../../../../src/core/server'; +import { ConfigType } from '../../..'; +import { transformError, buildSiemResponse } from '../../detection_engine/routes/utils'; import { getExportTimelineByObjectIds } from './utils/export_timelines'; import { @@ -18,7 +18,7 @@ import { } from './schemas/export_timelines_schema'; import { buildRouteValidation } from '../../../utils/build_validation/route_validation'; -export const exportTimelinesRoute = (router: IRouter, config: LegacyServices['config']) => { +export const exportTimelinesRoute = (router: IRouter, config: ConfigType) => { router.post( { path: TIMELINE_EXPORT_URL, @@ -34,7 +34,7 @@ export const exportTimelinesRoute = (router: IRouter, config: LegacyServices['co try { const siemResponse = buildSiemResponse(response); const savedObjectsClient = context.core.savedObjects.client; - const exportSizeLimit = config().get('savedObjects.maxImportExportSize'); + const exportSizeLimit = config.maxTimelineImportExportSize; if (request.body?.ids != null && request.body.ids.length > exportSizeLimit) { return siemResponse.error({ diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.test.ts b/x-pack/plugins/siem/server/lib/timeline/routes/import_timelines_route.test.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.test.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/import_timelines_route.test.ts index 352f8f0a355fc..9f41943cfa27f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.test.ts +++ b/x-pack/plugins/siem/server/lib/timeline/routes/import_timelines_route.test.ts @@ -6,15 +6,15 @@ import { getImportTimelinesRequest } from './__mocks__/request_responses'; import { + createMockConfig, serverMock, requestContextMock, requestMock, } from '../../detection_engine/routes/__mocks__'; import { TIMELINE_EXPORT_URL } from '../../../../common/constants'; -import { SecurityPluginSetup } from '../../../../../../../plugins/security/server'; +import { SecurityPluginSetup } from '../../../../../security/server'; import { - mockConfig, mockUniqueParsedObjects, mockParsedObjects, mockDuplicateIdErrors, @@ -24,7 +24,7 @@ import { } from './__mocks__/import_timelines'; describe('import timelines', () => { - let config: jest.Mock; + let config: ReturnType; let server: ReturnType; let request: ReturnType; let securitySetup: SecurityPluginSetup; @@ -43,9 +43,7 @@ describe('import timelines', () => { server = serverMock.create(); context = requestContextMock.createTools().context; - config = jest.fn().mockImplementation(() => { - return mockConfig; - }); + config = createMockConfig(); securitySetup = ({ authc: { @@ -65,7 +63,7 @@ describe('import timelines', () => { }; }); - jest.doMock('../../../../../../../../src/legacy/utils', () => { + jest.doMock('../../../../../../../src/legacy/utils', () => { return { createPromiseFromStreams: jest.fn().mockReturnValue(mockParsedObjects), }; @@ -334,10 +332,7 @@ describe('import timelines', () => { const result = server.validate(request); expect(result.badRequest).toHaveBeenCalledWith( - [ - 'Invalid value undefined supplied to : { file: (ReadableRt & { hapi: { filename: string } }) }/file: (ReadableRt & { hapi: { filename: string } })/0: ReadableRt', - 'Invalid value undefined supplied to : { file: (ReadableRt & { hapi: { filename: string } }) }/file: (ReadableRt & { hapi: { filename: string } })/1: { hapi: { filename: string } }', - ].join('\n') + 'Invalid value "undefined" supplied to "file",Invalid value "undefined" supplied to "file"' ); }); }); diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts b/x-pack/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts similarity index 95% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts index ad7ee28d8ad51..258ef9faf671b 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts +++ b/x-pack/plugins/siem/server/lib/timeline/routes/import_timelines_route.ts @@ -7,6 +7,7 @@ import { extname } from 'path'; import { chunk, omit, set } from 'lodash/fp'; +import { TIMELINE_IMPORT_URL } from '../../../../common/constants'; import { buildSiemResponse, createBulkErrorObject, @@ -15,7 +16,7 @@ import { } from '../../detection_engine/routes/utils'; import { createTimelinesStreamFromNdJson } from '../create_timelines_stream_from_ndjson'; -import { createPromiseFromStreams } from '../../../../../../../../src/legacy/utils'; +import { createPromiseFromStreams } from '../../../../../../../src/legacy/utils'; import { createTimelines, @@ -27,12 +28,11 @@ import { PromiseFromStreams, } from './utils/import_timelines'; -import { IRouter } from '../../../../../../../../src/core/server'; -import { TIMELINE_IMPORT_URL } from '../../../../common/constants'; +import { IRouter } from '../../../../../../../src/core/server'; import { SetupPlugins } from '../../../plugin'; import { ImportTimelinesPayloadSchemaRt } from './schemas/import_timelines_schema'; import { importRulesSchema } from '../../detection_engine/routes/schemas/response/import_rules_schema'; -import { LegacyServices } from '../../../types'; +import { ConfigType } from '../../..'; import { Timeline } from '../saved_object'; import { validate } from '../../detection_engine/routes/rules/validate'; @@ -44,7 +44,7 @@ const timelineLib = new Timeline(); export const importTimelinesRoute = ( router: IRouter, - config: LegacyServices['config'], + config: ConfigType, security: SetupPlugins['security'] ) => { router.post( @@ -56,7 +56,7 @@ export const importTimelinesRoute = ( options: { tags: ['access:siem'], body: { - maxBytes: config().get('savedObjects.maxImportPayloadBytes'), + maxBytes: config.maxTimelineImportPayloadBytes, output: 'stream', }, }, @@ -81,7 +81,7 @@ export const importTimelinesRoute = ( }); } - const objectLimit = config().get('savedObjects.maxImportExportSize'); + const objectLimit = config.maxTimelineImportExportSize; const readStream = createTimelinesStreamFromNdJson(objectLimit); const parsedObjects = await createPromiseFromStreams([ diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/schemas/export_timelines_schema.ts b/x-pack/plugins/siem/server/lib/timeline/routes/schemas/export_timelines_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/schemas/export_timelines_schema.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/schemas/export_timelines_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/schemas/import_timelines_schema.ts b/x-pack/plugins/siem/server/lib/timeline/routes/schemas/import_timelines_schema.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/schemas/import_timelines_schema.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/schemas/import_timelines_schema.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/schemas/schemas.ts b/x-pack/plugins/siem/server/lib/timeline/routes/schemas/schemas.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/schemas/schemas.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/schemas/schemas.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/utils/export_timelines.ts b/x-pack/plugins/siem/server/lib/timeline/routes/utils/export_timelines.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/utils/export_timelines.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/utils/export_timelines.ts index 52ee2a891c9bb..edd4abe0d76b5 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/utils/export_timelines.ts +++ b/x-pack/plugins/siem/server/lib/timeline/routes/utils/export_timelines.ts @@ -21,7 +21,7 @@ import { SavedObjectsClient, SavedObjectsFindOptions, SavedObjectsFindResponse, -} from '../../../../../../../../../src/core/server'; +} from '../../../../../../../../src/core/server'; import { ExportedTimelines, diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/routes/utils/import_timelines.ts b/x-pack/plugins/siem/server/lib/timeline/routes/utils/import_timelines.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/timeline/routes/utils/import_timelines.ts rename to x-pack/plugins/siem/server/lib/timeline/routes/utils/import_timelines.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/saved_object.test.ts b/x-pack/plugins/siem/server/lib/timeline/saved_object.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/timeline/saved_object.test.ts rename to x-pack/plugins/siem/server/lib/timeline/saved_object.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/saved_object.ts b/x-pack/plugins/siem/server/lib/timeline/saved_object.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/timeline/saved_object.ts rename to x-pack/plugins/siem/server/lib/timeline/saved_object.ts index bc6975331ad9b..e8cd27947589f 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/saved_object.ts +++ b/x-pack/plugins/siem/server/lib/timeline/saved_object.ts @@ -6,7 +6,7 @@ import { getOr } from 'lodash/fp'; -import { SavedObjectsFindOptions } from '../../../../../../../src/core/server'; +import { SavedObjectsFindOptions } from '../../../../../../src/core/server'; import { UNAUTHENTICATED_USER } from '../../../common/constants'; import { ResponseTimeline, diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/saved_object_mappings.ts b/x-pack/plugins/siem/server/lib/timeline/saved_object_mappings.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/timeline/saved_object_mappings.ts rename to x-pack/plugins/siem/server/lib/timeline/saved_object_mappings.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/timeline/types.ts b/x-pack/plugins/siem/server/lib/timeline/types.ts similarity index 99% rename from x-pack/legacy/plugins/siem/server/lib/timeline/types.ts rename to x-pack/plugins/siem/server/lib/timeline/types.ts index 523221192eca4..0bce3300591c2 100644 --- a/x-pack/legacy/plugins/siem/server/lib/timeline/types.ts +++ b/x-pack/plugins/siem/server/lib/timeline/types.ts @@ -14,7 +14,7 @@ import { PinnedEventToReturnSavedObjectRuntimeType, PinnedEventSavedObject, } from '../pinned_event/types'; -import { SavedObjectsClient } from '../../../../../../../src/core/server'; +import { SavedObjectsClient } from '../../../../../../src/core/server'; /* * ColumnHeader Types diff --git a/x-pack/legacy/plugins/siem/server/lib/tls/elasticsearch_adapter.test.ts b/x-pack/plugins/siem/server/lib/tls/elasticsearch_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/tls/elasticsearch_adapter.test.ts rename to x-pack/plugins/siem/server/lib/tls/elasticsearch_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/tls/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/tls/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/tls/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/tls/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/tls/index.ts b/x-pack/plugins/siem/server/lib/tls/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/tls/index.ts rename to x-pack/plugins/siem/server/lib/tls/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/tls/mock.ts b/x-pack/plugins/siem/server/lib/tls/mock.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/tls/mock.ts rename to x-pack/plugins/siem/server/lib/tls/mock.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/tls/query_tls.dsl.ts b/x-pack/plugins/siem/server/lib/tls/query_tls.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/tls/query_tls.dsl.ts rename to x-pack/plugins/siem/server/lib/tls/query_tls.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/tls/types.ts b/x-pack/plugins/siem/server/lib/tls/types.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/tls/types.ts rename to x-pack/plugins/siem/server/lib/tls/types.ts index 1fbb31ba3e0f3..f18ddc04e14a0 100644 --- a/x-pack/legacy/plugins/siem/server/lib/tls/types.ts +++ b/x-pack/plugins/siem/server/lib/tls/types.ts @@ -5,7 +5,7 @@ */ import { FrameworkRequest, RequestBasicOptions } from '../framework'; -import { TlsData } from '../../../public/graphql/types'; +import { TlsData } from '../../graphql/types'; export interface TlsAdapter { getTls(request: FrameworkRequest, options: RequestBasicOptions): Promise; diff --git a/x-pack/legacy/plugins/siem/server/lib/types.ts b/x-pack/plugins/siem/server/lib/types.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/types.ts rename to x-pack/plugins/siem/server/lib/types.ts index 323ced734d24b..a74fe8f778ba9 100644 --- a/x-pack/legacy/plugins/siem/server/lib/types.ts +++ b/x-pack/plugins/siem/server/lib/types.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { AuthenticatedUser } from '../../../../../plugins/security/public'; -import { RequestHandlerContext } from '../../../../../../src/core/server'; -export { ConfigType as Configuration } from '../../../../../plugins/siem/server'; +import { AuthenticatedUser } from '../../../security/public'; +import { RequestHandlerContext } from '../../../../../src/core/server'; +export { ConfigType as Configuration } from '../'; import { Authentications } from './authentications'; import { Events } from './events'; diff --git a/x-pack/legacy/plugins/siem/server/lib/uncommon_processes/elasticsearch_adapter.test.ts b/x-pack/plugins/siem/server/lib/uncommon_processes/elasticsearch_adapter.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/uncommon_processes/elasticsearch_adapter.test.ts rename to x-pack/plugins/siem/server/lib/uncommon_processes/elasticsearch_adapter.test.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/uncommon_processes/elasticsearch_adapter.ts b/x-pack/plugins/siem/server/lib/uncommon_processes/elasticsearch_adapter.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/uncommon_processes/elasticsearch_adapter.ts rename to x-pack/plugins/siem/server/lib/uncommon_processes/elasticsearch_adapter.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/uncommon_processes/index.ts b/x-pack/plugins/siem/server/lib/uncommon_processes/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/uncommon_processes/index.ts rename to x-pack/plugins/siem/server/lib/uncommon_processes/index.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/uncommon_processes/query.dsl.ts b/x-pack/plugins/siem/server/lib/uncommon_processes/query.dsl.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/uncommon_processes/query.dsl.ts rename to x-pack/plugins/siem/server/lib/uncommon_processes/query.dsl.ts diff --git a/x-pack/legacy/plugins/siem/server/lib/uncommon_processes/types.ts b/x-pack/plugins/siem/server/lib/uncommon_processes/types.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/uncommon_processes/types.ts rename to x-pack/plugins/siem/server/lib/uncommon_processes/types.ts diff --git a/x-pack/plugins/siem/server/plugin.ts b/x-pack/plugins/siem/server/plugin.ts index ccc6aef1452b2..b9ec1c2e92438 100644 --- a/x-pack/plugins/siem/server/plugin.ts +++ b/x-pack/plugins/siem/server/plugin.ts @@ -5,33 +5,203 @@ */ import { Observable } from 'rxjs'; +import { first } from 'rxjs/operators'; +import { i18n } from '@kbn/i18n'; -import { CoreSetup, PluginInitializerContext, Logger } from '../../../../src/core/server'; +import { + CoreSetup, + CoreStart, + PluginInitializerContext, + Logger, +} from '../../../../src/core/server'; +import { + PluginStartContract as AlertingStart, + PluginSetupContract as AlertingSetup, +} from '../../alerting/server'; +import { SecurityPluginSetup as SecuritySetup } from '../../security/server'; +import { PluginSetupContract as FeaturesSetup } from '../../features/server'; +import { MlPluginSetup as MlSetup } from '../../ml/server'; +import { EncryptedSavedObjectsPluginSetup as EncryptedSavedObjectsSetup } from '../../encrypted_saved_objects/server'; +import { SpacesPluginSetup as SpacesSetup } from '../../spaces/server'; +import { PluginStartContract as ActionsStart } from '../../actions/server'; +import { LicensingPluginSetup } from '../../licensing/server'; +import { initServer } from './init_server'; +import { compose } from './lib/compose/kibana'; +import { initRoutes } from './routes'; +import { isAlertExecutor } from './lib/detection_engine/signals/types'; +import { signalRulesAlertType } from './lib/detection_engine/signals/signal_rule_alert_type'; +import { rulesNotificationAlertType } from './lib/detection_engine/notifications/rules_notification_alert_type'; +import { isNotificationAlertExecutor } from './lib/detection_engine/notifications/types'; +import { hasListsFeature, listsEnvFeatureFlagName } from './lib/detection_engine/feature_flags'; +import { + noteSavedObjectType, + pinnedEventSavedObjectType, + timelineSavedObjectType, + ruleStatusSavedObjectType, + ruleActionsSavedObjectType, +} from './saved_objects'; +import { SiemClientFactory } from './client'; import { createConfig$, ConfigType } from './config'; +export { CoreSetup, CoreStart }; + +export interface SetupPlugins { + alerting: AlertingSetup; + encryptedSavedObjects?: EncryptedSavedObjectsSetup; + features: FeaturesSetup; + licensing: LicensingPluginSetup; + security?: SecuritySetup; + spaces?: SpacesSetup; + ml?: MlSetup; +} + +export interface StartPlugins { + actions: ActionsStart; + alerting: AlertingStart; +} + export class Plugin { readonly name = 'siem'; private readonly logger: Logger; - // @ts-ignore-next-line TODO(rylnd): use it or lose it private readonly config$: Observable; + private context: PluginInitializerContext; + private siemClientFactory: SiemClientFactory; constructor(context: PluginInitializerContext) { - const { logger } = context; - this.logger = logger.get(); - this.logger.debug('plugin initialized'); - + this.context = context; + this.logger = context.logger.get('plugins', this.name); this.config$ = createConfig$(context); + this.siemClientFactory = new SiemClientFactory(); + + this.logger.debug('plugin initialized'); } - public setup(core: CoreSetup, plugins: {}) { + public async setup(core: CoreSetup, plugins: SetupPlugins) { this.logger.debug('plugin setup'); - } - public start() { - this.logger.debug('plugin started'); - } + if (hasListsFeature()) { + // TODO: Remove this once we have the lists feature supported + this.logger.error( + `You have activated the lists feature flag which is NOT currently supported for SIEM! You should turn this feature flag off immediately by un-setting the environment variable: ${listsEnvFeatureFlagName} and restarting Kibana` + ); + } + + const router = core.http.createRouter(); + core.http.registerRouteHandlerContext(this.name, (context, request, response) => ({ + getSiemClient: () => this.siemClientFactory.create(request), + })); + + const config = await this.config$.pipe(first()).toPromise(); + + this.siemClientFactory.setup({ + getSpaceId: plugins.spaces?.spacesService?.getSpaceId, + config, + }); + + initRoutes( + router, + config, + plugins.encryptedSavedObjects?.usingEphemeralEncryptionKey ?? false, + plugins.security + ); - public stop() { - this.logger.debug('plugin stopped'); + plugins.features.registerFeature({ + id: this.name, + name: i18n.translate('xpack.siem.featureRegistry.linkSiemTitle', { + defaultMessage: 'SIEM', + }), + order: 1100, + icon: 'securityAnalyticsApp', + navLinkId: 'siem', + app: ['siem', 'kibana'], + catalogue: ['siem'], + privileges: { + all: { + app: ['siem', 'kibana'], + catalogue: ['siem'], + api: ['siem', 'actions-read', 'actions-all', 'alerting-read', 'alerting-all'], + savedObject: { + all: [ + 'alert', + 'action', + 'action_task_params', + noteSavedObjectType, + pinnedEventSavedObjectType, + timelineSavedObjectType, + ruleStatusSavedObjectType, + ruleActionsSavedObjectType, + 'cases', + 'cases-comments', + 'cases-configure', + 'cases-user-actions', + ], + read: ['config'], + }, + ui: [ + 'show', + 'crud', + 'alerting:show', + 'actions:show', + 'alerting:save', + 'actions:save', + 'alerting:delete', + 'actions:delete', + ], + }, + read: { + app: ['siem', 'kibana'], + catalogue: ['siem'], + api: ['siem', 'actions-read', 'actions-all', 'alerting-read', 'alerting-all'], + savedObject: { + all: ['alert', 'action', 'action_task_params'], + read: [ + 'config', + noteSavedObjectType, + pinnedEventSavedObjectType, + timelineSavedObjectType, + ruleStatusSavedObjectType, + ruleActionsSavedObjectType, + 'cases', + 'cases-comments', + 'cases-configure', + 'cases-user-actions', + ], + }, + ui: [ + 'show', + 'alerting:show', + 'actions:show', + 'alerting:save', + 'actions:save', + 'alerting:delete', + 'actions:delete', + ], + }, + }, + }); + + if (plugins.alerting != null) { + const signalRuleType = signalRulesAlertType({ + logger: this.logger, + version: this.context.env.packageInfo.version, + ml: plugins.ml, + }); + const ruleNotificationType = rulesNotificationAlertType({ + logger: this.logger, + }); + + if (isAlertExecutor(signalRuleType)) { + plugins.alerting.registerType(signalRuleType); + } + + if (isNotificationAlertExecutor(ruleNotificationType)) { + plugins.alerting.registerType(ruleNotificationType); + } + } + + const libs = compose(core, plugins, this.context.env.mode.prod); + initServer(libs); } + + public start(core: CoreStart, plugins: StartPlugins) {} } diff --git a/x-pack/legacy/plugins/siem/server/routes/index.ts b/x-pack/plugins/siem/server/routes/index.ts similarity index 96% rename from x-pack/legacy/plugins/siem/server/routes/index.ts rename to x-pack/plugins/siem/server/routes/index.ts index 8c9f92890c26a..64b232a2686b8 100644 --- a/x-pack/legacy/plugins/siem/server/routes/index.ts +++ b/x-pack/plugins/siem/server/routes/index.ts @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IRouter } from '../../../../../../src/core/server'; -import { LegacyServices } from '../types'; +import { IRouter } from '../../../../../src/core/server'; import { createRulesRoute } from '../lib/detection_engine/routes/rules/create_rules_route'; import { createIndexRoute } from '../lib/detection_engine/routes/index/create_index_route'; @@ -32,10 +31,11 @@ import { getPrepackagedRulesStatusRoute } from '../lib/detection_engine/routes/r import { importTimelinesRoute } from '../lib/timeline/routes/import_timelines_route'; import { exportTimelinesRoute } from '../lib/timeline/routes/export_timelines_route'; import { SetupPlugins } from '../plugin'; +import { ConfigType } from '..'; export const initRoutes = ( router: IRouter, - config: LegacyServices['config'], + config: ConfigType, usingEphemeralEncryptionKey: boolean, security: SetupPlugins['security'] ) => { diff --git a/x-pack/legacy/plugins/siem/server/saved_objects.ts b/x-pack/plugins/siem/server/saved_objects.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/saved_objects.ts rename to x-pack/plugins/siem/server/saved_objects.ts diff --git a/x-pack/legacy/plugins/siem/server/types.ts b/x-pack/plugins/siem/server/types.ts similarity index 82% rename from x-pack/legacy/plugins/siem/server/types.ts rename to x-pack/plugins/siem/server/types.ts index a52322f5f830c..3a5c6cf94c652 100644 --- a/x-pack/legacy/plugins/siem/server/types.ts +++ b/x-pack/plugins/siem/server/types.ts @@ -4,13 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Legacy } from 'kibana'; import { SiemClient } from './client'; -export interface LegacyServices { - config: Legacy.Server['config']; -} - export { SiemClient }; export interface SiemRequestContext { diff --git a/x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/auditbeat.ts b/x-pack/plugins/siem/server/utils/beat_schema/8.0.0/auditbeat.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/auditbeat.ts rename to x-pack/plugins/siem/server/utils/beat_schema/8.0.0/auditbeat.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/ecs.ts b/x-pack/plugins/siem/server/utils/beat_schema/8.0.0/ecs.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/ecs.ts rename to x-pack/plugins/siem/server/utils/beat_schema/8.0.0/ecs.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/filebeat.ts b/x-pack/plugins/siem/server/utils/beat_schema/8.0.0/filebeat.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/filebeat.ts rename to x-pack/plugins/siem/server/utils/beat_schema/8.0.0/filebeat.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/index.ts b/x-pack/plugins/siem/server/utils/beat_schema/8.0.0/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/index.ts rename to x-pack/plugins/siem/server/utils/beat_schema/8.0.0/index.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/packetbeat.ts b/x-pack/plugins/siem/server/utils/beat_schema/8.0.0/packetbeat.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/packetbeat.ts rename to x-pack/plugins/siem/server/utils/beat_schema/8.0.0/packetbeat.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/winlogbeat.ts b/x-pack/plugins/siem/server/utils/beat_schema/8.0.0/winlogbeat.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/beat_schema/8.0.0/winlogbeat.ts rename to x-pack/plugins/siem/server/utils/beat_schema/8.0.0/winlogbeat.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/beat_schema/index.test.ts b/x-pack/plugins/siem/server/utils/beat_schema/index.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/beat_schema/index.test.ts rename to x-pack/plugins/siem/server/utils/beat_schema/index.test.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/beat_schema/index.ts b/x-pack/plugins/siem/server/utils/beat_schema/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/beat_schema/index.ts rename to x-pack/plugins/siem/server/utils/beat_schema/index.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/beat_schema/type.ts b/x-pack/plugins/siem/server/utils/beat_schema/type.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/beat_schema/type.ts rename to x-pack/plugins/siem/server/utils/beat_schema/type.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/calculate_timeseries_interval.ts b/x-pack/plugins/siem/server/utils/build_query/calculate_timeseries_interval.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/calculate_timeseries_interval.ts rename to x-pack/plugins/siem/server/utils/build_query/calculate_timeseries_interval.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/create_options.test.ts b/x-pack/plugins/siem/server/utils/build_query/create_options.test.ts similarity index 93% rename from x-pack/legacy/plugins/siem/server/utils/build_query/create_options.test.ts rename to x-pack/plugins/siem/server/utils/build_query/create_options.test.ts index 8262b5b670d30..5ca67ad6ae51f 100644 --- a/x-pack/legacy/plugins/siem/server/utils/build_query/create_options.test.ts +++ b/x-pack/plugins/siem/server/utils/build_query/create_options.test.ts @@ -6,7 +6,7 @@ import { omit } from 'lodash/fp'; -import { defaultIndexPattern } from '../../../default_index_pattern'; +import { DEFAULT_INDEX_PATTERN } from '../../../common/constants'; import { Direction } from '../../graphql/types'; import { RequestOptions } from '../../lib/framework'; @@ -30,7 +30,7 @@ describe('createOptions', () => { }, }; args = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, pagination: { limit: 5, }, @@ -57,7 +57,7 @@ describe('createOptions', () => { test('should create options given all input including sort field', () => { const options = createOptions(source, args, info); const expected: RequestOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { host: 'host-1', @@ -87,7 +87,7 @@ describe('createOptions', () => { const argsWithoutSort: Args = omit('sortField', args); const options = createOptions(source, argsWithoutSort, info); const expected: RequestOptions = { - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, sourceConfiguration: { fields: { host: 'host-1', diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/create_options.ts b/x-pack/plugins/siem/server/utils/build_query/create_options.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/create_options.ts rename to x-pack/plugins/siem/server/utils/build_query/create_options.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/field.mock.ts b/x-pack/plugins/siem/server/utils/build_query/field.mock.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/field.mock.ts rename to x-pack/plugins/siem/server/utils/build_query/field.mock.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/fields.test.ts b/x-pack/plugins/siem/server/utils/build_query/fields.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/fields.test.ts rename to x-pack/plugins/siem/server/utils/build_query/fields.test.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/fields.ts b/x-pack/plugins/siem/server/utils/build_query/fields.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/fields.ts rename to x-pack/plugins/siem/server/utils/build_query/fields.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/filters.ts b/x-pack/plugins/siem/server/utils/build_query/filters.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/filters.ts rename to x-pack/plugins/siem/server/utils/build_query/filters.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/index.ts b/x-pack/plugins/siem/server/utils/build_query/index.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/index.ts rename to x-pack/plugins/siem/server/utils/build_query/index.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/merge_fields_with_hits.test.ts b/x-pack/plugins/siem/server/utils/build_query/merge_fields_with_hits.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/merge_fields_with_hits.test.ts rename to x-pack/plugins/siem/server/utils/build_query/merge_fields_with_hits.test.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/merge_fields_with_hits.ts b/x-pack/plugins/siem/server/utils/build_query/merge_fields_with_hits.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/merge_fields_with_hits.ts rename to x-pack/plugins/siem/server/utils/build_query/merge_fields_with_hits.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/reduce_fields.test.ts b/x-pack/plugins/siem/server/utils/build_query/reduce_fields.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/reduce_fields.test.ts rename to x-pack/plugins/siem/server/utils/build_query/reduce_fields.test.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/build_query/reduce_fields.ts b/x-pack/plugins/siem/server/utils/build_query/reduce_fields.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/build_query/reduce_fields.ts rename to x-pack/plugins/siem/server/utils/build_query/reduce_fields.ts diff --git a/x-pack/plugins/siem/server/utils/build_validation/__mocks__/utils.ts b/x-pack/plugins/siem/server/utils/build_validation/__mocks__/utils.ts new file mode 100644 index 0000000000000..578972dda5aef --- /dev/null +++ b/x-pack/plugins/siem/server/utils/build_validation/__mocks__/utils.ts @@ -0,0 +1,43 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import * as t from 'io-ts'; +import { fold } from 'fp-ts/lib/Either'; +import { pipe } from 'fp-ts/lib/pipeable'; +import { formatErrors } from '../format_errors'; + +interface Message { + errors: t.Errors; + schema: T | {}; +} + +const onLeft = (errors: t.Errors): Message => { + return { schema: {}, errors }; +}; + +const onRight = (schema: T): Message => { + return { + schema, + errors: [], + }; +}; + +export const foldLeftRight = fold(onLeft, onRight); + +/** + * Convenience utility to keep the error message handling within tests to be + * very concise. + * @param validation The validation to get the errors from + */ +export const getPaths = (validation: t.Validation): string[] => { + return pipe( + validation, + fold( + errors => formatErrors(errors), + () => ['no errors'] + ) + ); +}; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/exact_check.test.ts b/x-pack/plugins/siem/server/utils/build_validation/exact_check.test.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/exact_check.test.ts rename to x-pack/plugins/siem/server/utils/build_validation/exact_check.test.ts index cae4365d06856..1e70deaeed438 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/exact_check.test.ts +++ b/x-pack/plugins/siem/server/utils/build_validation/exact_check.test.ts @@ -5,22 +5,13 @@ */ import * as t from 'io-ts'; -import { left, right } from 'fp-ts/lib/Either'; +import { left, right, Either } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import { foldLeftRight, getPaths } from './__mocks__/utils'; import { exactCheck, findDifferencesRecursive } from './exact_check'; -import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; describe('exact_check', () => { - beforeAll(() => { - setFeatureFlagsForTestsOnly(); - }); - - afterAll(() => { - unSetFeatureFlagsForTestsOnly(); - }); - test('it returns an error if given extra object properties', () => { const someType = t.exact( t.type({ @@ -36,14 +27,22 @@ describe('exact_check', () => { }); test('it returns an error if the data type is not as expected', () => { + type UnsafeCastForTest = Either< + t.Errors, + { + a: number; + } + >; + const someType = t.exact( t.type({ a: t.string, }) ); + const payload = { a: 1 }; const decoded = someType.decode(payload); - const checked = exactCheck(payload, decoded); + const checked = exactCheck(payload, decoded as UnsafeCastForTest); const message = pipe(checked, foldLeftRight); expect(getPaths(left(message.errors))).toEqual(['Invalid value "1" supplied to "a"']); expect(message.schema).toEqual({}); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/exact_check.ts b/x-pack/plugins/siem/server/utils/build_validation/exact_check.ts similarity index 59% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/exact_check.ts rename to x-pack/plugins/siem/server/utils/build_validation/exact_check.ts index 6fa0472950189..9484765f9973d 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/exact_check.ts +++ b/x-pack/plugins/siem/server/utils/build_validation/exact_check.ts @@ -25,10 +25,7 @@ import { isObject, get } from 'lodash/fp'; * @param decoded The decoded either which has either an existing error or the * decoded object which could have additional keys stripped from it. */ -export const exactCheck = ( - original: object, - decoded: Either -): Either => { +export const exactCheck = (original: T, decoded: Either): Either => { const onLeft = (errors: t.Errors): Either => left(errors); const onRight = (decodedValue: T): Either => { const differences = findDifferencesRecursive(original, decodedValue); @@ -47,7 +44,7 @@ export const exactCheck = ( return pipe(decoded, fold(onLeft, onRight)); }; -export const findDifferencesRecursive = (original: object, decodedValue: T): string[] => { +export const findDifferencesRecursive = (original: T, decodedValue: T): string[] => { if (decodedValue == null) { try { // It is null and painful when the original contains an object or an array @@ -56,29 +53,33 @@ export const findDifferencesRecursive = (original: object, decodedValue: T): } catch (err) { return ['circular reference']; } + } else if (typeof original !== 'object' || original == null) { + // We are not an object or null so do not report differences + return []; + } else { + const decodedKeys = Object.keys(decodedValue); + const differences = Object.keys(original).flatMap(originalKey => { + const foundKey = decodedKeys.some(key => key === originalKey); + const topLevelKey = foundKey ? [] : [originalKey]; + // I use lodash to cheat and get an any (not going to lie ;-)) + const valueObjectOrArrayOriginal = get(originalKey, original); + const valueObjectOrArrayDecoded = get(originalKey, decodedValue); + if (isObject(valueObjectOrArrayOriginal)) { + return [ + ...topLevelKey, + ...findDifferencesRecursive(valueObjectOrArrayOriginal, valueObjectOrArrayDecoded), + ]; + } else if (Array.isArray(valueObjectOrArrayOriginal)) { + return [ + ...topLevelKey, + ...valueObjectOrArrayOriginal.flatMap((arrayElement, index) => + findDifferencesRecursive(arrayElement, get(index, valueObjectOrArrayDecoded)) + ), + ]; + } else { + return topLevelKey; + } + }); + return differences; } - const decodedKeys = Object.keys(decodedValue); - const differences = Object.keys(original).flatMap(originalKey => { - const foundKey = decodedKeys.some(key => key === originalKey); - const topLevelKey = foundKey ? [] : [originalKey]; - // I use lodash to cheat and get an any (not going to lie ;-)) - const valueObjectOrArrayOriginal = get(originalKey, original); - const valueObjectOrArrayDecoded = get(originalKey, decodedValue); - if (isObject(valueObjectOrArrayOriginal)) { - return [ - ...topLevelKey, - ...findDifferencesRecursive(valueObjectOrArrayOriginal, valueObjectOrArrayDecoded), - ]; - } else if (Array.isArray(valueObjectOrArrayOriginal)) { - return [ - ...topLevelKey, - ...valueObjectOrArrayOriginal.flatMap((arrayElement, index) => - findDifferencesRecursive(arrayElement, get(index, valueObjectOrArrayDecoded)) - ), - ]; - } else { - return topLevelKey; - } - }); - return differences; }; diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/utils.test.ts b/x-pack/plugins/siem/server/utils/build_validation/format_errors.test.ts similarity index 94% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/utils.test.ts rename to x-pack/plugins/siem/server/utils/build_validation/format_errors.test.ts index c1eb32be4895c..f9dd9e76a1d9c 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/utils.test.ts +++ b/x-pack/plugins/siem/server/utils/build_validation/format_errors.test.ts @@ -5,18 +5,9 @@ */ import * as t from 'io-ts'; -import { formatErrors } from './utils'; -import { setFeatureFlagsForTestsOnly, unSetFeatureFlagsForTestsOnly } from '../../../feature_flags'; +import { formatErrors } from './format_errors'; describe('utils', () => { - beforeAll(() => { - setFeatureFlagsForTestsOnly(); - }); - - afterAll(() => { - unSetFeatureFlagsForTestsOnly(); - }); - test('returns an empty error message string if there are no errors', () => { const errors: t.Errors = []; const output = formatErrors(errors); diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/utils.ts b/x-pack/plugins/siem/server/utils/build_validation/format_errors.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/lib/detection_engine/routes/schemas/response/utils.ts rename to x-pack/plugins/siem/server/utils/build_validation/format_errors.ts diff --git a/x-pack/plugins/siem/server/utils/build_validation/route_validation.test.ts b/x-pack/plugins/siem/server/utils/build_validation/route_validation.test.ts new file mode 100644 index 0000000000000..866dbe9480ca5 --- /dev/null +++ b/x-pack/plugins/siem/server/utils/build_validation/route_validation.test.ts @@ -0,0 +1,86 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { buildRouteValidation } from './route_validation'; +import * as rt from 'io-ts'; +import { RouteValidationResultFactory } from '../../../../../../src/core/server/http'; + +describe('buildRouteValidation', () => { + const schema = rt.exact( + rt.type({ + ids: rt.array(rt.string), + }) + ); + type Schema = rt.TypeOf; + + /** + * If your schema is using exact all the way down then the validation will + * catch any additional keys that should not be present within the validation + * when the route_validation uses the exact check. + */ + const deepSchema = rt.exact( + rt.type({ + topLevel: rt.exact( + rt.type({ + secondLevel: rt.exact( + rt.type({ + thirdLevel: rt.string, + }) + ), + }) + ), + }) + ); + type DeepSchema = rt.TypeOf; + + const validationResult: RouteValidationResultFactory = { + ok: jest.fn().mockImplementation(validatedInput => validatedInput), + badRequest: jest.fn().mockImplementation(e => e), + }; + + beforeEach(() => { + jest.clearAllMocks(); + }); + + test('return validation error', () => { + const input: Omit & { id: string } = { id: 'someId' }; + const result = buildRouteValidation(schema)(input, validationResult); + + expect(result).toEqual('Invalid value "undefined" supplied to "ids"'); + }); + + test('return validated input', () => { + const input: Schema = { ids: ['someId'] }; + const result = buildRouteValidation(schema)(input, validationResult); + + expect(result).toEqual(input); + }); + + test('returns validation error if given extra keys on input for an array', () => { + const input: Schema & { somethingExtra: string } = { + ids: ['someId'], + somethingExtra: 'hello', + }; + const result = buildRouteValidation(schema)(input, validationResult); + expect(result).toEqual('invalid keys "somethingExtra"'); + }); + + test('return validation input for a deep 3rd level object', () => { + const input: DeepSchema = { topLevel: { secondLevel: { thirdLevel: 'hello' } } }; + const result = buildRouteValidation(deepSchema)(input, validationResult); + expect(result).toEqual(input); + }); + + test('return validation error for a deep 3rd level object that has an extra key value of "somethingElse"', () => { + const input: DeepSchema & { + topLevel: { secondLevel: { thirdLevel: string; somethingElse: string } }; + } = { + topLevel: { secondLevel: { thirdLevel: 'hello', somethingElse: 'extraKey' } }, + }; + const result = buildRouteValidation(deepSchema)(input, validationResult); + expect(result).toEqual('invalid keys "somethingElse"'); + }); +}); diff --git a/x-pack/legacy/plugins/siem/server/utils/build_validation/route_validation.ts b/x-pack/plugins/siem/server/utils/build_validation/route_validation.ts similarity index 78% rename from x-pack/legacy/plugins/siem/server/utils/build_validation/route_validation.ts rename to x-pack/plugins/siem/server/utils/build_validation/route_validation.ts index 1281c23cbc89a..30b95dcfa94ee 100644 --- a/x-pack/legacy/plugins/siem/server/utils/build_validation/route_validation.ts +++ b/x-pack/plugins/siem/server/utils/build_validation/route_validation.ts @@ -7,12 +7,13 @@ import { fold } from 'fp-ts/lib/Either'; import { pipe } from 'fp-ts/lib/pipeable'; import * as rt from 'io-ts'; -import { failure } from 'io-ts/lib/PathReporter'; import { RouteValidationFunction, RouteValidationResultFactory, RouteValidationError, -} from '../../../../../../../src/core/server'; +} from '../../../../../../src/core/server'; +import { exactCheck } from './exact_check'; +import { formatErrors } from './format_errors'; type RequestValidationResult = | { @@ -32,8 +33,9 @@ export const buildRouteValidation = >( ) => pipe( schema.decode(inputValue), + decoded => exactCheck(inputValue, decoded), fold>( - (errors: rt.Errors) => validationResult.badRequest(failure(errors).join('\n')), + (errors: rt.Errors) => validationResult.badRequest(formatErrors(errors).join()), (validatedInput: A) => validationResult.ok(validatedInput) ) ); diff --git a/x-pack/legacy/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.test.ts b/x-pack/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.test.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.test.ts rename to x-pack/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.test.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.ts b/x-pack/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.ts similarity index 98% rename from x-pack/legacy/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.ts rename to x-pack/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.ts index 0b7966926b5dd..2d630d0b92c68 100644 --- a/x-pack/legacy/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.ts +++ b/x-pack/plugins/siem/server/utils/read_stream/create_stream_from_ndjson.ts @@ -6,7 +6,7 @@ import { Transform } from 'stream'; import { has, isString } from 'lodash/fp'; import { ImportRuleAlertRest } from '../../lib/detection_engine/types'; -import { createMapStream, createFilterStream } from '../../../../../../../src/legacy/utils/streams'; +import { createMapStream, createFilterStream } from '../../../../../../src/legacy/utils/streams'; import { importRulesSchema } from '../../lib/detection_engine/routes/schemas/import_rules_schema'; import { BadRequestError } from '../../lib/detection_engine/errors/bad_request_error'; diff --git a/x-pack/legacy/plugins/siem/server/utils/serialized_query.ts b/x-pack/plugins/siem/server/utils/serialized_query.ts similarity index 92% rename from x-pack/legacy/plugins/siem/server/utils/serialized_query.ts rename to x-pack/plugins/siem/server/utils/serialized_query.ts index 1ba6eb8b9f9a6..09b227d8c5a32 100644 --- a/x-pack/legacy/plugins/siem/server/utils/serialized_query.ts +++ b/x-pack/plugins/siem/server/utils/serialized_query.ts @@ -7,7 +7,7 @@ import { UserInputError } from 'apollo-server-errors'; import { isEmpty, isPlainObject, isString } from 'lodash/fp'; -import { JsonObject } from '../../../../../../src/plugins/kibana_utils/public'; +import { JsonObject } from '../../../../../src/plugins/kibana_utils/public'; export const parseFilterQuery = (filterQuery: string): JsonObject => { try { diff --git a/x-pack/legacy/plugins/siem/server/utils/typed_elasticsearch_mappings.ts b/x-pack/plugins/siem/server/utils/typed_elasticsearch_mappings.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/typed_elasticsearch_mappings.ts rename to x-pack/plugins/siem/server/utils/typed_elasticsearch_mappings.ts diff --git a/x-pack/legacy/plugins/siem/server/utils/typed_resolvers.ts b/x-pack/plugins/siem/server/utils/typed_resolvers.ts similarity index 100% rename from x-pack/legacy/plugins/siem/server/utils/typed_resolvers.ts rename to x-pack/plugins/siem/server/utils/typed_resolvers.ts diff --git a/x-pack/plugins/siem/yarn.lock b/x-pack/plugins/siem/yarn.lock new file mode 120000 index 0000000000000..6e09764ec763b --- /dev/null +++ b/x-pack/plugins/siem/yarn.lock @@ -0,0 +1 @@ +../../../yarn.lock \ No newline at end of file diff --git a/x-pack/plugins/snapshot_restore/common/types/index.ts b/x-pack/plugins/snapshot_restore/common/types/index.ts index 5cb3839fa9e01..d52584ca737a2 100644 --- a/x-pack/plugins/snapshot_restore/common/types/index.ts +++ b/x-pack/plugins/snapshot_restore/common/types/index.ts @@ -8,4 +8,3 @@ export * from './repository'; export * from './snapshot'; export * from './restore'; export * from './policy'; -export * from './privileges'; diff --git a/x-pack/plugins/snapshot_restore/common/types/privileges.ts b/x-pack/plugins/snapshot_restore/common/types/privileges.ts deleted file mode 100644 index bf710b8225599..0000000000000 --- a/x-pack/plugins/snapshot_restore/common/types/privileges.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export interface MissingPrivileges { - [key: string]: string[] | undefined; -} - -export interface Privileges { - hasAllPrivileges: boolean; - missingPrivileges: MissingPrivileges; -} diff --git a/x-pack/plugins/snapshot_restore/public/application/app.tsx b/x-pack/plugins/snapshot_restore/public/application/app.tsx index 77ef697814b2c..350d8aec711ed 100644 --- a/x-pack/plugins/snapshot_restore/public/application/app.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/app.tsx @@ -4,13 +4,19 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useContext } from 'react'; +import React from 'react'; import { Redirect, Route, Switch } from 'react-router-dom'; import { EuiPageContent } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -import { APP_REQUIRED_CLUSTER_PRIVILEGES } from '../../common/constants'; -import { SectionLoading, SectionError } from './components'; +import { APP_REQUIRED_CLUSTER_PRIVILEGES } from '../../common'; +import { + useAuthorizationContext, + SectionError, + WithPrivileges, + NotAuthorizedSection, +} from '../shared_imports'; +import { SectionLoading } from './components'; import { BASE_PATH, DEFAULT_SECTION, Section } from './constants'; import { RepositoryAdd, @@ -21,11 +27,10 @@ import { PolicyEdit, } from './sections'; import { useConfig } from './app_context'; -import { AuthorizationContext, WithPrivileges, NotAuthorizedSection } from './lib/authorization'; export const App: React.FunctionComponent = () => { const { slm_ui: slmUi } = useConfig(); - const { apiError } = useContext(AuthorizationContext); + const { apiError } = useAuthorizationContext(); const sections: Section[] = ['repositories', 'snapshots', 'restore_status']; diff --git a/x-pack/plugins/snapshot_restore/public/application/app_providers.tsx b/x-pack/plugins/snapshot_restore/public/application/app_providers.tsx index e2732c0051337..3ca25b7d32dba 100644 --- a/x-pack/plugins/snapshot_restore/public/application/app_providers.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/app_providers.tsx @@ -5,8 +5,8 @@ */ import React from 'react'; -import { API_BASE_PATH } from '../../common/constants'; -import { AuthorizationProvider } from './lib/authorization'; +import { API_BASE_PATH } from '../../common'; +import { AuthorizationProvider } from '../shared_imports'; import { AppContextProvider, AppDependencies } from './app_context'; interface Props { @@ -18,10 +18,11 @@ export const AppProviders = ({ appDependencies, children }: Props) => { const { core } = appDependencies; const { i18n: { Context: I18nContext }, + http, } = core; return ( - + {children} diff --git a/x-pack/plugins/snapshot_restore/public/application/components/index.ts b/x-pack/plugins/snapshot_restore/public/application/components/index.ts index a7038ebd71578..f5bb892389870 100644 --- a/x-pack/plugins/snapshot_restore/public/application/components/index.ts +++ b/x-pack/plugins/snapshot_restore/public/application/components/index.ts @@ -10,7 +10,6 @@ export { RepositoryDeleteProvider } from './repository_delete_provider'; export { RepositoryForm } from './repository_form'; export { RepositoryVerificationBadge } from './repository_verification_badge'; export { RepositoryTypeLogo } from './repository_type_logo'; -export { SectionError, Error } from './section_error'; export { SectionLoading } from './section_loading'; export { SnapshotDeleteProvider } from './snapshot_delete_provider'; export { RestoreSnapshotForm } from './restore_snapshot_form'; diff --git a/x-pack/plugins/snapshot_restore/public/application/components/policy_form/steps/step_logistics.tsx b/x-pack/plugins/snapshot_restore/public/application/components/policy_form/steps/step_logistics.tsx index f2d4e2bd74598..105f0601e3dfb 100644 --- a/x-pack/plugins/snapshot_restore/public/application/components/policy_form/steps/step_logistics.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/components/policy_form/steps/step_logistics.tsx @@ -21,13 +21,13 @@ import { } from '@elastic/eui'; import { Repository } from '../../../../../common/types'; -import { CronEditor } from '../../../../shared_imports'; +import { CronEditor, SectionError } from '../../../../shared_imports'; import { useServices } from '../../../app_context'; import { DEFAULT_POLICY_SCHEDULE, DEFAULT_POLICY_FREQUENCY } from '../../../constants'; import { useLoadRepositories } from '../../../services/http'; import { linkToAddRepository } from '../../../services/navigation'; import { documentationLinksService } from '../../../services/documentation'; -import { SectionLoading, SectionError } from '../../'; +import { SectionLoading } from '../../'; import { StepProps } from './'; export const PolicyStepLogistics: React.FunctionComponent = ({ diff --git a/x-pack/plugins/snapshot_restore/public/application/components/repository_form/step_one.tsx b/x-pack/plugins/snapshot_restore/public/application/components/repository_form/step_one.tsx index 3b4c9d595b9f2..34bc06343a780 100644 --- a/x-pack/plugins/snapshot_restore/public/application/components/repository_form/step_one.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/components/repository_form/step_one.tsx @@ -23,13 +23,14 @@ import { } from '@elastic/eui'; import { Repository, RepositoryType, EmptyRepository } from '../../../../common/types'; -import { REPOSITORY_TYPES } from '../../../../common/constants'; +import { REPOSITORY_TYPES } from '../../../../common'; +import { SectionError, Error } from '../../../shared_imports'; import { documentationLinksService } from '../../services/documentation'; import { useLoadRepositoryTypes } from '../../services/http'; import { textService } from '../../services/text'; import { RepositoryValidation } from '../../services/validation'; -import { SectionError, SectionLoading, RepositoryTypeLogo, Error } from '../'; +import { SectionLoading, RepositoryTypeLogo } from '../'; interface Props { repository: Repository | EmptyRepository; diff --git a/x-pack/plugins/snapshot_restore/public/application/components/repository_form/type_settings/index.tsx b/x-pack/plugins/snapshot_restore/public/application/components/repository_form/type_settings/index.tsx index 75295a1205cef..1e54868397a6d 100644 --- a/x-pack/plugins/snapshot_restore/public/application/components/repository_form/type_settings/index.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/components/repository_form/type_settings/index.tsx @@ -6,11 +6,11 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { REPOSITORY_TYPES } from '../../../../../common/constants'; +import { REPOSITORY_TYPES } from '../../../../../common'; import { Repository, RepositoryType, EmptyRepository } from '../../../../../common/types'; +import { SectionError } from '../../../../shared_imports'; import { useServices } from '../../../app_context'; import { RepositorySettingsValidation } from '../../../services/validation'; -import { SectionError } from '../../index'; import { AzureSettings } from './azure_settings'; import { FSSettings } from './fs_settings'; diff --git a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/authorization_provider.tsx b/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/authorization_provider.tsx deleted file mode 100644 index d32fe29cc1dfa..0000000000000 --- a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/authorization_provider.tsx +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React, { createContext } from 'react'; -import { useRequest } from '../../../services/http/use_request'; -import { Privileges } from '../../../../../common/types'; -import { Error } from '../../../components/section_error'; - -interface Authorization { - isLoading: boolean; - apiError: Error | null; - privileges: Privileges; -} - -const initialValue: Authorization = { - isLoading: true, - apiError: null, - privileges: { - hasAllPrivileges: true, - missingPrivileges: {}, - }, -}; - -export const AuthorizationContext = createContext(initialValue); - -interface Props { - privilegesEndpoint: string; - children: React.ReactNode; -} - -export const AuthorizationProvider = ({ privilegesEndpoint, children }: Props) => { - const { isLoading, error, data: privilegesData } = useRequest({ - path: privilegesEndpoint, - method: 'get', - }); - - const value = { - isLoading, - privileges: isLoading ? { hasAllPrivileges: true, missingPrivileges: {} } : privilegesData, - apiError: error ? error : null, - } as Authorization; - - return {children}; -}; diff --git a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/not_authorized_section.tsx b/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/not_authorized_section.tsx deleted file mode 100644 index 3fc13245708e8..0000000000000 --- a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/not_authorized_section.tsx +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import React from 'react'; -import { EuiEmptyPrompt } from '@elastic/eui'; - -interface Props { - title: React.ReactNode; - message: React.ReactNode | string; -} - -export const NotAuthorizedSection = ({ title, message }: Props) => ( - {title}} body={

{message}

} /> -); diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_details/policy_details.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_details/policy_details.tsx index f3110199ee17c..03d381c9f3aa3 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_details/policy_details.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_details/policy_details.tsx @@ -26,6 +26,7 @@ import { import { SlmPolicy } from '../../../../../../common/types'; import { useServices } from '../../../../app_context'; +import { SectionError, Error } from '../../../../../shared_imports'; import { UIM_POLICY_DETAIL_PANEL_SUMMARY_TAB, UIM_POLICY_DETAIL_PANEL_HISTORY_TAB, @@ -34,11 +35,9 @@ import { useLoadPolicy } from '../../../../services/http'; import { linkToEditPolicy, linkToSnapshot } from '../../../../services/navigation'; import { - SectionError, SectionLoading, PolicyExecuteProvider, PolicyDeleteProvider, - Error, } from '../../../../components'; import { TabSummary, TabHistory } from './tabs'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx index 0122e25e5e165..51297038b0f3f 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_list.tsx @@ -9,13 +9,19 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { RouteComponentProps } from 'react-router-dom'; import { EuiEmptyPrompt, EuiButton, EuiCallOut, EuiSpacer } from '@elastic/eui'; +import { + SectionError, + Error, + WithPrivileges, + NotAuthorizedSection, +} from '../../../../shared_imports'; + import { SlmPolicy } from '../../../../../common/types'; -import { APP_SLM_CLUSTER_PRIVILEGES } from '../../../../../common/constants'; -import { SectionError, SectionLoading, Error } from '../../../components'; +import { APP_SLM_CLUSTER_PRIVILEGES } from '../../../../../common'; +import { SectionLoading } from '../../../components'; import { BASE_PATH, UIM_POLICY_LIST_LOAD } from '../../../constants'; import { useLoadPolicies, useLoadRetentionSettings } from '../../../services/http'; import { linkToAddPolicy, linkToPolicy } from '../../../services/navigation'; -import { WithPrivileges, NotAuthorizedSection } from '../../../lib/authorization'; import { useServices } from '../../../app_context'; import { PolicyDetails } from './policy_details'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_table/policy_table.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_table/policy_table.tsx index 7f9c5c5af7705..ba28bcddf5347 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_table/policy_table.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/policy_list/policy_table/policy_table.tsx @@ -21,6 +21,7 @@ import { } from '@elastic/eui'; import { SlmPolicy } from '../../../../../../common/types'; +import { Error } from '../../../../../shared_imports'; import { UIM_POLICY_SHOW_DETAILS_CLICK } from '../../../../constants'; import { useServices } from '../../../../app_context'; import { @@ -28,7 +29,6 @@ import { PolicyExecuteProvider, PolicyDeleteProvider, } from '../../../../components'; -import { Error } from '../../../../components/section_error'; import { linkToAddPolicy, linkToEditPolicy } from '../../../../services/navigation'; import { SendRequestResponse } from '../../../../../shared_imports'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_details/repository_details.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_details/repository_details.tsx index d293f194f647a..9932f14664076 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_details/repository_details.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_details/repository_details.tsx @@ -25,6 +25,8 @@ import { import 'brace/theme/textmate'; +import { SectionError, Error } from '../../../../../shared_imports'; + import { useServices } from '../../../../app_context'; import { documentationLinksService } from '../../../../services/documentation'; import { @@ -35,7 +37,8 @@ import { import { textService } from '../../../../services/text'; import { linkToSnapshots, linkToEditRepository } from '../../../../services/navigation'; -import { REPOSITORY_TYPES } from '../../../../../../common/constants'; +import { REPOSITORY_TYPES } from '../../../../../../common'; + import { Repository, RepositoryVerification, @@ -43,10 +46,8 @@ import { } from '../../../../../../common/types'; import { RepositoryDeleteProvider, - SectionError, SectionLoading, RepositoryVerificationBadge, - Error, } from '../../../../components'; import { TypeDetails } from './type_details'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_list.tsx index 6fa12537e9d6f..2256fa5991dec 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_list.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_list.tsx @@ -10,7 +10,8 @@ import { RouteComponentProps } from 'react-router-dom'; import { EuiButton, EuiEmptyPrompt } from '@elastic/eui'; import { Repository } from '../../../../../common/types'; -import { SectionError, SectionLoading, Error } from '../../../components'; +import { SectionError, Error } from '../../../../shared_imports'; +import { SectionLoading } from '../../../components'; import { BASE_PATH, UIM_REPOSITORY_LIST_LOAD } from '../../../constants'; import { useServices } from '../../../app_context'; import { useLoadRepositories } from '../../../services/http'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_table/repository_table.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_table/repository_table.tsx index 7c0438f6b837f..bf2643d78bca1 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_table/repository_table.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/repository_list/repository_table/repository_table.tsx @@ -15,15 +15,14 @@ import { EuiIconTip, } from '@elastic/eui'; -import { REPOSITORY_TYPES } from '../../../../../../common/constants'; +import { REPOSITORY_TYPES } from '../../../../../../common'; import { Repository, RepositoryType } from '../../../../../../common/types'; -import { Error } from '../../../../components/section_error'; +import { Error, SendRequestResponse } from '../../../../../shared_imports'; import { RepositoryDeleteProvider } from '../../../../components'; import { UIM_REPOSITORY_SHOW_DETAILS_CLICK } from '../../../../constants'; import { useServices } from '../../../../app_context'; import { textService } from '../../../../services/text'; import { linkToEditRepository, linkToAddRepository } from '../../../../services/navigation'; -import { SendRequestResponse } from '../../../../../shared_imports'; interface Props { repositories: Repository[]; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/restore_list/restore_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/restore_list/restore_list.tsx index da9ce3b124a11..0e3d9363d0535 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/restore_list/restore_list.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/restore_list/restore_list.tsx @@ -18,14 +18,19 @@ import { EuiLoadingSpinner, EuiLink, } from '@elastic/eui'; -import { APP_RESTORE_INDEX_PRIVILEGES } from '../../../../../common/constants'; -import { SectionError, SectionLoading, Error } from '../../../components'; +import { APP_RESTORE_INDEX_PRIVILEGES } from '../../../../../common'; +import { + WithPrivileges, + NotAuthorizedSection, + SectionError, + Error, +} from '../../../../shared_imports'; +import { SectionLoading } from '../../../components'; import { UIM_RESTORE_LIST_LOAD } from '../../../constants'; import { useLoadRestores } from '../../../services/http'; import { linkToSnapshots } from '../../../services/navigation'; import { useServices } from '../../../app_context'; import { RestoreTable } from './restore_table'; -import { WithPrivileges, NotAuthorizedSection } from '../../../lib/authorization'; const ONE_SECOND_MS = 1000; const TEN_SECONDS_MS = 10 * 1000; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/snapshot_details.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/snapshot_details.tsx index d16545debe1ec..1943762a3c36e 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/snapshot_details.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_details/snapshot_details.tsx @@ -23,12 +23,8 @@ import React, { Fragment, useState, useEffect } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { SnapshotDetails as ISnapshotDetails } from '../../../../../../common/types'; -import { - SectionError, - SectionLoading, - SnapshotDeleteProvider, - Error, -} from '../../../../components'; +import { SectionError, Error } from '../../../../../shared_imports'; +import { SectionLoading, SnapshotDeleteProvider } from '../../../../components'; import { useServices } from '../../../../app_context'; import { UIM_SNAPSHOT_DETAIL_PANEL_SUMMARY_TAB, diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx index fe99ccb6f596c..30e4c771644bc 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_list.tsx @@ -10,10 +10,10 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { RouteComponentProps } from 'react-router-dom'; import { EuiButton, EuiCallOut, EuiLink, EuiEmptyPrompt, EuiSpacer, EuiIcon } from '@elastic/eui'; -import { APP_SLM_CLUSTER_PRIVILEGES } from '../../../../../common/constants'; -import { SectionError, SectionLoading, Error } from '../../../components'; +import { APP_SLM_CLUSTER_PRIVILEGES } from '../../../../../common'; +import { WithPrivileges, SectionError, Error } from '../../../../shared_imports'; +import { SectionLoading } from '../../../components'; import { BASE_PATH, UIM_SNAPSHOT_LIST_LOAD } from '../../../constants'; -import { WithPrivileges } from '../../../lib/authorization'; import { documentationLinksService } from '../../../services/documentation'; import { useLoadSnapshots } from '../../../services/http'; import { diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_table/snapshot_table.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_table/snapshot_table.tsx index ad64dcc7adcfe..427c241970007 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_table/snapshot_table.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/home/snapshot_list/snapshot_table/snapshot_table.tsx @@ -17,10 +17,10 @@ import { } from '@elastic/eui'; import { SnapshotDetails } from '../../../../../../common/types'; +import { Error } from '../../../../../shared_imports'; import { SNAPSHOT_STATE, UIM_SNAPSHOT_SHOW_DETAILS_CLICK } from '../../../../constants'; import { useServices } from '../../../../app_context'; import { linkToRepository, linkToRestoreSnapshot } from '../../../../services/navigation'; -import { Error } from '../../../../components/section_error'; import { DataPlaceholder, FormattedDateTime, SnapshotDeleteProvider } from '../../../../components'; import { SendRequestResponse } from '../../../../../shared_imports'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/policy_add/policy_add.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/policy_add/policy_add.tsx index 4eb0f54978d09..6d1a432be7f9f 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/policy_add/policy_add.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/policy_add/policy_add.tsx @@ -9,9 +9,11 @@ import { RouteComponentProps } from 'react-router-dom'; import { EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle } from '@elastic/eui'; import { SlmPolicyPayload } from '../../../../common/types'; -import { TIME_UNITS } from '../../../../common/constants'; +import { TIME_UNITS } from '../../../../common'; -import { PolicyForm, SectionError, SectionLoading, Error } from '../../components'; +import { SectionError, Error } from '../../../shared_imports'; + +import { PolicyForm, SectionLoading } from '../../components'; import { BASE_PATH, DEFAULT_POLICY_SCHEDULE } from '../../constants'; import { breadcrumbService, docTitleService } from '../../services/navigation'; import { addPolicy, useLoadIndices } from '../../services/http'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/policy_edit/policy_edit.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/policy_edit/policy_edit.tsx index 9ca7eba5c4eeb..0f1473fc05492 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/policy_edit/policy_edit.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/policy_edit/policy_edit.tsx @@ -9,8 +9,9 @@ import { RouteComponentProps } from 'react-router-dom'; import { EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle, EuiCallOut } from '@elastic/eui'; import { SlmPolicyPayload } from '../../../../common/types'; +import { SectionError, Error } from '../../../shared_imports'; import { TIME_UNITS } from '../../../../common/constants'; -import { SectionError, SectionLoading, PolicyForm, Error } from '../../components'; +import { SectionLoading, PolicyForm } from '../../components'; import { BASE_PATH } from '../../constants'; import { useServices } from '../../app_context'; import { breadcrumbService, docTitleService } from '../../services/navigation'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/repository_add/repository_add.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/repository_add/repository_add.tsx index 126e04bc7dc1d..08bfde833c368 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/repository_add/repository_add.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/repository_add/repository_add.tsx @@ -12,7 +12,9 @@ import { RouteComponentProps } from 'react-router-dom'; import { EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle } from '@elastic/eui'; import { Repository, EmptyRepository } from '../../../../common/types'; -import { RepositoryForm, SectionError } from '../../components'; +import { SectionError } from '../../../shared_imports'; + +import { RepositoryForm } from '../../components'; import { BASE_PATH, Section } from '../../constants'; import { breadcrumbService, docTitleService } from '../../services/navigation'; import { addRepository } from '../../services/http'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/repository_edit/repository_edit.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/repository_edit/repository_edit.tsx index aa29b8b9f0551..95f8b9b8bde7d 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/repository_edit/repository_edit.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/repository_edit/repository_edit.tsx @@ -10,7 +10,8 @@ import { RouteComponentProps } from 'react-router-dom'; import { EuiCallOut, EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle } from '@elastic/eui'; import { Repository, EmptyRepository } from '../../../../common/types'; -import { RepositoryForm, SectionError, SectionLoading, Error } from '../../components'; +import { SectionError, Error } from '../../../shared_imports'; +import { RepositoryForm, SectionLoading } from '../../components'; import { BASE_PATH, Section } from '../../constants'; import { useServices } from '../../app_context'; import { breadcrumbService, docTitleService } from '../../services/navigation'; diff --git a/x-pack/plugins/snapshot_restore/public/application/sections/restore_snapshot/restore_snapshot.tsx b/x-pack/plugins/snapshot_restore/public/application/sections/restore_snapshot/restore_snapshot.tsx index 252fd07a85f80..9eabed8341ee0 100644 --- a/x-pack/plugins/snapshot_restore/public/application/sections/restore_snapshot/restore_snapshot.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/sections/restore_snapshot/restore_snapshot.tsx @@ -9,8 +9,9 @@ import { RouteComponentProps } from 'react-router-dom'; import { EuiPageBody, EuiPageContent, EuiSpacer, EuiTitle } from '@elastic/eui'; import { SnapshotDetails, RestoreSettings } from '../../../../common/types'; +import { SectionError, Error } from '../../../shared_imports'; import { BASE_PATH } from '../../constants'; -import { SectionError, SectionLoading, RestoreSnapshotForm, Error } from '../../components'; +import { SectionLoading, RestoreSnapshotForm } from '../../components'; import { useServices } from '../../app_context'; import { breadcrumbService, docTitleService } from '../../services/navigation'; import { useLoadSnapshot, executeRestore } from '../../services/http'; diff --git a/x-pack/plugins/snapshot_restore/public/application/services/http/use_request.ts b/x-pack/plugins/snapshot_restore/public/application/services/http/use_request.ts index 200d601fd2ce9..27a565ccb74bc 100644 --- a/x-pack/plugins/snapshot_restore/public/application/services/http/use_request.ts +++ b/x-pack/plugins/snapshot_restore/public/application/services/http/use_request.ts @@ -9,11 +9,10 @@ import { UseRequestConfig, sendRequest as _sendRequest, useRequest as _useRequest, + Error as CustomError, } from '../../../shared_imports'; -import { Error as CustomError } from '../../components/section_error'; - -import { httpService } from './index'; +import { httpService } from '.'; export const sendRequest = (config: SendRequestConfig) => { return _sendRequest(httpService.httpClient, config); diff --git a/x-pack/plugins/snapshot_restore/public/shared_imports.ts b/x-pack/plugins/snapshot_restore/public/shared_imports.ts index 7e7ef09d0c09d..e0024ea8e0c12 100644 --- a/x-pack/plugins/snapshot_restore/public/shared_imports.ts +++ b/x-pack/plugins/snapshot_restore/public/shared_imports.ts @@ -12,4 +12,10 @@ export { useRequest, CronEditor, DAY, + SectionError, + Error, + WithPrivileges, + useAuthorizationContext, + NotAuthorizedSection, + AuthorizationProvider, } from '../../../../src/plugins/es_ui_shared/public'; diff --git a/x-pack/plugins/snapshot_restore/server/routes/api/app.ts b/x-pack/plugins/snapshot_restore/server/routes/api/app.ts index 5d334fddc144b..bda64fdb66571 100644 --- a/x-pack/plugins/snapshot_restore/server/routes/api/app.ts +++ b/x-pack/plugins/snapshot_restore/server/routes/api/app.ts @@ -3,12 +3,13 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { Privileges } from '../../../common/types'; +import { Privileges } from '../../../../../../src/plugins/es_ui_shared/public'; + import { APP_REQUIRED_CLUSTER_PRIVILEGES, APP_RESTORE_INDEX_PRIVILEGES, APP_SLM_CLUSTER_PRIVILEGES, -} from '../../../common/constants'; +} from '../../../common'; import { RouteDependencies } from '../../types'; import { addBasePath } from '../helpers'; diff --git a/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts b/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts index 72faab0d2c892..d842f07cdb205 100644 --- a/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts +++ b/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts @@ -57,26 +57,26 @@ describe('copySavedObjectsToSpaces', () => { typeRegistry.getAllTypes.mockReturnValue([ { name: 'dashboard', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'visualization', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'globaltype', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: false, mappings: { properties: {} }, }, ]); typeRegistry.isNamespaceAgnostic.mockImplementation((type: string) => - typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceAgnostic) + typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceType === 'agnostic') ); coreStart.savedObjects.getTypeRegistry.mockReturnValue(typeRegistry); diff --git a/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts b/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts index aa1d5e9a47832..0654712ecff0e 100644 --- a/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts +++ b/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts @@ -57,26 +57,26 @@ describe('resolveCopySavedObjectsToSpacesConflicts', () => { typeRegistry.getAllTypes.mockReturnValue([ { name: 'dashboard', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'visualization', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'globaltype', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: false, mappings: { properties: {} }, }, ]); typeRegistry.isNamespaceAgnostic.mockImplementation((type: string) => - typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceAgnostic) + typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceType === 'agnostic') ); coreStart.savedObjects.getTypeRegistry.mockReturnValue(typeRegistry); diff --git a/x-pack/plugins/spaces/server/plugin.test.ts b/x-pack/plugins/spaces/server/plugin.test.ts index 0b9905d5e9c95..75ddee772b168 100644 --- a/x-pack/plugins/spaces/server/plugin.test.ts +++ b/x-pack/plugins/spaces/server/plugin.test.ts @@ -81,7 +81,7 @@ describe('Spaces Plugin', () => { expect(core.savedObjects.registerType).toHaveBeenCalledWith({ name: 'space', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: true, mappings: expect.any(Object), migrations: expect.any(Object), diff --git a/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_mock_so_service.ts b/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_mock_so_service.ts index d8c318369834e..cbe832e485d66 100644 --- a/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_mock_so_service.ts +++ b/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_mock_so_service.ts @@ -46,37 +46,37 @@ export const createMockSavedObjectsService = (spaces: any[] = []) => { typeRegistry.getAllTypes.mockReturnValue([ { name: 'visualization', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'dashboard', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'index-pattern', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'globalType', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: false, mappings: { properties: {} }, }, { name: 'space', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: true, mappings: { properties: {} }, }, ]); typeRegistry.isNamespaceAgnostic.mockImplementation((type: string) => - typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceAgnostic) + typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceType === 'agnostic') ); savedObjects.getTypeRegistry.mockReturnValue(typeRegistry); diff --git a/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.test.ts b/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.test.ts index 4a9756d9e03f8..31f2c98d74c96 100644 --- a/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.test.ts +++ b/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.test.ts @@ -58,7 +58,7 @@ describe('SpacesSavedObjectsService', () => { "6.6.0": [Function], }, "name": "space", - "namespaceAgnostic": true, + "namespaceType": "agnostic", }, ] `); diff --git a/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.ts b/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.ts index 40ea49573e3c1..58aa1fe08558a 100644 --- a/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.ts +++ b/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.ts @@ -20,7 +20,7 @@ export class SpacesSavedObjectsService { core.savedObjects.registerType({ name: 'space', hidden: true, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: SpacesSavedObjectMappings, migrations: { '6.6.0': migrateToKibana660, diff --git a/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts b/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts index f9961329c088b..569219a0b8990 100644 --- a/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts +++ b/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts @@ -13,21 +13,21 @@ import { SavedObjectTypeRegistry } from 'src/core/server'; const typeRegistry = new SavedObjectTypeRegistry(); typeRegistry.registerType({ name: 'foo', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }); typeRegistry.registerType({ name: 'bar', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }); typeRegistry.registerType({ name: 'space', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: true, mappings: { properties: {} }, }); diff --git a/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_stats_with_xpack.test.ts b/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_stats_with_xpack.test.ts index f2a9995098e59..5dfe3d3e99a7f 100644 --- a/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_stats_with_xpack.test.ts +++ b/x-pack/plugins/telemetry_collection_xpack/server/telemetry_collection/get_stats_with_xpack.test.ts @@ -31,7 +31,6 @@ const kibana = { const getContext = () => ({ version: '8675309-snapshot', - isDev: true, logger: coreMock.createPluginInitializerContext().logger.get('test'), }); diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index bfa4318c13657..8a606e230dc36 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -847,8 +847,6 @@ "data.search.searchSource.indexPatternIdDescription": "{kibanaIndexPattern} インデックス内の ID です。", "data.search.searchSource.indexPatternIdLabel": "インデックスパターン ID", "data.search.searchSource.indexPatternLabel": "インデックスパターン", - "data.search.searchSource.noSearchStrategyRegisteredErrorMessageDescription": "検索リクエストの検索方法が見つかりませんでした", - "data.search.searchSource.noSearchStrategyRegisteredErrorMessageTitle": "検索方法が登録されていません", "data.search.searchSource.queryTimeDescription": "クエリの処理の所要時間です。リクエストの送信やブラウザでのパースの時間は含まれません。", "data.search.searchSource.queryTimeLabel": "クエリ時間", "data.search.searchSource.queryTimeValue": "{queryTime}ms", @@ -2246,7 +2244,6 @@ "kbn.management.editIndexPattern.scripted.table.nameHeader": "名前", "kbn.management.editIndexPattern.scripted.table.scriptDescription": "フィールドのスクリプトです", "kbn.management.editIndexPattern.scripted.table.scriptHeader": "スクリプト", - "kbn.management.editIndexPattern.scripted.unknownModeErrorMessage": "不明なフィールド設定モード {mode}", "kbn.management.editIndexPattern.scriptedHeader": "スクリプトフィールド", "kbn.management.editIndexPattern.scriptedLabel": "ビジュアライゼーションにスクリプトフィールドを使用し、ドキュメントに表示させることができます。但し、スクリプトフィールドは検索できません。", "kbn.management.editIndexPattern.setDefaultAria": "デフォルトのインデックスに設定", @@ -2464,13 +2461,13 @@ "management.breadcrumb": "管理", "management.connectDataDisplayName": "データに接続", "management.displayName": "管理", + "management.nav.label": "管理", + "management.nav.menu": "管理メニュー", + "management.stackManagement.managementDescription": "Elastic Stack の管理を行うセンターコンソールです。", "indexPatternManagement.editIndexPattern.createIndex.defaultButtonDescription": "すべてのデータに完全集約を実行", "indexPatternManagement.editIndexPattern.createIndex.defaultButtonText": "標準インデックスパターン", "indexPatternManagement.editIndexPattern.createIndex.defaultTypeName": "インデックスパターン", "indexPatternManagement.editIndexPattern.list.defaultIndexPatternListName": "デフォルト", - "management.nav.label": "管理", - "management.nav.menu": "管理メニュー", - "management.stackManagement.managementDescription": "Elastic Stack の管理を行うセンターコンソールです。", "newsfeed.emptyPrompt.noNewsText": "Kibanaインスタンスがインターネットにアクセスできない場合、管理者にこの機能を無効にするように依頼してください。そうでない場合は、ニュースを取り込み続けます。", "newsfeed.emptyPrompt.noNewsTitle": "ニュースがない場合", "newsfeed.flyoutList.closeButtonLabel": "閉じる", @@ -8790,8 +8787,6 @@ "xpack.logstash.idFormatErrorMessage": "パイプライン ID は文字またはアンダーラインで始まる必要があり、文字、アンダーライン、ハイフン、数字のみ使用できます", "xpack.logstash.insufficientUserPermissionsDescription": "Logstash パイプラインの管理に必要なユーザーパーミッションがありません", "xpack.logstash.kibanaManagementPipelinesTitle": "Kibana の管理で作成されたパイプラインだけがここに表示されます", - "xpack.logstash.managementSection.createPipelineTitle": "パイプラインの作成", - "xpack.logstash.managementSection.editPipelineTitle": "パイプラインの編集", "xpack.logstash.managementSection.enableSecurityDescription": "Logstash パイプライン管理機能を使用するには、セキュリティを有効にする必要があります。elasticsearch.yml で xpack.security.enabled: true に設定してください。", "xpack.logstash.managementSection.licenseDoesNotSupportDescription": "ご使用の {licenseType} ライセンスは Logstash パイプライン管理をサポートしていません。ライセンスをアップグレードしてください。", "xpack.logstash.managementSection.notPossibleToManagePipelinesMessage": "現在ライセンス情報が利用できないため Logstash パイプラインを使用できません。", @@ -9480,8 +9475,6 @@ "xpack.ml.dataframe.analytics.classificationExploration.evaluateJobIdTitle": "分類ジョブID {jobId}の評価", "xpack.ml.dataframe.analytics.classificationExploration.firstDocumentsShownHelpText": "予測がある最初の{searchSize}のドキュメントを示す", "xpack.ml.dataframe.analytics.classificationExploration.generalizationDocsCount": "{docsCount, plural, one {# doc} other {# docs}}が評価されました", - "xpack.ml.dataframe.analytics.classificationExploration.indexArrayBadgeContent": "配列", - "xpack.ml.dataframe.analytics.classificationExploration.indexArrayToolTipContent": "この配列ベースの列の完全なコンテンツは表示できません。", "xpack.ml.dataframe.analytics.classificationExploration.jobCapsFetchError": "結果を取得できません。インデックスのフィールドデータの読み込み中にエラーが発生しました。", "xpack.ml.dataframe.analytics.classificationExploration.jobConfigurationFetchError": "結果を取得できません。ジョブ構成データの読み込み中にエラーが発生しました。", "xpack.ml.dataframe.analytics.classificationExploration.jobConfigurationNoResultsMessage": "結果が見つかりませんでした。", @@ -9575,11 +9568,7 @@ "xpack.ml.dataframe.analytics.regressionExploration.generalError": "データの読み込み中にエラーが発生しました。", "xpack.ml.dataframe.analytics.regressionExploration.generalizationDocsCount": "{docsCount, plural, one {# doc} other {# docs}}が評価されました", "xpack.ml.dataframe.analytics.regressionExploration.generalizationErrorTitle": "一般化エラー", - "xpack.ml.dataframe.analytics.regressionExploration.indexArrayBadgeContent": "配列", - "xpack.ml.dataframe.analytics.regressionExploration.indexArrayToolTipContent": "この配列ベースの列の完全なコンテンツは表示できません。", "xpack.ml.dataframe.analytics.regressionExploration.indexError": "インデックスデータの読み込み中にエラーが発生しました。", - "xpack.ml.dataframe.analytics.regressionExploration.isTestingLabel": "テスト", - "xpack.ml.dataframe.analytics.regressionExploration.isTrainingLabel": "トレーニング", "xpack.ml.dataframe.analytics.regressionExploration.jobCapsFetchError": "結果を取得できません。インデックスのフィールドデータの読み込み中にエラーが発生しました。", "xpack.ml.dataframe.analytics.regressionExploration.jobConfigurationFetchError": "結果を取得できません。ジョブ構成データの読み込み中にエラーが発生しました。", "xpack.ml.dataframe.analytics.regressionExploration.meanSquaredErrorText": "平均二乗エラー", @@ -9591,9 +9580,6 @@ "xpack.ml.dataframe.analytics.regressionExploration.queryParsingErrorMessage": "クエリをパースできません。", "xpack.ml.dataframe.analytics.regressionExploration.rSquaredText": "R の二乗", "xpack.ml.dataframe.analytics.regressionExploration.rSquaredTooltipContent": "適合度を表します。モデルによる観察された結果の複製の効果を測定します。", - "xpack.ml.dataframe.analytics.regressionExploration.searchBoxPlaceholder": "例: 平均>0.5", - "xpack.ml.dataframe.analytics.regressionExploration.selectColumnsAriaLabel": "列を選択", - "xpack.ml.dataframe.analytics.regressionExploration.selectFieldsPopoverTitle": "フィールドを選択", "xpack.ml.dataframe.analytics.regressionExploration.tableJobIdTitle": "回帰ジョブID {jobId}のデスティネーションインデックス", "xpack.ml.dataframe.analytics.regressionExploration.trainingDocsCount": "{docsCount, plural, one {# doc} other {# docs}}が評価されました", "xpack.ml.dataframe.analytics.regressionExploration.trainingErrorTitle": "トレーニングエラー", @@ -15962,7 +15948,7 @@ "xpack.triggersActionsUI.sections.alertAdd.saveButtonLabel": "保存", "xpack.triggersActionsUI.sections.alertAdd.saveErrorNotificationText": "アラートを作成できません。", "xpack.triggersActionsUI.sections.alertAdd.saveSuccessNotificationText": "「{alertName}」 を保存しました", - "xpack.triggersActionsUI.sections.alertAdd.selectIndex": "インデックスを選択してください。", + "xpack.triggersActionsUI.sections.alertAdd.selectIndex": "インデックスを選択してください", "xpack.triggersActionsUI.sections.alertAdd.threshold.closeIndexPopoverLabel": "閉じる", "xpack.triggersActionsUI.sections.alertAdd.threshold.fixErrorInExpressionBelowValidationMessage": "下の表現のエラーを修正してください。", "xpack.triggersActionsUI.sections.alertAdd.threshold.howToBroadenSearchQueryDescription": "* で検索クエリの範囲を広げます。", @@ -16046,7 +16032,6 @@ "xpack.triggersActionsUI.sections.alertsList.bulkActionPopover.muteAllTitle": "ミュート", "xpack.triggersActionsUI.sections.alertsList.bulkActionPopover.unmuteAllTitle": "ミュート解除", "xpack.triggersActionsUI.sections.alertsList.collapsedItemActons.deleteTitle": "削除", - "xpack.triggersActionsUI.sections.alertsList.collapsedItemActons.enableTitle": "有効にする", "xpack.triggersActionsUI.sections.alertsList.collapsedItemActons.muteTitle": "ミュート", "xpack.triggersActionsUI.sections.alertsList.collapsedItemActons.popoverButtonTitle": "アクション", "xpack.triggersActionsUI.components.emptyPrompt.emptyButton": "アラートの作成", @@ -16234,16 +16219,10 @@ "xpack.uptime.components.embeddables.embeddedMap.embeddablePanelTitle": "オブザーバー位置情報マップを監視", "xpack.uptime.durationChart.emptyPrompt.description": "このモニターは選択された時間範囲で一度も {emphasizedText} していません。", "xpack.uptime.durationChart.emptyPrompt.title": "利用可能な期間データがありません", - "xpack.uptime.emptyState.configureHeartbeatLinkText": "Heartbeat を構成", - "xpack.uptime.emptyState.configureHeartbeatToGetStartedMessage": "アップタイムデータの収集を開始するには {configureHeartbeatLink}。", "xpack.uptime.emptyState.loadingMessage": "読み込み中…", - "xpack.uptime.emptyState.noDataMessage": "アップタイムデータが見つかりませんでした", - "xpack.uptime.emptyState.noDataTitle": "利用可能なアップタイムデータがありません", - "xpack.uptime.emptyState.noIndexTitle": "アップタイムインデックスが見つかりません", "xpack.uptime.emptyStateError.notAuthorized": "アップタイムデータの表示が承認されていません。システム管理者にお問い合わせください。", "xpack.uptime.emptyStateError.notFoundPage": "ページが見つかりません", "xpack.uptime.emptyStateError.title": "エラー", - "xpack.uptime.errorMessage": "エラー: {message}", "xpack.uptime.featureCatalogueDescription": "エンドポイントヘルスチェックとアップタイム監視を行います。", "xpack.uptime.featureRegistry.uptimeFeatureName": "アップタイム", "xpack.uptime.filterBar.ariaLabel": "概要ページのインプットフィルター基準", @@ -16265,7 +16244,6 @@ "xpack.uptime.locationName.helpLinkAnnotation": "場所を追加", "xpack.uptime.ml.durationChart.exploreInMlApp": "ML アプリで探索", "xpack.uptime.ml.enableAnomalyDetectionPanel.anomalyDetectionTitle": "異常検知", - "xpack.uptime.ml.enableAnomalyDetectionPanel.callout.jobExistsDescription.viewJobLinkText": "既存のジョブを表示", "xpack.uptime.ml.enableAnomalyDetectionPanel.createMLJobDescription": "ここでは稼働状況監視の応答時間について異常スコアを計算する機械学習ジョブを作成できます。\n 有効にすると、詳細ページの監視期間チャートに予想範囲が表示され、グラフに異常の注釈が付きます。\n 地理的な地域にわたって遅延が増える期間を特定することもできます。", "xpack.uptime.ml.enableAnomalyDetectionPanel.createNewJobButtonLabel": "新規ジョブを作成", "xpack.uptime.ml.enableAnomalyDetectionPanel.disableAnomalyDetectionTitle": "異常検知を無効にする", @@ -16760,4 +16738,4 @@ "xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "フィールドを選択してください。", "xpack.watcher.watcherDescription": "アラートの作成、管理、監視によりデータへの変更を検知します。" } -} +} \ No newline at end of file diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 004ba09503c99..faee95b8172b7 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -848,8 +848,6 @@ "data.search.searchSource.indexPatternIdDescription": "{kibanaIndexPattern} 索引中的 ID。", "data.search.searchSource.indexPatternIdLabel": "索引模式 ID", "data.search.searchSource.indexPatternLabel": "索引模式", - "data.search.searchSource.noSearchStrategyRegisteredErrorMessageDescription": "无法为该搜索请求找到搜索策略", - "data.search.searchSource.noSearchStrategyRegisteredErrorMessageTitle": "未注册任何搜索策略", "data.search.searchSource.queryTimeDescription": "处理查询所花费的时间。不包括发送请求或在浏览器中解析它的时间。", "data.search.searchSource.queryTimeLabel": "查询时间", "data.search.searchSource.queryTimeValue": "{queryTime}ms", @@ -2247,7 +2245,6 @@ "kbn.management.editIndexPattern.scripted.table.nameHeader": "名称", "kbn.management.editIndexPattern.scripted.table.scriptDescription": "字段的脚本", "kbn.management.editIndexPattern.scripted.table.scriptHeader": "脚本", - "kbn.management.editIndexPattern.scripted.unknownModeErrorMessage": "未知 fieldSettings 模式 {mode}", "kbn.management.editIndexPattern.scriptedHeader": "脚本字段", "kbn.management.editIndexPattern.scriptedLabel": "可以在可视化中使用脚本字段,并在您的文档中显示它们。但是,您不能搜索脚本字段。", "kbn.management.editIndexPattern.setDefaultAria": "设置为默认索引", @@ -2465,13 +2462,13 @@ "management.breadcrumb": "管理", "management.connectDataDisplayName": "连接数据", "management.displayName": "管理", + "management.nav.label": "管理", + "management.nav.menu": "管理菜单", + "management.stackManagement.managementDescription": "您用于管理 Elastic Stack 的中心控制台。", "indexPatternManagement.editIndexPattern.createIndex.defaultButtonDescription": "对任何数据执行完全聚合", "indexPatternManagement.editIndexPattern.createIndex.defaultButtonText": "标准索引模式", "indexPatternManagement.editIndexPattern.createIndex.defaultTypeName": "索引模式", "indexPatternManagement.editIndexPattern.list.defaultIndexPatternListName": "默认值", - "management.nav.label": "管理", - "management.nav.menu": "管理菜单", - "management.stackManagement.managementDescription": "您用于管理 Elastic Stack 的中心控制台。", "newsfeed.emptyPrompt.noNewsText": "如果您的 Kibana 实例没有 Internet 连接,请让您的管理员禁用此功能。否则,我们将不断尝试获取新闻。", "newsfeed.emptyPrompt.noNewsTitle": "无新闻?", "newsfeed.flyoutList.closeButtonLabel": "鍏抽棴", @@ -8793,8 +8790,6 @@ "xpack.logstash.idFormatErrorMessage": "管道 ID 必须以字母或下划线开头,并只能包含字母、下划线、短划线和数字", "xpack.logstash.insufficientUserPermissionsDescription": "管理 Logstash 管道的用户权限不足", "xpack.logstash.kibanaManagementPipelinesTitle": "仅在 Kibana“管理”中创建的管道显示在此处", - "xpack.logstash.managementSection.createPipelineTitle": "创建管道", - "xpack.logstash.managementSection.editPipelineTitle": "编辑管道", "xpack.logstash.managementSection.enableSecurityDescription": "必须启用 Security,才能使用 Logstash 管道管理功能。请在 elasticsearch.yml 中设置 xpack.security.enabled: true。", "xpack.logstash.managementSection.licenseDoesNotSupportDescription": "您的{licenseType}许可不支持 Logstash 管道管理功能。请升级您的许可。", "xpack.logstash.managementSection.notPossibleToManagePipelinesMessage": "您不能管理 Logstash 管道,因为许可信息当前不可用。", @@ -9483,8 +9478,6 @@ "xpack.ml.dataframe.analytics.classificationExploration.evaluateJobIdTitle": "分类作业 ID {jobId} 的评估", "xpack.ml.dataframe.analytics.classificationExploration.firstDocumentsShownHelpText": "正在显示有相关预测存在的前 {searchSize} 个文档", "xpack.ml.dataframe.analytics.classificationExploration.generalizationDocsCount": "{docsCount, plural, one {# 个文档} other {# 个文档}}已评估", - "xpack.ml.dataframe.analytics.classificationExploration.indexArrayBadgeContent": "数组", - "xpack.ml.dataframe.analytics.classificationExploration.indexArrayToolTipContent": "此基于数组的列的完整内容无法显示。", "xpack.ml.dataframe.analytics.classificationExploration.jobCapsFetchError": "无法提取结果。加载索引的字段数据时发生错误。", "xpack.ml.dataframe.analytics.classificationExploration.jobConfigurationFetchError": "无法提取结果。加载作业配置数据时发生错误。", "xpack.ml.dataframe.analytics.classificationExploration.jobConfigurationNoResultsMessage": "未找到结果。", @@ -9578,11 +9571,7 @@ "xpack.ml.dataframe.analytics.regressionExploration.generalError": "加载数据时出错。", "xpack.ml.dataframe.analytics.regressionExploration.generalizationDocsCount": "{docsCount, plural, one {# 个文档} other {# 个文档}}已评估", "xpack.ml.dataframe.analytics.regressionExploration.generalizationErrorTitle": "泛化误差", - "xpack.ml.dataframe.analytics.regressionExploration.indexArrayBadgeContent": "数组", - "xpack.ml.dataframe.analytics.regressionExploration.indexArrayToolTipContent": "此基于数组的列的完整内容无法显示。", "xpack.ml.dataframe.analytics.regressionExploration.indexError": "加载索引数据时出错。", - "xpack.ml.dataframe.analytics.regressionExploration.isTestingLabel": "测试", - "xpack.ml.dataframe.analytics.regressionExploration.isTrainingLabel": "培训", "xpack.ml.dataframe.analytics.regressionExploration.jobCapsFetchError": "无法提取结果。加载索引的字段数据时发生错误。", "xpack.ml.dataframe.analytics.regressionExploration.jobConfigurationFetchError": "无法提取结果。加载作业配置数据时发生错误。", "xpack.ml.dataframe.analytics.regressionExploration.meanSquaredErrorText": "均方误差", @@ -9594,9 +9583,6 @@ "xpack.ml.dataframe.analytics.regressionExploration.queryParsingErrorMessage": "无法解析查询。", "xpack.ml.dataframe.analytics.regressionExploration.rSquaredText": "R 平方", "xpack.ml.dataframe.analytics.regressionExploration.rSquaredTooltipContent": "表示拟合优度。度量模型复制被观察结果的优良性。", - "xpack.ml.dataframe.analytics.regressionExploration.searchBoxPlaceholder": "例如 avg>0.5", - "xpack.ml.dataframe.analytics.regressionExploration.selectColumnsAriaLabel": "选择列", - "xpack.ml.dataframe.analytics.regressionExploration.selectFieldsPopoverTitle": "选择字段", "xpack.ml.dataframe.analytics.regressionExploration.tableJobIdTitle": "回归作业 ID {jobId} 的目标索引", "xpack.ml.dataframe.analytics.regressionExploration.trainingDocsCount": "{docsCount, plural, one {# 个文档} other {# 个文档}}已评估", "xpack.ml.dataframe.analytics.regressionExploration.trainingErrorTitle": "训练误差", @@ -15959,7 +15945,7 @@ "xpack.triggersActionsUI.sections.addModalConnectorForm.updateSuccessNotificationText": "已创建“{connectorName}”", "xpack.triggersActionsUI.sections.alertAdd.betaBadgeTooltipContent": "{pluginName} 为公测版,可能会进行更改。设计和代码相对于正式发行版功能还不够成熟,将按原样提供,且不提供任何保证。公测版功能不受正式发行版功能支持 SLA 的约束。", "xpack.triggersActionsUI.sections.alertAdd.cancelButtonLabel": "取消", - "xpack.triggersActionsUI.sections.alertAdd.conditionPrompt": "定义条件。", + "xpack.triggersActionsUI.sections.alertAdd.conditionPrompt": "定义条件", "xpack.triggersActionsUI.sections.alertAdd.errorLoadingAlertVisualizationTitle": "无法加载告警可视化", "xpack.triggersActionsUI.sections.alertAdd.flyoutTitle": "创建告警", "xpack.triggersActionsUI.sections.alertAdd.loadingAlertVisualizationDescription": "正在加载告警可视化……", @@ -15967,7 +15953,7 @@ "xpack.triggersActionsUI.sections.alertAdd.saveButtonLabel": "保存", "xpack.triggersActionsUI.sections.alertAdd.saveErrorNotificationText": "无法创建告警。", "xpack.triggersActionsUI.sections.alertAdd.saveSuccessNotificationText": "已保存“{alertName}”", - "xpack.triggersActionsUI.sections.alertAdd.selectIndex": "选择索引。", + "xpack.triggersActionsUI.sections.alertAdd.selectIndex": "选择索引", "xpack.triggersActionsUI.sections.alertAdd.threshold.closeIndexPopoverLabel": "关闭", "xpack.triggersActionsUI.sections.alertAdd.threshold.fixErrorInExpressionBelowValidationMessage": "表达式包含错误。", "xpack.triggersActionsUI.sections.alertAdd.threshold.howToBroadenSearchQueryDescription": "使用 * 可扩大您的查询范围。", @@ -16051,7 +16037,6 @@ "xpack.triggersActionsUI.sections.alertsList.bulkActionPopover.muteAllTitle": "静音", "xpack.triggersActionsUI.sections.alertsList.bulkActionPopover.unmuteAllTitle": "取消静音", "xpack.triggersActionsUI.sections.alertsList.collapsedItemActons.deleteTitle": "删除", - "xpack.triggersActionsUI.sections.alertsList.collapsedItemActons.enableTitle": "启用", "xpack.triggersActionsUI.sections.alertsList.collapsedItemActons.muteTitle": "静音", "xpack.triggersActionsUI.sections.alertsList.collapsedItemActons.popoverButtonTitle": "操作", "xpack.triggersActionsUI.components.emptyPrompt.emptyButton": "创建告警", @@ -16239,16 +16224,10 @@ "xpack.uptime.components.embeddables.embeddedMap.embeddablePanelTitle": "监测观察者位置地图", "xpack.uptime.durationChart.emptyPrompt.description": "在选定时间范围内此监测从未{emphasizedText}。", "xpack.uptime.durationChart.emptyPrompt.title": "没有持续时间数据", - "xpack.uptime.emptyState.configureHeartbeatLinkText": "配置 Heartbeat", - "xpack.uptime.emptyState.configureHeartbeatToGetStartedMessage": "{configureHeartbeatLink}以开始收集运行时间数据。", "xpack.uptime.emptyState.loadingMessage": "正在加载……", - "xpack.uptime.emptyState.noDataMessage": "未找到任何运行时间数据", - "xpack.uptime.emptyState.noDataTitle": "没有可用的运行时间数据", - "xpack.uptime.emptyState.noIndexTitle": "找不到运行时间索引", "xpack.uptime.emptyStateError.notAuthorized": "您无权查看 Uptime 数据,请联系系统管理员。", "xpack.uptime.emptyStateError.notFoundPage": "未找到页面", "xpack.uptime.emptyStateError.title": "错误", - "xpack.uptime.errorMessage": "错误:{message}", "xpack.uptime.featureCatalogueDescription": "执行终端节点运行状况检查和运行时间监测。", "xpack.uptime.featureRegistry.uptimeFeatureName": "运行时间", "xpack.uptime.filterBar.ariaLabel": "概览页面的输入筛选条件", @@ -16270,7 +16249,6 @@ "xpack.uptime.locationName.helpLinkAnnotation": "添加位置", "xpack.uptime.ml.durationChart.exploreInMlApp": "在 ML 应用中浏览", "xpack.uptime.ml.enableAnomalyDetectionPanel.anomalyDetectionTitle": "异常检测", - "xpack.uptime.ml.enableAnomalyDetectionPanel.callout.jobExistsDescription.viewJobLinkText": "查看现有作业", "xpack.uptime.ml.enableAnomalyDetectionPanel.createMLJobDescription": "在此处可以创建 Machine Learning 作业,以便为运行时间监测计算\n 响应持续时间的异常分数。启用后,详情页面上的监测持续时间图表\n 将显示预期边界并使用异常标注图表。您还可能\n 识别在所有地理区域的延迟增长时段。", "xpack.uptime.ml.enableAnomalyDetectionPanel.createNewJobButtonLabel": "创建新作业", "xpack.uptime.ml.enableAnomalyDetectionPanel.disableAnomalyDetectionTitle": "禁用异常检测", @@ -16765,4 +16743,4 @@ "xpack.watcher.watchEdit.thresholdWatchExpression.aggType.fieldIsRequiredValidationMessage": "此字段必填。", "xpack.watcher.watcherDescription": "通过创建、管理和监测警报来检测数据中的更改。" } -} +} \ No newline at end of file diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty.test.tsx index 7da97b9fe3436..1c9e87310107f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty.test.tsx @@ -90,7 +90,7 @@ describe('pagerduty action params validation', () => { summary: '2323', source: 'source', severity: 'critical', - timestamp: '234654564654', + timestamp: new Date().toISOString(), component: 'test', group: 'group', class: 'test class', @@ -99,6 +99,7 @@ describe('pagerduty action params validation', () => { expect(actionTypeModel.validateParams(actionParams)).toEqual({ errors: { summary: [], + timestamp: [], }, }); }); @@ -156,7 +157,7 @@ describe('PagerDutyParamsFields renders', () => { summary: '2323', source: 'source', severity: SeverityActionOptions.CRITICAL, - timestamp: '234654564654', + timestamp: new Date().toISOString(), component: 'test', group: 'group', class: 'test class', @@ -164,7 +165,7 @@ describe('PagerDutyParamsFields renders', () => { const wrapper = mountWithIntl( {}} index={0} /> diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty.tsx index d99362c618356..15f91ae1d4609 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_action_types/pagerduty.tsx @@ -14,6 +14,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import moment from 'moment'; import { ActionTypeModel, ActionConnectorFieldsProps, @@ -23,6 +24,7 @@ import { import { PagerDutyActionParams, PagerDutyActionConnector } from './types'; import pagerDutySvg from './pagerduty.svg'; import { AddMessageVariables } from '../add_message_variables'; +import { hasMustacheTokens } from '../../lib/has_mustache_tokens'; export function getActionType(): ActionTypeModel { return { @@ -62,6 +64,7 @@ export function getActionType(): ActionTypeModel { const validationResult = { errors: {} }; const errors = { summary: new Array(), + timestamp: new Array(), }; validationResult.errors = errors; if (!actionParams.summary?.length) { @@ -74,6 +77,24 @@ export function getActionType(): ActionTypeModel { ) ); } + if (actionParams.timestamp && !hasMustacheTokens(actionParams.timestamp)) { + if (isNaN(Date.parse(actionParams.timestamp))) { + const { nowShortFormat, nowLongFormat } = getValidTimestampExamples(); + errors.timestamp.push( + i18n.translate( + 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.error.invalidTimestamp', + { + defaultMessage: + 'Timestamp must be a valid date, such as {nowShortFormat} or {nowLongFormat}.', + values: { + nowShortFormat, + nowLongFormat, + }, + } + ) + ); + } + } return validationResult; }, actionConnectorFields: PagerDutyActionConnectorFields, @@ -334,6 +355,8 @@ const PagerDutyParamsFields: React.FunctionComponent 0 && timestamp !== undefined} label={i18n.translate( 'xpack.triggersActionsUI.components.builtinActionTypes.pagerDutyAction.timestampTextFieldLabel', { @@ -355,11 +378,14 @@ const PagerDutyParamsFields: React.FunctionComponent 0 && timestamp !== undefined} onChange={(e: React.ChangeEvent) => { editAction('timestamp', e.target.value, index); }} onBlur={() => { - if (!timestamp) { + if (timestamp?.trim()) { + editAction('timestamp', timestamp.trim(), index); + } else { editAction('timestamp', '', index); } }} @@ -534,3 +560,11 @@ const PagerDutyParamsFields: React.FunctionComponent ); }; + +function getValidTimestampExamples() { + const now = moment(); + return { + nowShortFormat: now.format('YYYY-MM-DD'), + nowLongFormat: now.format('YYYY-MM-DD h:mm:ss'), + }; +} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.scss b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.scss index d0a7039ae24e1..3734cf5d5218b 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.scss +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.scss @@ -1,3 +1,13 @@ .actAlertVisualization__chart { - height: $euiSize * 15; + height: $euiSize * 14; +} + +.actAddAlertSteps { + .euiStep__titleWrapper { + align-items: center; + } + + .euiStep__title { + @include euiTitle('xs'); + } } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.tsx b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.tsx index 7557b17f5b67d..43955db97f295 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/components/builtin_alert_types/threshold/expression.tsx @@ -283,7 +283,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent @@ -396,7 +396,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent @@ -445,12 +445,10 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent ) : null} - - +
{canShowVizualization ? ( - void }) => ( data-test-subj="createFirstAlertButton" key="create-action" fill - iconType="plusInCircle" - iconSide="left" onClick={onCTAClicked} > { + test('returns false for empty string', () => { + expect(hasMustacheTokens('')).toBe(false); + }); + + test('returns false for string without tokens', () => { + expect(hasMustacheTokens(`some random string ${uuid.v4()}`)).toBe(false); + }); + + test('returns true when a template token is present', () => { + expect(hasMustacheTokens('{{context.timestamp}}')).toBe(true); + }); +}); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/has_mustache_tokens.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/has_mustache_tokens.ts new file mode 100644 index 0000000000000..4dcd8113d51fc --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/has_mustache_tokens.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export function hasMustacheTokens(str: string): boolean { + return null !== str.match(/{{.*}}/); +} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx index 488db42f4e843..d4def86b07b1f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx @@ -232,7 +232,7 @@ describe('action_form', () => { Object { "id": "test2", "key": "test2", - "label": "Test connector 2 (pre-configured)", + "label": "Test connector 2 (preconfigured)", }, ] `); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx index 3f964cc167c25..4199cfb7b4b7f 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx @@ -25,6 +25,8 @@ import { EuiIconTip, EuiLink, EuiCallOut, + EuiHorizontalRule, + EuiText, } from '@elastic/eui'; import { HttpSetup, ToastsApi } from 'kibana/public'; import { loadActionTypes, loadAllActions } from '../../lib/action_connector_api'; @@ -150,7 +152,7 @@ export const ActionForm = ({ const preconfiguredMessage = i18n.translate( 'xpack.triggersActionsUI.sections.actionForm.preconfiguredTitleMessage', { - defaultMessage: '(pre-configured)', + defaultMessage: '(preconfigured)', } ); const getSelectedOptions = (actionItemId: string) => { @@ -256,81 +258,87 @@ export const ActionForm = ({ ); return ( - - - - - - -
- - - - - - {checkEnabledResult.isEnabled === false && ( - - - - )} - - -
-
-
- - } - extraAction={ - { - const updatedActions = actions.filter((_item: AlertAction, i: number) => i !== index); - setAlertProperty(updatedActions); - setIsAddActionPanelOpen( - updatedActions.filter((item: AlertAction) => item.id !== actionItem.id).length === 0 - ); - setActiveActionItem(undefined); - }} - /> - } - paddingSize="l" - > - {accordionContent} -
+ + + + + + + +

+ + + + + + {checkEnabledResult.isEnabled === false && ( + + + + )} + + +

+
+
+ + } + extraAction={ + { + const updatedActions = actions.filter( + (_item: AlertAction, i: number) => i !== index + ); + setAlertProperty(updatedActions); + setIsAddActionPanelOpen( + updatedActions.filter((item: AlertAction) => item.id !== actionItem.id).length === + 0 + ); + setActiveActionItem(undefined); + }} + /> + } + paddingSize="l" + > + {accordionContent} +
+ +
); }; @@ -341,96 +349,103 @@ export const ActionForm = ({ const actionTypeRegistered = actionTypeRegistry.get(actionItem.actionTypeId); if (!actionTypeRegistered || actionItem.group !== defaultActionGroupId) return null; return ( - - - - - - -
- -
-
-
- - } - extraAction={ - { - const updatedActions = actions.filter((_item: AlertAction, i: number) => i !== index); - setAlertProperty(updatedActions); - setIsAddActionPanelOpen( - updatedActions.filter((item: AlertAction) => item.id !== actionItem.id).length === 0 - ); - setActiveActionItem(undefined); - }} - /> - } - paddingSize="l" - > - actionItem.id === emptyId) ? ( - - ) : ( - - ) + + + + + + + +

+ +

+
+
+ } - actions={[ - { - setActiveActionItem({ actionTypeId: actionItem.actionTypeId, index }); - setAddModalVisibility(true); + const updatedActions = actions.filter( + (_item: AlertAction, i: number) => i !== index + ); + setAlertProperty(updatedActions); + setIsAddActionPanelOpen( + updatedActions.filter((item: AlertAction) => item.id !== actionItem.id).length === + 0 + ); + setActiveActionItem(undefined); }} - > - - , - ]} - /> -
+ /> + } + paddingSize="l" + > + actionItem.id === emptyId) ? ( + + ) : ( + + ) + } + actions={[ + { + setActiveActionItem({ actionTypeId: actionItem.actionTypeId, index }); + setAddModalVisibility(true); + }} + > + + , + ]} + /> +
+ +
); }; @@ -537,19 +552,34 @@ export const ActionForm = ({ ) : ( - {alertActionsList} - - {isAddActionPanelOpen === false ? ( - setIsAddActionPanelOpen(true)} - > + +

- +

+
+ + {alertActionsList} + {isAddActionPanelOpen === false ? ( +
+ + + + setIsAddActionPanelOpen(true)} + > + + + + +
) : null} {isAddActionPanelOpen ? ( @@ -558,7 +588,7 @@ export const ActionForm = ({
@@ -571,6 +601,7 @@ export const ActionForm = ({ - + {isLoadingActionTypes ? ( { expect(connectorNameField.first().prop('value')).toBe('action-connector'); }); - test('if pre-configured connector rendered correct in the edit form', () => { + test('if preconfigured connector rendered correct in the edit form', () => { const connector = { secrets: {}, id: 'test', actionTypeId: 'test-action-type-id', actionType: 'test-action-type-name', - name: 'pre-configured-connector', + name: 'preconfigured-connector', isPreconfigured: true, referencedByCount: 0, config: {}, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.tsx index a81d6c285f460..690a64ef4f1f3 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connector_edit_flyout.tsx @@ -104,7 +104,7 @@ export const ConnectorEditFlyout = ({ />  
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx index 043a644489d82..566a6030d72be 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/actions_connectors_list/components/actions_connectors_list.tsx @@ -215,7 +215,7 @@ export const ActionsConnectorsList: React.FunctionComponent = () => { label={i18n.translate( 'xpack.triggersActionsUI.sections.alertForm.preconfiguredTitleMessage', { - defaultMessage: 'Pre-configured', + defaultMessage: 'Preconfigured', } )} tooltipContent="This connector can't be deleted." @@ -338,8 +338,6 @@ export const ActionsConnectorsList: React.FunctionComponent = () => { data-test-subj="createActionButton" key="create-action" fill - iconType="plusInCircle" - iconSide="left" onClick={() => setAddFlyoutVisibility(true)} > { key="create-alert" data-test-subj="createAlertButton" fill - iconType="plusInCircle" - iconSide="left" onClick={() => setAlertFlyoutVisibility(true)} > = ({ isOpen={isPopoverOpen} closePopover={() => setIsPopoverOpen(false)} ownFocus + panelPaddingSize="none" data-test-subj="collapsedItemActions" > - - { - if (item.enabled) { - await disableAlert(item); - } else { - await enableAlert(item); + +
+ { + if (item.enabled) { + await disableAlert(item); + } else { + await enableAlert(item); + } + onAlertChanged(); + }} + label={ + } - onAlertChanged(); - }} - label={ + /> + + - } - /> - - - { - if (item.muteAll) { - await unmuteAlert(item); - } else { - await muteAlert(item); + +
+
+ { + if (item.muteAll) { + await unmuteAlert(item); + } else { + await muteAlert(item); + } + onAlertChanged(); + }} + label={ + } - onAlertChanged(); - }} - label={ + /> + + - } - /> - - - - setAlertsToDelete([item.id])} - > - - - - + +
+ + setAlertsToDelete([item.id])} + > +
+
+ +
+
+ +

+ +

+
+
+
+
+
); }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/alert_quick_edit_buttons.scss b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/alert_quick_edit_buttons.scss new file mode 100644 index 0000000000000..a5b4cc258c1b5 --- /dev/null +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/alert_quick_edit_buttons.scss @@ -0,0 +1,5 @@ +.actBulkActionPopover__deleteAll { + .euiButtonEmpty__text { + padding-top: $euiSizeXS; + } +} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/alert_quick_edit_buttons.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/alert_quick_edit_buttons.tsx index eeae0cf54f1a1..26bc8b869a06b 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/alert_quick_edit_buttons.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/alert_quick_edit_buttons.tsx @@ -5,9 +5,9 @@ */ import { i18n } from '@kbn/i18n'; -import React, { useState, Fragment } from 'react'; +import React, { useState } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { EuiButtonEmpty } from '@elastic/eui'; +import { EuiButtonEmpty, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; import { Alert } from '../../../../types'; import { useAppDependencies } from '../../../app_context'; @@ -15,6 +15,7 @@ import { withBulkAlertOperations, ComponentOpts as BulkOperationsComponentOpts, } from './with_bulk_alert_api_operations'; +import './alert_quick_edit_buttons.scss'; export type ComponentOpts = { selectedItems: Alert[]; @@ -147,72 +148,84 @@ export const AlertQuickEditButtons: React.FunctionComponent = ({ } return ( - + {!allAlertsMuted && ( - - - + + + + + )} {allAlertsMuted && ( - - - + + + + + )} {allAlertsDisabled && ( - - - + + + + + )} {!allAlertsDisabled && ( + + + + + + )} + - )} - - - - - + + ); }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/bulk_operation_popover.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/bulk_operation_popover.tsx index d0fd0e1792818..935b0bd8985ca 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/bulk_operation_popover.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/common/components/bulk_operation_popover.tsx @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useState } from 'react'; +import React, { useState, Fragment } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { EuiButton, EuiFormRow, EuiPopover } from '@elastic/eui'; +import { EuiButton, EuiPopover } from '@elastic/eui'; export const BulkOperationPopover: React.FunctionComponent = ({ children }) => { const [isPopoverOpen, setIsPopoverOpen] = useState(false); @@ -16,6 +16,7 @@ export const BulkOperationPopover: React.FunctionComponent = ({ children }) => { isOpen={isPopoverOpen} closePopover={() => setIsPopoverOpen(false)} data-test-subj="bulkAction" + panelPaddingSize="s" button={ { > {children && React.Children.map(children, child => - React.isValidElement(child) ? ( - {React.cloneElement(child, {})} - ) : ( - child - ) + React.isValidElement(child) ? {React.cloneElement(child, {})} : child )} ); diff --git a/x-pack/plugins/uptime/server/graphql/constants.ts b/x-pack/plugins/uptime/server/graphql/constants.ts deleted file mode 100644 index aba58f5c6c4a5..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/constants.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export const DEFAULT_GRAPHQL_PATH = '/api/uptime/graphql'; diff --git a/x-pack/plugins/uptime/server/graphql/index.ts b/x-pack/plugins/uptime/server/graphql/index.ts deleted file mode 100644 index a88afd7ac769c..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { createMonitorStatesResolvers, monitorStatesSchema } from './monitor_states'; -import { pingsSchema } from './pings'; -import { CreateUMGraphQLResolvers } from './types'; -import { unsignedIntegerResolverFunctions, unsignedIntegerSchema } from './unsigned_int_scalar'; - -export { DEFAULT_GRAPHQL_PATH } from './constants'; -export const resolvers: CreateUMGraphQLResolvers[] = [ - createMonitorStatesResolvers, - unsignedIntegerResolverFunctions, -]; -export const typeDefs: any[] = [pingsSchema, unsignedIntegerSchema, monitorStatesSchema]; diff --git a/x-pack/plugins/uptime/server/graphql/monitor_states/index.ts b/x-pack/plugins/uptime/server/graphql/monitor_states/index.ts deleted file mode 100644 index fb0893dbc4dbf..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/monitor_states/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { createMonitorStatesResolvers } from './resolvers'; -export { monitorStatesSchema } from './schema.gql'; diff --git a/x-pack/plugins/uptime/server/graphql/monitor_states/resolvers.ts b/x-pack/plugins/uptime/server/graphql/monitor_states/resolvers.ts deleted file mode 100644 index 479c06234ca66..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/monitor_states/resolvers.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { CreateUMGraphQLResolvers, UMContext } from '../types'; -import { UMServerLibs } from '../../lib/lib'; -import { UMResolver } from '../../../../../legacy/plugins/uptime/common/graphql/resolver_types'; -import { - GetMonitorStatesQueryArgs, - MonitorSummaryResult, -} from '../../../../../legacy/plugins/uptime/common/graphql/types'; -import { CONTEXT_DEFAULTS } from '../../../../../legacy/plugins/uptime/common/constants'; -import { savedObjectsAdapter } from '../../lib/saved_objects'; - -export type UMGetMonitorStatesResolver = UMResolver< - MonitorSummaryResult | Promise, - any, - GetMonitorStatesQueryArgs, - UMContext ->; - -export const createMonitorStatesResolvers: CreateUMGraphQLResolvers = ( - libs: UMServerLibs -): { - Query: { - getMonitorStates: UMGetMonitorStatesResolver; - }; -} => { - return { - Query: { - async getMonitorStates( - _resolver, - { dateRangeStart, dateRangeEnd, filters, pagination, statusFilter, pageSize }, - { APICaller, savedObjectsClient } - ): Promise { - const dynamicSettings = await savedObjectsAdapter.getUptimeDynamicSettings( - savedObjectsClient - ); - - const decodedPagination = pagination - ? JSON.parse(decodeURIComponent(pagination)) - : CONTEXT_DEFAULTS.CURSOR_PAGINATION; - const [ - indexStatus, - { summaries, nextPagePagination, prevPagePagination }, - ] = await Promise.all([ - libs.requests.getIndexStatus({ callES: APICaller, dynamicSettings }), - libs.requests.getMonitorStates({ - callES: APICaller, - dynamicSettings, - dateRangeStart, - dateRangeEnd, - pagination: decodedPagination, - pageSize, - filters, - // this is added to make typescript happy, - // this sort of reassignment used to be further downstream but I've moved it here - // because this code is going to be decomissioned soon - statusFilter: statusFilter || undefined, - }), - ]); - - const totalSummaryCount = indexStatus?.docCount ?? 0; - - return { - summaries, - nextPagePagination, - prevPagePagination, - totalSummaryCount, - }; - }, - }, - }; -}; diff --git a/x-pack/plugins/uptime/server/graphql/monitor_states/schema.gql.ts b/x-pack/plugins/uptime/server/graphql/monitor_states/schema.gql.ts deleted file mode 100644 index 040ad99ac0c64..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/monitor_states/schema.gql.ts +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import gql from 'graphql-tag'; - -export const monitorStatesSchema = gql` - "Represents a monitor's statuses for a period of time." - type SummaryHistogramPoint { - "The time at which these data were collected." - timestamp: UnsignedInteger! - "The number of _up_ documents." - up: Int! - "The number of _down_ documents." - down: Int! - } - - "Monitor status data over time." - type SummaryHistogram { - "The number of documents used to assemble the histogram." - count: Int! - "The individual histogram data points." - points: [SummaryHistogramPoint!]! - } - - type Agent { - id: String! - } - - type Check { - agent: Agent - container: StateContainer - kubernetes: StateKubernetes - monitor: CheckMonitor! - observer: CheckObserver - timestamp: String! - } - - type StateContainer { - id: String - } - - type StateKubernetes { - pod: StatePod - } - - type StatePod { - uid: String - } - - type CheckMonitor { - ip: String - name: String - status: String! - } - - type Location { - lat: Float - lon: Float - } - - type CheckGeo { - name: String - location: Location - } - - type CheckObserver { - geo: CheckGeo - } - - type StateGeo { - name: [String] - location: Location - } - - type StateObserver { - geo: StateGeo - } - - type MonitorState { - status: String - name: String - id: String - type: String - } - - type Summary { - up: Int - down: Int - geo: CheckGeo - } - - type MonitorSummaryUrl { - domain: String - fragment: String - full: String - original: String - password: String - path: String - port: Int - query: String - scheme: String - username: String - } - - type StateUrl { - domain: String - full: String - path: String - port: Int - scheme: String - } - - "Contains monitor transmission encryption information." - type StateTLS { - "The date and time after which the certificate is invalid." - certificate_not_valid_after: String - certificate_not_valid_before: String - certificates: String - rtt: RTT - } - - "Unifies the subsequent data for an uptime monitor." - type State { - "The agent processing the monitor." - agent: Agent - "There is a check object for each instance of the monitoring agent." - checks: [Check!] - geo: StateGeo - observer: StateObserver - monitor: MonitorState - summary: Summary! - timestamp: UnsignedInteger! - "Transport encryption information." - tls: [StateTLS] - url: StateUrl - } - - "Represents the current state and associated data for an Uptime monitor." - type MonitorSummary { - "The ID assigned by the config or generated by the user." - monitor_id: String! - "The state of the monitor and its associated details." - state: State! - histogram: SummaryHistogram - } - - "The primary object returned for monitor states." - type MonitorSummaryResult { - "Used to go to the next page of results" - prevPagePagination: String - "Used to go to the previous page of results" - nextPagePagination: String - "The objects representing the state of a series of heartbeat monitors." - summaries: [MonitorSummary!] - "The number of summaries." - totalSummaryCount: Int! - } - - enum CursorDirection { - AFTER - BEFORE - } - - enum SortOrder { - ASC - DESC - } - - type Query { - "Fetches the current state of Uptime monitors for the given parameters." - getMonitorStates( - dateRangeStart: String! - dateRangeEnd: String! - pagination: String - filters: String - statusFilter: String - pageSize: Int - ): MonitorSummaryResult - } -`; diff --git a/x-pack/plugins/uptime/server/graphql/pings/index.ts b/x-pack/plugins/uptime/server/graphql/pings/index.ts deleted file mode 100644 index 100ce29c398ec..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/pings/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { pingsSchema } from './schema.gql'; diff --git a/x-pack/plugins/uptime/server/graphql/pings/schema.gql.ts b/x-pack/plugins/uptime/server/graphql/pings/schema.gql.ts deleted file mode 100644 index 179bca53db161..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/pings/schema.gql.ts +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import gql from 'graphql-tag'; - -export const pingsSchema = gql` - type PingResults { - "Total number of matching pings" - total: UnsignedInteger! - "Unique list of all locations the query matched" - locations: [String!]! - "List of pings " - pings: [Ping!]! - } - - type ContainerImage { - name: String - tag: String - } - - type Container { - id: String - image: ContainerImage - name: String - runtime: String - } - - type DocCount { - count: UnsignedInteger! - } - - "The monitor's status for a ping" - type Duration { - us: UnsignedInteger - } - - "An agent for recording a beat" - type Beat { - hostname: String - name: String - timezone: String - type: String - } - - type Docker { - id: String - image: String - name: String - } - - type ECS { - version: String - } - - type Error { - code: Int - message: String - type: String - } - - type OS { - family: String - kernel: String - platform: String - version: String - name: String - build: String - } - - "Geolocation data added via processors to enrich events." - type Geo { - "Name of the city in which the agent is running." - city_name: String - "The name of the continent on which the agent is running." - continent_name: String - "ISO designation for the agent's country." - country_iso_code: String - "The name of the agent's country." - country_name: String - "The lat/long of the agent." - location: String - "A name for the host's location, e.g. 'us-east-1' or 'LAX'." - name: String - "ISO designation of the agent's region." - region_iso_code: String - "Name of the region hosting the agent." - region_name: String - } - - type Host { - architecture: String - id: String - hostname: String - ip: String - mac: String - name: String - os: OS - } - - type HttpRTT { - content: Duration - response_header: Duration - total: Duration - validate: Duration - validate_body: Duration - write_request: Duration - } - - type HTTPBody { - "Size of HTTP response body in bytes" - bytes: UnsignedInteger - "Hash of the HTTP response body" - hash: String - "Response body of the HTTP Response. May be truncated based on client settings." - content: String - "Byte length of the content string, taking into account multibyte chars." - content_bytes: UnsignedInteger - } - - type HTTPResponse { - status_code: UnsignedInteger - body: HTTPBody - } - - type HTTP { - response: HTTPResponse - rtt: HttpRTT - url: String - } - - type ICMP { - requests: Int - rtt: Int - } - - type KubernetesContainer { - image: String - name: String - } - - type KubernetesNode { - name: String - } - - type KubernetesPod { - name: String - uid: String - } - - type Kubernetes { - container: KubernetesContainer - namespace: String - node: KubernetesNode - pod: KubernetesPod - } - - type MetaCloud { - availability_zone: String - instance_id: String - instance_name: String - machine_type: String - project_id: String - provider: String - region: String - } - - type Meta { - cloud: MetaCloud - } - - type Monitor { - duration: Duration - host: String - "The id of the monitor" - id: String - "The IP pinged by the monitor" - ip: String - "The name of the protocol being monitored" - name: String - "The protocol scheme of the monitored host" - scheme: String - "The status of the monitored host" - status: String - "The type of host being monitored" - type: String - check_group: String - } - - "Metadata added by a proccessor, which is specified in its configuration." - type Observer { - "Geolocation data for the agent." - geo: Geo - } - - type Resolve { - host: String - ip: String - rtt: Duration - } - - type RTT { - connect: Duration - handshake: Duration - validate: Duration - } - - type Socks5 { - rtt: RTT - } - - type TCP { - port: Int - rtt: RTT - } - - "Contains monitor transmission encryption information." - type PingTLS { - "The date and time after which the certificate is invalid." - certificate_not_valid_after: String - certificate_not_valid_before: String - certificates: String - rtt: RTT - } - - type URL { - full: String - scheme: String - domain: String - port: Int - path: String - query: String - } - - "A request sent from a monitor to a host" - type Ping { - "unique ID for this ping" - id: String! - "The timestamp of the ping's creation" - timestamp: String! - "The agent that recorded the ping" - beat: Beat - container: Container - docker: Docker - ecs: ECS - error: Error - host: Host - http: HTTP - icmp: ICMP - kubernetes: Kubernetes - meta: Meta - monitor: Monitor - observer: Observer - resolve: Resolve - socks5: Socks5 - summary: Summary - tags: String - tcp: TCP - tls: PingTLS - url: URL - } -`; diff --git a/x-pack/plugins/uptime/server/graphql/types.ts b/x-pack/plugins/uptime/server/graphql/types.ts deleted file mode 100644 index 5f0a6749eb599..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { RequestHandlerContext, CallAPIOptions, SavedObjectsClient } from 'src/core/server'; -import { UMServerLibs } from '../lib/lib'; - -export type UMContext = RequestHandlerContext & { - APICaller: ( - endpoint: string, - clientParams?: Record, - options?: CallAPIOptions | undefined - ) => Promise; - savedObjectsClient: SavedObjectsClient; -}; - -export interface UMGraphQLResolver { - Query?: any; -} - -export type CreateUMGraphQLResolvers = (libs: UMServerLibs) => any; diff --git a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/__tests__/parse_literal.test.ts b/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/__tests__/parse_literal.test.ts deleted file mode 100644 index 7c357abcf8e1d..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/__tests__/parse_literal.test.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; - * you may not use this file except in compliance with the Elastic License. - */ - -import { parseLiteral } from '../resolvers'; - -describe('parseLiteral', () => { - it('parses string literal of type IntValue', () => { - const result = parseLiteral({ - kind: 'IntValue', - value: '1562605032000', - }); - expect(result).toBe(1562605032000); - }); - - it('parses string literal of type FloatValue', () => { - const result = parseLiteral({ - kind: 'FloatValue', - value: '1562605032000.0', - }); - expect(result).toBe(1562605032000); - }); - - it('parses string literal of type String', () => { - const result = parseLiteral({ - kind: 'StringValue', - value: '1562605032000', - }); - expect(result).toBe(1562605032000); - }); - - it('returns `null` for unsupported types', () => { - expect( - parseLiteral({ - kind: 'EnumValue', - value: 'false', - }) - ).toBeNull(); - }); -}); diff --git a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/__tests__/parse_value.test.ts b/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/__tests__/parse_value.test.ts deleted file mode 100644 index cb8958918c6dc..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/__tests__/parse_value.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { parseValue } from '../resolvers'; - -describe('parseValue', () => { - it(`parses a number value and returns it if its > 0`, () => { - const result = parseValue('1562605032000'); - expect(result).toBe(1562605032000); - }); - - it(`parses a number and returns null if its value is < 0`, () => { - const result = parseValue('-1562605032000'); - expect(result).toBeNull(); - }); -}); diff --git a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/__tests__/serialize.test.ts b/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/__tests__/serialize.test.ts deleted file mode 100644 index 2271d12ee7e13..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/__tests__/serialize.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { serialize } from '../resolvers'; - -describe('serialize', () => { - it('serializes date strings correctly', () => { - const result = serialize('2019-07-08T16:59:09.796Z'); - expect(result).toBe(1562605149796); - }); - - it('serializes timestamp strings correctly', () => { - const result = serialize('1562605032000'); - expect(result).toBe(1562605032000); - }); - - it('serializes non-date and non-numeric values to NaN', () => { - const result = serialize('foo'); - expect(result).toBeNaN(); - }); -}); diff --git a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/index.ts b/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/index.ts deleted file mode 100644 index a8819f543a851..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { unsignedIntegerResolverFunctions } from './resolvers'; -export { unsignedIntegerSchema } from './schema.gql'; diff --git a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/resolvers.ts b/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/resolvers.ts deleted file mode 100644 index 9b8fe145e7ff5..0000000000000 --- a/x-pack/plugins/uptime/server/graphql/unsigned_int_scalar/resolvers.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { GraphQLScalarType, Kind, ValueNode } from 'graphql'; -import { UMServerLibs } from '../../lib/lib'; -import { CreateUMGraphQLResolvers } from '../types'; - -export const serialize = (value: any): number => { - // `parseInt` will yield `2019` for a value such as "2019-07-08T16:59:09.796Z" - if (isNaN(Number(value))) { - return Date.parse(value); - } - return parseInt(value, 10); -}; - -export const parseValue = (value: any) => { - const parsed = parseInt(value, 10); - if (parsed < 0) { - return null; - } - return parsed; -}; - -export const parseLiteral = (ast: ValueNode) => { - switch (ast.kind) { - case Kind.INT: - case Kind.FLOAT: - case Kind.STRING: - return parseInt(ast.value, 10); - } - return null; -}; - -const unsignedIntegerScalar = new GraphQLScalarType({ - name: 'UnsignedInteger', - description: 'Represents an unsigned 32-bit integer', - serialize, - parseValue, - parseLiteral, -}); - -/** - * This scalar resolver will parse an integer string of > 32 bits and return a value of type `number`. - * This assumes that the code is running in an environment that supports big ints. - */ -export const unsignedIntegerResolverFunctions: CreateUMGraphQLResolvers = (libs: UMServerLibs) => ({ - UnsignedInteger: unsignedIntegerScalar, -}); diff --git a/x-pack/plugins/uptime/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/uptime/server/lib/adapters/framework/adapter_types.ts index 47fe5f2af4263..98c6be5aa3c8e 100644 --- a/x-pack/plugins/uptime/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/uptime/server/lib/adapters/framework/adapter_types.ts @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { GraphQLSchema } from 'graphql'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; import { IRouter, @@ -44,5 +43,4 @@ export interface UptimeCorePlugins { export interface UMBackendFrameworkAdapter { registerRoute(route: UMKibanaRoute): void; - registerGraphQLEndpoint(routePath: string, schema: GraphQLSchema): void; } diff --git a/x-pack/plugins/uptime/server/lib/adapters/framework/kibana_framework_adapter.ts b/x-pack/plugins/uptime/server/lib/adapters/framework/kibana_framework_adapter.ts index 1f92c8212b393..0176471aec1be 100644 --- a/x-pack/plugins/uptime/server/lib/adapters/framework/kibana_framework_adapter.ts +++ b/x-pack/plugins/uptime/server/lib/adapters/framework/kibana_framework_adapter.ts @@ -4,9 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { GraphQLSchema } from 'graphql'; -import { schema as kbnSchema } from '@kbn/config-schema'; -import { runHttpQuery } from 'apollo-server-core'; import { UptimeCoreSetup } from './adapter_types'; import { UMBackendFrameworkAdapter } from './adapter_types'; import { UMKibanaRoute } from '../../../rest_api'; @@ -33,71 +30,4 @@ export class UMKibanaBackendFrameworkAdapter implements UMBackendFrameworkAdapte throw new Error(`Handler for method ${method} is not defined`); } } - - public registerGraphQLEndpoint(routePath: string, schema: GraphQLSchema): void { - this.server.route.post( - { - path: routePath, - validate: { - body: kbnSchema.object({ - operationName: kbnSchema.nullable(kbnSchema.string()), - query: kbnSchema.string(), - variables: kbnSchema.recordOf(kbnSchema.string(), kbnSchema.any()), - }), - }, - options: { - tags: ['access:uptime-read'], - }, - }, - async (context, request, resp): Promise => { - const { - core: { - elasticsearch: { - dataClient: { callAsCurrentUser }, - }, - }, - } = context; - const options = { - graphQLOptions: (_req: any) => { - return { - context: { - ...context, - APICaller: callAsCurrentUser, - savedObjectsClient: context.core.savedObjects.client, - }, - schema, - }; - }, - path: routePath, - route: { - tags: ['access:uptime-read'], - }, - }; - try { - const query = request.body as Record; - - const graphQLResponse = await runHttpQuery([request], { - method: 'POST', - options: options.graphQLOptions, - query, - }); - - return resp.ok({ - body: graphQLResponse, - headers: { - 'content-type': 'application/json', - }, - }); - } catch (error) { - if (error.isGraphQLError === true) { - return resp.internalError({ - body: { message: error.message }, - headers: { 'content-type': 'application/json' }, - }); - } - return resp.internalError(); - } - } - ); - } } diff --git a/x-pack/plugins/uptime/server/lib/alerts/__tests__/status_check.test.ts b/x-pack/plugins/uptime/server/lib/alerts/__tests__/status_check.test.ts index 2eb17d588d297..2cc6f23ebaae5 100644 --- a/x-pack/plugins/uptime/server/lib/alerts/__tests__/status_check.test.ts +++ b/x-pack/plugins/uptime/server/lib/alerts/__tests__/status_check.test.ts @@ -88,6 +88,10 @@ describe('status check alert', () => { Object { "callES": [MockFunction], "dynamicSettings": Object { + "certificatesThresholds": Object { + "errorState": 7, + "warningState": 30, + }, "heartbeatIndices": "heartbeat-8*", }, "locations": Array [], @@ -131,6 +135,10 @@ describe('status check alert', () => { Object { "callES": [MockFunction], "dynamicSettings": Object { + "certificatesThresholds": Object { + "errorState": 7, + "warningState": 30, + }, "heartbeatIndices": "heartbeat-8*", }, "locations": Array [], diff --git a/x-pack/plugins/uptime/server/lib/requests/__tests__/get_certs.test.ts b/x-pack/plugins/uptime/server/lib/requests/__tests__/get_certs.test.ts new file mode 100644 index 0000000000000..539344dfca791 --- /dev/null +++ b/x-pack/plugins/uptime/server/lib/requests/__tests__/get_certs.test.ts @@ -0,0 +1,208 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { getCerts } from '../get_certs'; + +describe('getCerts', () => { + let mockHits: any; + let mockCallES: jest.Mock; + + beforeEach(() => { + mockHits = [ + { + _index: 'heartbeat-8.0.0-2020.04.16-000001', + _id: 'DJwmhHEBnyP8RKDrEYVK', + _score: 0, + _source: { + tls: { + certificate_not_valid_before: '2019-08-16T01:40:25.000Z', + server: { + x509: { + subject: { + common_name: 'r2.shared.global.fastly.net', + }, + issuer: { + common_name: 'GlobalSign CloudSSL CA - SHA256 - G3', + }, + }, + hash: { + sha1: 'b7b4b89ef0d0caf39d223736f0fdbb03c7b426f1', + sha256: '12b00d04db0db8caa302bfde043e88f95baceb91e86ac143e93830b4bbec726d', + }, + }, + certificate_not_valid_after: '2020-07-16T03:15:39.000Z', + }, + monitor: { + name: 'Real World Test', + id: 'real-world-test', + }, + }, + fields: { + 'tls.server.hash.sha256': [ + '12b00d04db0db8caa302bfde043e88f95baceb91e86ac143e93830b4bbec726d', + ], + }, + inner_hits: { + monitors: { + hits: { + total: { + value: 32, + relation: 'eq', + }, + max_score: null, + hits: [ + { + _index: 'heartbeat-8.0.0-2020.04.16-000001', + _id: 'DJwmhHEBnyP8RKDrEYVK', + _score: null, + _source: { + monitor: { + name: 'Real World Test', + id: 'real-world-test', + }, + }, + fields: { + 'monitor.id': ['real-world-test'], + }, + sort: ['real-world-test'], + }, + ], + }, + }, + }, + }, + ]; + mockCallES = jest.fn(); + mockCallES.mockImplementation(() => ({ + hits: { + hits: mockHits, + }, + })); + }); + + it('parses query result and returns expected values', async () => { + const result = await getCerts({ + callES: mockCallES, + dynamicSettings: { heartbeatIndices: 'heartbeat*' }, + index: 1, + from: 'now-2d', + to: 'now+1h', + search: 'my_common_name', + size: 30, + }); + expect(result).toMatchInlineSnapshot(` + Array [ + Object { + "certificate_not_valid_after": "2020-07-16T03:15:39.000Z", + "certificate_not_valid_before": "2019-08-16T01:40:25.000Z", + "common_name": "r2.shared.global.fastly.net", + "issuer": "GlobalSign CloudSSL CA - SHA256 - G3", + "monitors": Array [ + Object { + "id": "real-world-test", + "name": "Real World Test", + }, + ], + "sha1": "b7b4b89ef0d0caf39d223736f0fdbb03c7b426f1", + "sha256": "12b00d04db0db8caa302bfde043e88f95baceb91e86ac143e93830b4bbec726d", + }, + ] + `); + expect(mockCallES.mock.calls).toMatchInlineSnapshot(` + Array [ + Array [ + "search", + Object { + "body": Object { + "_source": Array [ + "monitor.id", + "monitor.name", + "tls.server.x509.issuer.common_name", + "tls.server.x509.subject.common_name", + "tls.server.hash.sha1", + "tls.server.hash.sha256", + "tls.certificate_not_valid_before", + "tls.certificate_not_valid_after", + ], + "collapse": Object { + "field": "tls.server.hash.sha256", + "inner_hits": Object { + "_source": Object { + "includes": Array [ + "monitor.id", + "monitor.name", + ], + }, + "collapse": Object { + "field": "monitor.id", + }, + "name": "monitors", + "sort": Array [ + Object { + "monitor.id": "asc", + }, + ], + }, + }, + "from": 1, + "query": Object { + "bool": Object { + "filter": Array [ + Object { + "exists": Object { + "field": "tls", + }, + }, + Object { + "range": Object { + "@timestamp": Object { + "gte": "now-2d", + "lte": "now+1h", + }, + }, + }, + ], + "should": Array [ + Object { + "wildcard": Object { + "tls.server.issuer": Object { + "value": "*my_common_name*", + }, + }, + }, + Object { + "wildcard": Object { + "tls.common_name": Object { + "value": "*my_common_name*", + }, + }, + }, + Object { + "wildcard": Object { + "monitor.id": Object { + "value": "*my_common_name*", + }, + }, + }, + Object { + "wildcard": Object { + "monitor.name": Object { + "value": "*my_common_name*", + }, + }, + }, + ], + }, + }, + "size": 30, + }, + "index": "heartbeat*", + }, + ], + ] + `); + }); +}); diff --git a/x-pack/plugins/uptime/server/lib/requests/get_certs.ts b/x-pack/plugins/uptime/server/lib/requests/get_certs.ts new file mode 100644 index 0000000000000..4f99fbe94d54c --- /dev/null +++ b/x-pack/plugins/uptime/server/lib/requests/get_certs.ts @@ -0,0 +1,135 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { UMElasticsearchQueryFn } from '../adapters'; +import { Cert, GetCertsParams } from '../../../../../legacy/plugins/uptime/common/runtime_types'; + +export const getCerts: UMElasticsearchQueryFn = async ({ + callES, + dynamicSettings, + index, + from, + to, + search, + size, +}) => { + const searchWrapper = `*${search}*`; + const params: any = { + index: dynamicSettings.heartbeatIndices, + body: { + from: index, + size, + query: { + bool: { + filter: [ + { + exists: { + field: 'tls', + }, + }, + { + range: { + '@timestamp': { + gte: from, + lte: to, + }, + }, + }, + ], + }, + }, + _source: [ + 'monitor.id', + 'monitor.name', + 'tls.server.x509.issuer.common_name', + 'tls.server.x509.subject.common_name', + 'tls.server.hash.sha1', + 'tls.server.hash.sha256', + 'tls.certificate_not_valid_before', + 'tls.certificate_not_valid_after', + ], + collapse: { + field: 'tls.server.hash.sha256', + inner_hits: { + _source: { + includes: ['monitor.id', 'monitor.name'], + }, + collapse: { + field: 'monitor.id', + }, + name: 'monitors', + sort: [{ 'monitor.id': 'asc' }], + }, + }, + }, + }; + + if (search) { + params.body.query.bool.should = [ + { + wildcard: { + 'tls.server.issuer': { + value: searchWrapper, + }, + }, + }, + { + wildcard: { + 'tls.common_name': { + value: searchWrapper, + }, + }, + }, + { + wildcard: { + 'monitor.id': { + value: searchWrapper, + }, + }, + }, + { + wildcard: { + 'monitor.name': { + value: searchWrapper, + }, + }, + }, + ]; + } + + const result = await callES('search', params); + const formatted = (result?.hits?.hits ?? []).map((hit: any) => { + const { + _source: { + tls: { + server: { + x509: { + issuer: { common_name: issuer }, + subject: { common_name }, + }, + hash: { sha1, sha256 }, + }, + certificate_not_valid_after, + certificate_not_valid_before, + }, + }, + } = hit; + const monitors = hit.inner_hits.monitors.hits.hits.map((monitor: any) => ({ + name: monitor._source?.monitor.name, + id: monitor._source?.monitor.id, + })); + return { + monitors, + certificate_not_valid_after, + certificate_not_valid_before, + issuer, + sha1, + sha256, + common_name, + }; + }); + return formatted; +}; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_monitor_details.ts b/x-pack/plugins/uptime/server/lib/requests/get_monitor_details.ts index 8393370e1516b..4ce7176b57b19 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_monitor_details.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_monitor_details.ts @@ -68,11 +68,11 @@ export const getMonitorDetails: UMElasticsearchQueryFn< const data = result.hits.hits[0]?._source; const monitorError: MonitorError | undefined = data?.error; - const errorTimeStamp: string | undefined = data?.['@timestamp']; + const errorTimestamp: string | undefined = data?.['@timestamp']; return { monitorId, error: monitorError, - timestamp: errorTimeStamp, + timestamp: errorTimestamp, }; }; diff --git a/x-pack/plugins/uptime/server/lib/requests/get_monitor_states.ts b/x-pack/plugins/uptime/server/lib/requests/get_monitor_states.ts index d7842d1a0b4aa..4b40943a85705 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_monitor_states.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_monitor_states.ts @@ -8,10 +8,11 @@ import { CONTEXT_DEFAULTS } from '../../../../../legacy/plugins/uptime/common/co import { fetchPage } from './search'; import { UMElasticsearchQueryFn } from '../adapters'; import { - MonitorSummary, SortOrder, CursorDirection, -} from '../../../../../legacy/plugins/uptime/common/graphql/types'; + MonitorSummary, +} from '../../../../../legacy/plugins/uptime/common/runtime_types'; + import { QueryContext } from './search'; export interface CursorPagination { diff --git a/x-pack/plugins/uptime/server/lib/requests/index.ts b/x-pack/plugins/uptime/server/lib/requests/index.ts index 6317f665d377f..243bb089cc7b4 100644 --- a/x-pack/plugins/uptime/server/lib/requests/index.ts +++ b/x-pack/plugins/uptime/server/lib/requests/index.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +export { getCerts } from './get_certs'; export { getFilterBar, GetFilterBarParams } from './get_filter_bar'; export { getUptimeIndexPattern as getIndexPattern } from './get_index_pattern'; export { getLatestMonitor, GetLatestMonitorParams } from './get_latest_monitor'; diff --git a/x-pack/plugins/uptime/server/lib/requests/search/__tests__/fetch_page.test.ts b/x-pack/plugins/uptime/server/lib/requests/search/__tests__/fetch_page.test.ts index f542773f32796..2a8f681ab3453 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/__tests__/fetch_page.test.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/__tests__/fetch_page.test.ts @@ -12,7 +12,7 @@ import { MonitorGroupsPage, } from '../fetch_page'; import { QueryContext } from '../query_context'; -import { MonitorSummary } from '../../../../../../../legacy/plugins/uptime/common/graphql/types'; +import { MonitorSummary } from '../../../../../../../legacy/plugins/uptime/common/runtime_types'; import { nextPagination, prevPagination, simpleQueryContext } from './test_helpers'; const simpleFixture: MonitorGroups[] = [ @@ -53,12 +53,16 @@ const simpleFetcher = (monitorGroups: MonitorGroups[]): MonitorGroupsFetcher => }; const simpleEnricher = (monitorGroups: MonitorGroups[]): MonitorEnricher => { - return async (queryContext: QueryContext, checkGroups: string[]): Promise => { + return async (_queryContext: QueryContext, checkGroups: string[]): Promise => { return checkGroups.map(cg => { const monitorGroup = monitorGroups.find(mg => mg.groups.some(g => g.checkGroup === cg))!; return { monitor_id: monitorGroup.id, - state: { summary: {}, timestamp: new Date(Date.parse('1999-12-31')).toISOString() }, + state: { + summary: {}, + timestamp: new Date(Date.parse('1999-12-31')).valueOf().toString(), + url: {}, + }, }; }); }; @@ -71,16 +75,37 @@ describe('fetching a page', () => { simpleFetcher(simpleFixture), simpleEnricher(simpleFixture) ); - expect(res).toEqual({ - items: [ - { - monitor_id: 'foo', - state: { summary: {}, timestamp: '1999-12-31T00:00:00.000Z' }, + expect(res).toMatchInlineSnapshot(` + Object { + "items": Array [ + Object { + "monitor_id": "foo", + "state": Object { + "summary": Object {}, + "timestamp": "946598400000", + "url": Object {}, + }, + }, + Object { + "monitor_id": "bar", + "state": Object { + "summary": Object {}, + "timestamp": "946598400000", + "url": Object {}, + }, + }, + ], + "nextPagePagination": Object { + "cursorDirection": "AFTER", + "cursorKey": "bar", + "sortOrder": "ASC", }, - { monitor_id: 'bar', state: { summary: {}, timestamp: '1999-12-31T00:00:00.000Z' } }, - ], - nextPagePagination: { cursorDirection: 'AFTER', sortOrder: 'ASC', cursorKey: 'bar' }, - prevPagePagination: { cursorDirection: 'BEFORE', sortOrder: 'ASC', cursorKey: 'foo' }, - }); + "prevPagePagination": Object { + "cursorDirection": "BEFORE", + "cursorKey": "foo", + "sortOrder": "ASC", + }, + } + `); }); }); diff --git a/x-pack/plugins/uptime/server/lib/requests/search/__tests__/query_context.test.ts b/x-pack/plugins/uptime/server/lib/requests/search/__tests__/query_context.test.ts index a6c98541fba1d..84774cdeed856 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/__tests__/query_context.test.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/__tests__/query_context.test.ts @@ -9,7 +9,7 @@ import { CursorPagination } from '../types'; import { CursorDirection, SortOrder, -} from '../../../../../../../legacy/plugins/uptime/common/graphql/types'; +} from '../../../../../../../legacy/plugins/uptime/common/runtime_types'; describe(QueryContext, () => { // 10 minute range diff --git a/x-pack/plugins/uptime/server/lib/requests/search/__tests__/test_helpers.ts b/x-pack/plugins/uptime/server/lib/requests/search/__tests__/test_helpers.ts index d1212daf5304f..47034c2130116 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/__tests__/test_helpers.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/__tests__/test_helpers.ts @@ -8,7 +8,7 @@ import { CursorPagination } from '../types'; import { CursorDirection, SortOrder, -} from '../../../../../../../legacy/plugins/uptime/common/graphql/types'; +} from '../../../../../../../legacy/plugins/uptime/common/runtime_types'; import { QueryContext } from '../query_context'; export const prevPagination = (key: any): CursorPagination => { diff --git a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts index 1798550875276..4739c804d24e7 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts @@ -8,12 +8,12 @@ import { get, sortBy } from 'lodash'; import { QueryContext } from './query_context'; import { QUERY, STATES } from '../../../../../../legacy/plugins/uptime/common/constants'; import { - MonitorSummary, - SummaryHistogram, Check, + Histogram, + MonitorSummary, CursorDirection, SortOrder, -} from '../../../../../../legacy/plugins/uptime/common/graphql/types'; +} from '../../../../../../legacy/plugins/uptime/common/runtime_types'; import { MonitorEnricher } from './fetch_page'; export const enrichMonitorGroups: MonitorEnricher = async ( @@ -250,11 +250,8 @@ export const enrichMonitorGroups: MonitorEnricher = async ( const summaries: MonitorSummary[] = monitorBuckets.map((monitor: any) => { const monitorId = get(monitor, 'key.monitor_id'); monitorIds.push(monitorId); - let state = get(monitor, 'state.value'); - state = { - ...state, - timestamp: state['@timestamp'], - }; + const state: any = monitor.state?.value; + state.timestamp = state['@timestamp']; const { checks } = state; if (checks) { state.checks = sortBy(checks, checksSortBy); @@ -289,7 +286,7 @@ export const enrichMonitorGroups: MonitorEnricher = async ( const getHistogramForMonitors = async ( queryContext: QueryContext, monitorIds: string[] -): Promise<{ [key: string]: SummaryHistogram }> => { +): Promise<{ [key: string]: Histogram }> => { const params = { index: queryContext.heartbeatIndices, body: { diff --git a/x-pack/plugins/uptime/server/lib/requests/search/fetch_page.ts b/x-pack/plugins/uptime/server/lib/requests/search/fetch_page.ts index 62144dacbd377..84167840d5d9b 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/fetch_page.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/fetch_page.ts @@ -12,7 +12,7 @@ import { CursorDirection, MonitorSummary, SortOrder, -} from '../../../../../../legacy/plugins/uptime/common/graphql/types'; +} from '../../../../../../legacy/plugins/uptime/common/runtime_types'; import { enrichMonitorGroups } from './enrich_monitor_groups'; import { MonitorGroupIterator } from './monitor_group_iterator'; diff --git a/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts b/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts index 424c097853ad3..3449febfa5b05 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/find_potential_matches.ts @@ -5,7 +5,7 @@ */ import { get, set } from 'lodash'; -import { CursorDirection } from '../../../../../../legacy/plugins/uptime/common/graphql/types'; +import { CursorDirection } from '../../../../../../legacy/plugins/uptime/common/runtime_types'; import { QueryContext } from './query_context'; // This is the first phase of the query. In it, we find the most recent check groups that matched the given query. diff --git a/x-pack/plugins/uptime/server/lib/requests/search/monitor_group_iterator.ts b/x-pack/plugins/uptime/server/lib/requests/search/monitor_group_iterator.ts index 267551907c5e8..31d9166eb1e73 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/monitor_group_iterator.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/monitor_group_iterator.ts @@ -6,7 +6,7 @@ import { QueryContext } from './query_context'; import { fetchChunk } from './fetch_chunk'; -import { CursorDirection } from '../../../../../../legacy/plugins/uptime/common/graphql/types'; +import { CursorDirection } from '../../../../../../legacy/plugins/uptime/common/runtime_types'; import { MonitorGroups } from './fetch_page'; import { CursorPagination } from './types'; diff --git a/x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts b/x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts index 218eb2f121a81..43fc54fb25808 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/refine_potential_matches.ts @@ -5,7 +5,7 @@ */ import { QueryContext } from './query_context'; -import { CursorDirection } from '../../../../../../legacy/plugins/uptime/common/graphql/types'; +import { CursorDirection } from '../../../../../../legacy/plugins/uptime/common/runtime_types'; import { MonitorGroups, MonitorLocCheckGroup } from './fetch_page'; /** diff --git a/x-pack/plugins/uptime/server/lib/requests/search/types.ts b/x-pack/plugins/uptime/server/lib/requests/search/types.ts index 42c98ace6e8f5..2ec52d400b597 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/types.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/types.ts @@ -7,7 +7,7 @@ import { CursorDirection, SortOrder, -} from '../../../../../../legacy/plugins/uptime/common/graphql/types'; +} from '../../../../../../legacy/plugins/uptime/common/runtime_types'; export interface CursorPagination { cursorKey?: any; diff --git a/x-pack/plugins/uptime/server/lib/requests/uptime_requests.ts b/x-pack/plugins/uptime/server/lib/requests/uptime_requests.ts index e9a7aa94dd3aa..84154429b9188 100644 --- a/x-pack/plugins/uptime/server/lib/requests/uptime_requests.ts +++ b/x-pack/plugins/uptime/server/lib/requests/uptime_requests.ts @@ -9,6 +9,7 @@ import { HistogramResult, Ping, PingsResponse as PingResults, + GetCertsParams, GetPingsParams, } from '../../../../../legacy/plugins/uptime/common/runtime_types'; import { @@ -28,6 +29,7 @@ import { MonitorLocations, Snapshot, StatesIndexStatus, + Cert, } from '../../../../../legacy/plugins/uptime/common/runtime_types'; import { GetMonitorStatesResult } from './get_monitor_states'; import { GetSnapshotCountParams } from './get_snapshot_counts'; @@ -36,6 +38,7 @@ import { MonitorDurationResult } from '../../../../../legacy/plugins/uptime/comm type ESQ = UMElasticsearchQueryFn; export interface UptimeRequests { + getCerts: ESQ; getFilterBar: ESQ; getIndexPattern: ESQ<{}, {}>; getLatestMonitor: ESQ; diff --git a/x-pack/plugins/uptime/server/lib/saved_objects.ts b/x-pack/plugins/uptime/server/lib/saved_objects.ts index 175634ef797cc..3ccfd498c44bf 100644 --- a/x-pack/plugins/uptime/server/lib/saved_objects.ts +++ b/x-pack/plugins/uptime/server/lib/saved_objects.ts @@ -7,14 +7,10 @@ import { DynamicSettings, defaultDynamicSettings, -} from '../../../../legacy/plugins/uptime/common/runtime_types/dynamic_settings'; +} from '../../../../legacy/plugins/uptime/common/runtime_types'; import { SavedObjectsType, SavedObjectsErrorHelpers } from '../../../../../src/core/server'; import { UMSavedObjectsQueryFn } from './adapters'; -export interface UMDynamicSettingsType { - heartbeatIndices: string; -} - export interface UMSavedObjectsAdapter { getUptimeDynamicSettings: UMSavedObjectsQueryFn; setUptimeDynamicSettings: UMSavedObjectsQueryFn; @@ -26,12 +22,22 @@ export const settingsObjectId = 'uptime-dynamic-settings-singleton'; export const umDynamicSettings: SavedObjectsType = { name: settingsObjectType, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { heartbeatIndices: { type: 'keyword', }, + certificatesThresholds: { + properties: { + errorState: { + type: 'long', + }, + warningState: { + type: 'long', + }, + }, + }, }, }, }; diff --git a/x-pack/plugins/uptime/server/rest_api/certs.ts b/x-pack/plugins/uptime/server/rest_api/certs.ts new file mode 100644 index 0000000000000..31fb3f4ab96a7 --- /dev/null +++ b/x-pack/plugins/uptime/server/rest_api/certs.ts @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { schema } from '@kbn/config-schema'; +import { UMServerLibs } from '../lib/lib'; +import { UMRestApiRouteFactory } from '.'; +import { API_URLS } from '../../../../legacy/plugins/uptime/common/constants/rest_api'; + +const DEFAULT_INDEX = 0; +const DEFAULT_SIZE = 25; +const DEFAULT_FROM = 'now-1d'; +const DEFAULT_TO = 'now'; + +export const createGetCertsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({ + method: 'GET', + path: API_URLS.CERTS, + validate: { + query: schema.object({ + from: schema.maybe(schema.string()), + to: schema.maybe(schema.string()), + search: schema.maybe(schema.string()), + index: schema.maybe(schema.number()), + size: schema.maybe(schema.number()), + }), + }, + writeAccess: false, + options: { + tags: ['access:uptime-read'], + }, + handler: async ({ callES, dynamicSettings }, _context, request, response): Promise => { + const index = request.query?.index ?? DEFAULT_INDEX; + const size = request.query?.size ?? DEFAULT_SIZE; + const from = request.query?.from ?? DEFAULT_FROM; + const to = request.query?.to ?? DEFAULT_TO; + const { search } = request.query; + + return response.ok({ + body: { + certs: await libs.requests.getCerts({ + callES, + dynamicSettings, + index, + search, + size, + from, + to, + }), + }, + }); + }, +}); diff --git a/x-pack/plugins/uptime/server/rest_api/index.ts b/x-pack/plugins/uptime/server/rest_api/index.ts index c0412e588fa93..a7a63342d11d4 100644 --- a/x-pack/plugins/uptime/server/rest_api/index.ts +++ b/x-pack/plugins/uptime/server/rest_api/index.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { createGetCertsRoute } from './certs'; import { createGetOverviewFilters } from './overview_filters'; import { createGetPingHistogramRoute, createGetPingsRoute } from './pings'; import { createGetDynamicSettingsRoute, createPostDynamicSettingsRoute } from './dynamic_settings'; @@ -12,6 +13,7 @@ import { createGetSnapshotCount } from './snapshot'; import { UMRestApiRouteFactory } from './types'; import { createGetMonitorDetailsRoute, + createMonitorListRoute, createGetMonitorLocationsRoute, createGetStatusBarRoute, } from './monitors'; @@ -22,6 +24,7 @@ export { createRouteWithAuth } from './create_route_with_auth'; export { uptimeRouteWrapper } from './uptime_route_wrapper'; export const restApiRoutes: UMRestApiRouteFactory[] = [ + createGetCertsRoute, createGetOverviewFilters, createGetPingsRoute, createGetIndexPatternRoute, @@ -30,6 +33,7 @@ export const restApiRoutes: UMRestApiRouteFactory[] = [ createPostDynamicSettingsRoute, createGetMonitorDetailsRoute, createGetMonitorLocationsRoute, + createMonitorListRoute, createGetStatusBarRoute, createGetSnapshotCount, createLogPageViewRoute, diff --git a/x-pack/plugins/uptime/server/rest_api/monitors/index.ts b/x-pack/plugins/uptime/server/rest_api/monitors/index.ts index 51b39037049b5..256f885d550ed 100644 --- a/x-pack/plugins/uptime/server/rest_api/monitors/index.ts +++ b/x-pack/plugins/uptime/server/rest_api/monitors/index.ts @@ -5,5 +5,6 @@ */ export { createGetMonitorDetailsRoute } from './monitors_details'; +export { createMonitorListRoute } from './monitor_list'; export { createGetMonitorLocationsRoute } from './monitor_locations'; export { createGetStatusBarRoute } from './monitor_status'; diff --git a/x-pack/plugins/uptime/server/rest_api/monitors/monitor_list.ts b/x-pack/plugins/uptime/server/rest_api/monitors/monitor_list.ts new file mode 100644 index 0000000000000..5cb4e8a6241b7 --- /dev/null +++ b/x-pack/plugins/uptime/server/rest_api/monitors/monitor_list.ts @@ -0,0 +1,69 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { schema } from '@kbn/config-schema'; +import { UMRestApiRouteFactory } from '../types'; +import { CONTEXT_DEFAULTS } from '../../../../../legacy/plugins/uptime/common/constants'; +import { API_URLS } from '../../../../../legacy/plugins/uptime/common/constants/rest_api'; + +export const createMonitorListRoute: UMRestApiRouteFactory = libs => ({ + method: 'GET', + path: API_URLS.MONITOR_LIST, + validate: { + query: schema.object({ + dateRangeStart: schema.string(), + dateRangeEnd: schema.string(), + filters: schema.maybe(schema.string()), + pagination: schema.maybe(schema.string()), + statusFilter: schema.maybe(schema.string()), + pageSize: schema.number(), + }), + }, + options: { + tags: ['access:uptime-read'], + }, + handler: async ({ callES, dynamicSettings }, _context, request, response): Promise => { + const { + dateRangeStart, + dateRangeEnd, + filters, + pagination, + statusFilter, + pageSize, + } = request.query; + + const decodedPagination = pagination + ? JSON.parse(decodeURIComponent(pagination)) + : CONTEXT_DEFAULTS.CURSOR_PAGINATION; + const [indexStatus, { summaries, nextPagePagination, prevPagePagination }] = await Promise.all([ + libs.requests.getIndexStatus({ callES, dynamicSettings }), + libs.requests.getMonitorStates({ + callES, + dynamicSettings, + dateRangeStart, + dateRangeEnd, + pagination: decodedPagination, + pageSize, + filters, + // this is added to make typescript happy, + // this sort of reassignment used to be further downstream but I've moved it here + // because this code is going to be decomissioned soon + statusFilter: statusFilter || undefined, + }), + ]); + + const totalSummaryCount = indexStatus?.docCount ?? 0; + + return response.ok({ + body: { + summaries, + nextPagePagination, + prevPagePagination, + totalSummaryCount, + }, + }); + }, +}); diff --git a/x-pack/plugins/uptime/server/uptime_server.ts b/x-pack/plugins/uptime/server/uptime_server.ts index d4b38b8ad27a0..cc6fe85b80cb2 100644 --- a/x-pack/plugins/uptime/server/uptime_server.ts +++ b/x-pack/plugins/uptime/server/uptime_server.ts @@ -4,8 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { makeExecutableSchema } from 'graphql-tools'; -import { DEFAULT_GRAPHQL_PATH, resolvers, typeDefs } from './graphql'; import { UMServerLibs } from './lib/lib'; import { createRouteWithAuth, restApiRoutes, uptimeRouteWrapper } from './rest_api'; import { UptimeCoreSetup, UptimeCorePlugins } from './lib/adapters'; @@ -23,10 +21,4 @@ export const initUptimeServer = ( uptimeAlertTypeFactories.forEach(alertTypeFactory => plugins.alerting.registerType(alertTypeFactory(server, libs)) ); - - const graphQLSchema = makeExecutableSchema({ - resolvers: resolvers.map(createResolversFn => createResolversFn(libs)), - typeDefs, - }); - libs.framework.registerGraphQLEndpoint(DEFAULT_GRAPHQL_PATH, graphQLSchema); }; diff --git a/x-pack/scripts/functional_tests.js b/x-pack/scripts/functional_tests.js index 061c9e4a0d921..974f3eb6db60f 100644 --- a/x-pack/scripts/functional_tests.js +++ b/x-pack/scripts/functional_tests.js @@ -4,13 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ -const alwaysImportedTests = [require.resolve('../test/functional/config.js')]; +const alwaysImportedTests = [ + require.resolve('../test/functional/config.js'), + require.resolve('../test/functional_endpoint_ingest_failure/config.ts'), + require.resolve('../test/functional_endpoint/config.ts'), + require.resolve('../test/functional_with_es_ssl/config.ts'), + require.resolve('../test/functional/config_security_basic.js'), + require.resolve('../test/plugin_functional/config.ts'), +]; const onlyNotInCoverageTests = [ require.resolve('../test/reporting/configs/chromium_api.js'), require.resolve('../test/reporting/configs/chromium_functional.js'), require.resolve('../test/reporting/configs/generate_api.js'), - require.resolve('../test/functional_with_es_ssl/config.ts'), - require.resolve('../test/functional/config_security_basic.js'), require.resolve('../test/api_integration/config_security_basic.js'), require.resolve('../test/api_integration/config.js'), require.resolve('../test/alerting_api_integration/basic/config.ts'), @@ -18,7 +23,6 @@ const onlyNotInCoverageTests = [ require.resolve('../test/alerting_api_integration/security_and_spaces/config.ts'), require.resolve('../test/detection_engine_api_integration/security_and_spaces/config.ts'), require.resolve('../test/plugin_api_integration/config.ts'), - require.resolve('../test/plugin_functional/config.ts'), require.resolve('../test/kerberos_api_integration/config.ts'), require.resolve('../test/kerberos_api_integration/anonymous_access.config.ts'), require.resolve('../test/saml_api_integration/config.ts'), @@ -43,8 +47,7 @@ const onlyNotInCoverageTests = [ require.resolve('../test/licensing_plugin/config.ts'), require.resolve('../test/licensing_plugin/config.public.ts'), require.resolve('../test/licensing_plugin/config.legacy.ts'), - require.resolve('../test/functional_endpoint_ingest_failure/config.ts'), - require.resolve('../test/functional_endpoint/config.ts'), + require.resolve('../test/endpoint_api_integration_no_ingest/config.ts'), ]; require('@kbn/plugin-helpers').babelRegister(); diff --git a/x-pack/test/api_integration/apis/endpoint/index.ts b/x-pack/test/api_integration/apis/endpoint/index.ts index 4ffd0c3b6044b..0a5f9aa595b8a 100644 --- a/x-pack/test/api_integration/apis/endpoint/index.ts +++ b/x-pack/test/api_integration/apis/endpoint/index.ts @@ -6,9 +6,17 @@ import { FtrProviderContext } from '../../ftr_provider_context'; -export default function endpointAPIIntegrationTests({ loadTestFile }: FtrProviderContext) { +export default function endpointAPIIntegrationTests({ + loadTestFile, + getService, +}: FtrProviderContext) { describe('Endpoint plugin', function() { + const ingestManager = getService('ingestManager'); this.tags(['endpoint']); + before(async () => { + await ingestManager.setup(); + }); + loadTestFile(require.resolve('./index_pattern')); loadTestFile(require.resolve('./resolver')); loadTestFile(require.resolve('./metadata')); loadTestFile(require.resolve('./alerts')); diff --git a/x-pack/test/api_integration/apis/endpoint/index_pattern.ts b/x-pack/test/api_integration/apis/endpoint/index_pattern.ts new file mode 100644 index 0000000000000..d3ffd67defef1 --- /dev/null +++ b/x-pack/test/api_integration/apis/endpoint/index_pattern.ts @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import expect from '@kbn/expect/expect.js'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + + describe('Endpoint index pattern API', () => { + it('should retrieve the index pattern for events', async () => { + const { body } = await supertest.get('/api/endpoint/index_pattern/events').expect(200); + expect(body.indexPattern).to.eql('events-endpoint-*'); + }); + + it('should retrieve the index pattern for metadata', async () => { + const { body } = await supertest.get('/api/endpoint/index_pattern/metadata').expect(200); + expect(body.indexPattern).to.eql('metrics-endpoint-*'); + }); + + it('should not retrieve the index pattern for an invalid key', async () => { + await supertest.get('/api/endpoint/index_pattern/blah').expect(404); + }); + }); +} diff --git a/x-pack/test/api_integration/apis/endpoint/metadata.ts b/x-pack/test/api_integration/apis/endpoint/metadata.ts index 887be6b85b100..943782c79ada7 100644 --- a/x-pack/test/api_integration/apis/endpoint/metadata.ts +++ b/x-pack/test/api_integration/apis/endpoint/metadata.ts @@ -159,7 +159,7 @@ export default function({ getService }: FtrProviderContext) { .post('/api/endpoint/metadata') .set('kbn-xsrf', 'xxx') .send({ - filter: `host.os.variant.keyword:${variantValue}`, + filter: `host.os.variant:${variantValue}`, }) .expect(200); expect(body.total).to.eql(2); diff --git a/x-pack/test/api_integration/apis/endpoint/resolver.ts b/x-pack/test/api_integration/apis/endpoint/resolver.ts index c1e9240c09951..e8d336e875b99 100644 --- a/x-pack/test/api_integration/apis/endpoint/resolver.ts +++ b/x-pack/test/api_integration/apis/endpoint/resolver.ts @@ -17,8 +17,8 @@ export default function resolverAPIIntegrationTests({ getService }: FtrProviderC const esArchiver = getService('esArchiver'); describe('Resolver', () => { - before(() => esArchiver.load('endpoint/resolver/api_feature')); - after(() => esArchiver.unload('endpoint/resolver/api_feature')); + before(async () => await esArchiver.load('endpoint/resolver/api_feature')); + after(async () => await esArchiver.unload('endpoint/resolver/api_feature')); describe('related events endpoint', () => { const endpointID = '5a0c957f-b8e7-4538-965e-57e8bb86ad3a'; diff --git a/x-pack/test/api_integration/apis/logstash/pipeline/delete.ts b/x-pack/test/api_integration/apis/logstash/pipeline/delete.ts index cdbf5a3e6a1fe..2463dbe4500b5 100644 --- a/x-pack/test/api_integration/apis/logstash/pipeline/delete.ts +++ b/x-pack/test/api_integration/apis/logstash/pipeline/delete.ts @@ -20,7 +20,6 @@ export default function({ getService }: FtrProviderContext) { .send({ id: 'fast_generator', description: 'foobar baz', - username: 'seger', pipeline: 'input { generator {} }\n\n output { stdout {} }', }) .expect(204); diff --git a/x-pack/test/api_integration/apis/logstash/pipeline/save.ts b/x-pack/test/api_integration/apis/logstash/pipeline/save.ts index 2ca9fbe7d68e0..ca0cfb19b9454 100644 --- a/x-pack/test/api_integration/apis/logstash/pipeline/save.ts +++ b/x-pack/test/api_integration/apis/logstash/pipeline/save.ts @@ -28,7 +28,6 @@ export default function({ getService }: FtrProviderContext) { .send({ id: 'fast_generator', description: 'foobar baz', - username: 'seger', pipeline: 'input { generator {} }\n\n output { stdout {} }', }) .expect(204); diff --git a/x-pack/test/api_integration/apis/management/cross_cluster_replication/follower_indices.helpers.js b/x-pack/test/api_integration/apis/management/cross_cluster_replication/follower_indices.helpers.js index dbcb6bf819749..294db29f6dce4 100644 --- a/x-pack/test/api_integration/apis/management/cross_cluster_replication/follower_indices.helpers.js +++ b/x-pack/test/api_integration/apis/management/cross_cluster_replication/follower_indices.helpers.js @@ -13,7 +13,45 @@ export const registerHelpers = supertest => { const loadFollowerIndices = () => supertest.get(`${API_BASE_PATH}/follower_indices`); - const getFollowerIndex = name => supertest.get(`${API_BASE_PATH}/follower_indices/${name}`); + const getFollowerIndex = (name, waitUntilIsActive = false) => { + const maxRetries = 10; + const delayBetweenRetries = 500; + let retryCount = 0; + + const proceed = async () => { + const response = await supertest.get(`${API_BASE_PATH}/follower_indices/${name}`); + + if (waitUntilIsActive && response.body.status !== 'active') { + retryCount += 1; + + if (retryCount > maxRetries) { + throw new Error('Error waiting for follower index to be active.'); + } + + return new Promise(resolve => setTimeout(resolve, delayBetweenRetries)).then(proceed); + } + + return response; + }; + + return { + expect: status => + new Promise((resolve, reject) => + proceed() + .then(response => { + if (status !== response.status) { + reject(new Error(`Expected status ${status} but got ${response.status}`)); + } + return resolve(response); + }) + .catch(reject) + ), + then: (resolve, reject) => + proceed() + .then(resolve) + .catch(reject), + }; + }; const createFollowerIndex = (name = getRandomString(), payload = getFollowerIndexPayload()) => { followerIndicesCreated.push(name); @@ -24,6 +62,13 @@ export const registerHelpers = supertest => { .send({ ...payload, name }); }; + const updateFollowerIndex = (name, payload) => { + return supertest + .put(`${API_BASE_PATH}/follower_indices/${name}`) + .set('kbn-xsrf', 'xxx') + .send(payload); + }; + const unfollowLeaderIndex = followerIndex => { const followerIndices = Array.isArray(followerIndex) ? followerIndex : [followerIndex]; const followerIndicesToEncodedString = followerIndices @@ -51,6 +96,7 @@ export const registerHelpers = supertest => { loadFollowerIndices, getFollowerIndex, createFollowerIndex, + updateFollowerIndex, unfollowAll, }; }; diff --git a/x-pack/test/api_integration/apis/management/cross_cluster_replication/follower_indices.js b/x-pack/test/api_integration/apis/management/cross_cluster_replication/follower_indices.js index 5f9ebbd2a0a3f..eabf474120f2b 100644 --- a/x-pack/test/api_integration/apis/management/cross_cluster_replication/follower_indices.js +++ b/x-pack/test/api_integration/apis/management/cross_cluster_replication/follower_indices.js @@ -21,6 +21,7 @@ export default function({ getService }) { loadFollowerIndices, getFollowerIndex, createFollowerIndex, + updateFollowerIndex, unfollowAll, } = registerFollowerIndicesnHelpers(supertest); @@ -92,6 +93,31 @@ export default function({ getService }) { }); }); + describe('update()', () => { + it('should update a follower index advanced settings', async () => { + // Create a follower index + const leaderIndex = await createIndex(); + const followerIndex = getRandomString(); + const initialValue = 1234; + const payload = getFollowerIndexPayload(leaderIndex, undefined, { + maxReadRequestOperationCount: initialValue, + }); + await createFollowerIndex(followerIndex, payload); + + // Verify that its advanced settings are correctly set + const { body } = await getFollowerIndex(followerIndex, true); + expect(body.maxReadRequestOperationCount).to.be(initialValue); + + // Update the follower index + const updatedValue = 7777; + await updateFollowerIndex(followerIndex, { maxReadRequestOperationCount: updatedValue }); + + // Verify that the advanced settings are updated + const { body: updatedBody } = await getFollowerIndex(followerIndex, true); + expect(updatedBody.maxReadRequestOperationCount).to.be(updatedValue); + }); + }); + describe('Advanced settings', () => { it('hard-coded values should match Elasticsearch default values', async () => { /** diff --git a/x-pack/test/api_integration/apis/maps/migrations.js b/x-pack/test/api_integration/apis/maps/migrations.js index c4587530e160b..cd575899118a3 100644 --- a/x-pack/test/api_integration/apis/maps/migrations.js +++ b/x-pack/test/api_integration/apis/maps/migrations.js @@ -41,7 +41,7 @@ export default function({ getService }) { type: 'index-pattern', }, ]); - expect(resp.body.migrationVersion).to.eql({ map: '7.7.0' }); + expect(resp.body.migrationVersion).to.eql({ map: '7.8.0' }); expect(resp.body.attributes.layerListJSON.includes('indexPatternRefName')).to.be(true); }); }); diff --git a/x-pack/test/api_integration/apis/ml/bucket_span_estimator.ts b/x-pack/test/api_integration/apis/ml/bucket_span_estimator.ts index 3f56fb927d131..bc0dc3019d7c9 100644 --- a/x-pack/test/api_integration/apis/ml/bucket_span_estimator.ts +++ b/x-pack/test/api_integration/apis/ml/bucket_span_estimator.ts @@ -28,7 +28,7 @@ export default ({ getService }: FtrProviderContext) => { aggTypes: ['avg'], duration: { start: 1560297859000, end: 1562975136000 }, fields: ['taxless_total_price'], - index: 'ecommerce', + index: 'ft_ecommerce', query: { bool: { must: [{ match_all: {} }] } }, timeField: 'order_date', }, @@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext) => { aggTypes: ['avg', 'sum'], duration: { start: 1560297859000, end: 1562975136000 }, fields: ['products.base_price', 'products.base_unit_price'], - index: 'ecommerce', + index: 'ft_ecommerce', query: { bool: { must: [{ match_all: {} }] } }, timeField: 'order_date', }, @@ -60,7 +60,7 @@ export default ({ getService }: FtrProviderContext) => { aggTypes: ['avg'], duration: { start: 1560297859000, end: 1562975136000 }, fields: ['taxless_total_price'], - index: 'ecommerce', + index: 'ft_ecommerce', query: { bool: { must: [{ match_all: {} }] } }, splitField: 'customer_first_name.keyword', timeField: 'order_date', @@ -78,7 +78,7 @@ export default ({ getService }: FtrProviderContext) => { duration: { start: 1560297859000, end: 1562975136000 }, fields: ['taxless_total_price'], filters: [], - index: 'ecommerce', + index: 'ft_ecommerce', query: { bool: { must: [{ match_all: {} }] } }, timeField: 'order_date', }, @@ -91,11 +91,8 @@ export default ({ getService }: FtrProviderContext) => { describe('bucket span estimator', function() { before(async () => { - await esArchiver.load('ml/ecommerce'); - }); - - after(async () => { - await esArchiver.unload('ml/ecommerce'); + await esArchiver.loadIfNeeded('ml/ecommerce'); + await ml.testResources.setKibanaTimeZoneToUTC(); }); describe('with default settings', function() { diff --git a/x-pack/test/api_integration/apis/ml/calculate_model_memory_limit.ts b/x-pack/test/api_integration/apis/ml/calculate_model_memory_limit.ts index 975a10c2aed2a..59e3dfcca00f9 100644 --- a/x-pack/test/api_integration/apis/ml/calculate_model_memory_limit.ts +++ b/x-pack/test/api_integration/apis/ml/calculate_model_memory_limit.ts @@ -22,7 +22,7 @@ export default ({ getService }: FtrProviderContext) => { testTitleSuffix: 'when no partition field is provided with regular function', user: USER.ML_POWERUSER, requestBody: { - indexPattern: 'ecommerce', + indexPattern: 'ft_ecommerce', analysisConfig: { bucket_span: '15m', detectors: [ @@ -51,7 +51,7 @@ export default ({ getService }: FtrProviderContext) => { testTitleSuffix: 'with 1 metric and 1 influencer same as split field', user: USER.ML_POWERUSER, requestBody: { - indexPattern: 'ecommerce', + indexPattern: 'ft_ecommerce', analysisConfig: { bucket_span: '15m', detectors: [ @@ -77,7 +77,7 @@ export default ({ getService }: FtrProviderContext) => { testTitleSuffix: 'with 3 influencers, split by city', user: USER.ML_POWERUSER, requestBody: { - indexPattern: 'ecommerce', + indexPattern: 'ft_ecommerce', analysisConfig: { bucket_span: '15m', detectors: [ @@ -104,7 +104,7 @@ export default ({ getService }: FtrProviderContext) => { '2 detectors split by city and manufacturer, 4 influencers, filtering by country code', user: USER.ML_POWERUSER, requestBody: { - indexPattern: 'ecommerce', + indexPattern: 'ft_ecommerce', analysisConfig: { bucket_span: '2d', detectors: [ @@ -148,11 +148,8 @@ export default ({ getService }: FtrProviderContext) => { describe('calculate model memory limit', function() { before(async () => { - await esArchiver.load('ml/ecommerce'); - }); - - after(async () => { - await esArchiver.unload('ml/ecommerce'); + await esArchiver.loadIfNeeded('ml/ecommerce'); + await ml.testResources.setKibanaTimeZoneToUTC(); }); for (const testData of testDataList) { diff --git a/x-pack/test/api_integration/apis/ml/categorization_field_examples.ts b/x-pack/test/api_integration/apis/ml/categorization_field_examples.ts index b8ee2e7f6562c..df0153f965942 100644 --- a/x-pack/test/api_integration/apis/ml/categorization_field_examples.ts +++ b/x-pack/test/api_integration/apis/ml/categorization_field_examples.ts @@ -66,7 +66,7 @@ const analyzer = { ], }; const defaultRequestBody = { - indexPatternTitle: 'categorization_functional_test', + indexPatternTitle: 'ft_categorization', query: { bool: { must: [{ match_all: {} }] } }, size: 5, timeField: '@timestamp', @@ -289,11 +289,8 @@ export default ({ getService }: FtrProviderContext) => { describe('Categorization example endpoint - ', function() { before(async () => { - await esArchiver.load('ml/categorization'); - }); - - after(async () => { - await esArchiver.unload('ml/categorization'); + await esArchiver.loadIfNeeded('ml/categorization'); + await ml.testResources.setKibanaTimeZoneToUTC(); }); for (const testData of testDataList) { diff --git a/x-pack/test/api_integration/apis/ml/get_module.ts b/x-pack/test/api_integration/apis/ml/get_module.ts index 6dcd9594fc9aa..a50d3c0abe430 100644 --- a/x-pack/test/api_integration/apis/ml/get_module.ts +++ b/x-pack/test/api_integration/apis/ml/get_module.ts @@ -50,6 +50,10 @@ export default ({ getService }: FtrProviderContext) => { } describe('get_module', function() { + before(async () => { + await ml.testResources.setKibanaTimeZoneToUTC(); + }); + it('lists all modules', async () => { const rspBody = await executeGetModuleRequest('', USER.ML_POWERUSER, 200); expect(rspBody).to.be.an(Array); diff --git a/x-pack/test/api_integration/apis/ml/index.ts b/x-pack/test/api_integration/apis/ml/index.ts index 4e21faa610bfe..f012883c46ca3 100644 --- a/x-pack/test/api_integration/apis/ml/index.ts +++ b/x-pack/test/api_integration/apis/ml/index.ts @@ -7,6 +7,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function({ getService, loadTestFile }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); const ml = getService('ml'); describe('Machine Learning', function() { @@ -20,6 +21,14 @@ export default function({ getService, loadTestFile }: FtrProviderContext) { after(async () => { await ml.securityCommon.cleanMlUsers(); await ml.securityCommon.cleanMlRoles(); + + await ml.testResources.deleteIndexPattern('kibana_sample_data_logs'); + + await esArchiver.unload('ml/ecommerce'); + await esArchiver.unload('ml/categorization'); + await esArchiver.unload('ml/sample_logs'); + + await ml.testResources.resetKibanaTimeZone(); }); loadTestFile(require.resolve('./bucket_span_estimator')); diff --git a/x-pack/test/api_integration/apis/ml/recognize_module.ts b/x-pack/test/api_integration/apis/ml/recognize_module.ts index 2110bded7394c..8e360579c1459 100644 --- a/x-pack/test/api_integration/apis/ml/recognize_module.ts +++ b/x-pack/test/api_integration/apis/ml/recognize_module.ts @@ -32,7 +32,6 @@ export default ({ getService }: FtrProviderContext) => { }, { testTitleSuffix: 'for non existent index pattern', - sourceDataArchive: 'empty_kibana', indexPattern: 'non-existent-index-pattern', user: USER.ML_POWERUSER, expected: { @@ -53,14 +52,16 @@ export default ({ getService }: FtrProviderContext) => { } describe('module recognizer', function() { + before(async () => { + await ml.testResources.setKibanaTimeZoneToUTC(); + }); + for (const testData of testDataList) { describe('lists matching modules', function() { before(async () => { - await esArchiver.load(testData.sourceDataArchive); - }); - - after(async () => { - await esArchiver.unload(testData.sourceDataArchive); + if (testData.hasOwnProperty('sourceDataArchive')) { + await esArchiver.loadIfNeeded(testData.sourceDataArchive!); + } }); it(testData.testTitleSuffix, async () => { diff --git a/x-pack/test/api_integration/apis/ml/setup_module.ts b/x-pack/test/api_integration/apis/ml/setup_module.ts index 71f3910cd4e93..e603782b25717 100644 --- a/x-pack/test/api_integration/apis/ml/setup_module.ts +++ b/x-pack/test/api_integration/apis/ml/setup_module.ts @@ -25,6 +25,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for sample logs dataset with prefix and startDatafeed false', sourceDataArchive: 'ml/sample_logs', + indexPattern: { name: 'kibana_sample_data_logs', timeField: '@timestamp' }, module: 'sample_data_weblogs', user: USER.ML_POWERUSER, requestBody: { @@ -58,7 +59,6 @@ export default ({ getService }: FtrProviderContext) => { const testDataListNegative = [ { testTitleSuffix: 'for non existent index pattern', - sourceDataArchive: 'empty_kibana', module: 'sample_data_weblogs', user: USER.ML_POWERUSER, requestBody: { @@ -75,6 +75,7 @@ export default ({ getService }: FtrProviderContext) => { { testTitleSuffix: 'for unauthorized user', sourceDataArchive: 'ml/sample_logs', + indexPattern: { name: 'kibana_sample_data_logs', timeField: '@timestamp' }, module: 'sample_data_weblogs', user: USER.ML_UNAUTHORIZED, requestBody: { @@ -118,14 +119,21 @@ export default ({ getService }: FtrProviderContext) => { } describe('module setup', function() { + before(async () => { + await ml.testResources.setKibanaTimeZoneToUTC(); + }); + for (const testData of testDataListPositive) { describe('sets up module data', function() { before(async () => { - await esArchiver.load(testData.sourceDataArchive); + await esArchiver.loadIfNeeded(testData.sourceDataArchive); + await ml.testResources.createIndexPatternIfNeeded( + testData.indexPattern.name, + testData.indexPattern.timeField + ); }); after(async () => { - await esArchiver.unload(testData.sourceDataArchive); await ml.api.cleanMlIndices(); }); @@ -199,11 +207,18 @@ export default ({ getService }: FtrProviderContext) => { for (const testData of testDataListNegative) { describe('rejects request', function() { before(async () => { - await esArchiver.load(testData.sourceDataArchive); + if (testData.hasOwnProperty('sourceDataArchive')) { + await esArchiver.loadIfNeeded(testData.sourceDataArchive!); + } + if (testData.hasOwnProperty('indexPattern')) { + await ml.testResources.createIndexPatternIfNeeded( + testData.indexPattern!.name as string, + testData.indexPattern!.timeField as string + ); + } }); after(async () => { - await esArchiver.unload(testData.sourceDataArchive); await ml.api.cleanMlIndices(); }); diff --git a/x-pack/test/api_integration/apis/siem/overview_host.ts b/x-pack/test/api_integration/apis/siem/overview_host.ts index d32eeaec884fa..7e5cbd7673af7 100644 --- a/x-pack/test/api_integration/apis/siem/overview_host.ts +++ b/x-pack/test/api_integration/apis/siem/overview_host.ts @@ -5,10 +5,11 @@ */ import expect from '@kbn/expect'; + +import { DEFAULT_INDEX_PATTERN } from '../../../../plugins/siem/common/constants'; import { overviewHostQuery } from '../../../../legacy/plugins/siem/public/containers/overview/overview_host/index.gql_query'; import { GetOverviewHostQuery } from '../../../../legacy/plugins/siem/public/graphql/types'; import { FtrProviderContext } from '../../ftr_provider_context'; -import { defaultIndexPattern } from '../../../../legacy/plugins/siem/default_index_pattern'; export default function({ getService }: FtrProviderContext) { const esArchiver = getService('esArchiver'); @@ -51,7 +52,7 @@ export default function({ getService }: FtrProviderContext) { to: TO, from: FROM, }, - defaultIndex: defaultIndexPattern, + defaultIndex: DEFAULT_INDEX_PATTERN, inspect: false, }, }) diff --git a/x-pack/test/api_integration/apis/uptime/feature_controls.ts b/x-pack/test/api_integration/apis/uptime/feature_controls.ts index 8b82735fc38b0..6d125807e169d 100644 --- a/x-pack/test/api_integration/apis/uptime/feature_controls.ts +++ b/x-pack/test/api_integration/apis/uptime/feature_controls.ts @@ -26,17 +26,6 @@ export default function featureControlsTests({ getService }: FtrProviderContext) expect(result.response).to.have.property('statusCode', 200); }; - const executeRESTAPIQuery = async (username: string, password: string, spaceId?: string) => { - const basePath = spaceId ? `/s/${spaceId}` : ''; - - return await supertest - .get(basePath + API_URLS.INDEX_STATUS) - .auth(username, password) - .set('kbn-xsrf', 'foo') - .then((response: any) => ({ error: undefined, response })) - .catch((error: any) => ({ error, response: undefined })); - }; - const executePingsRequest = async (username: string, password: string, spaceId?: string) => { const basePath = spaceId ? `/s/${spaceId}` : ''; @@ -72,9 +61,6 @@ export default function featureControlsTests({ getService }: FtrProviderContext) full_name: 'a kibana user', }); - const graphQLResult = await executeRESTAPIQuery(username, password); - expect404(graphQLResult); - const pingsResult = await executePingsRequest(username, password); expect404(pingsResult); } finally { @@ -111,9 +97,6 @@ export default function featureControlsTests({ getService }: FtrProviderContext) full_name: 'a kibana user', }); - const graphQLResult = await executeRESTAPIQuery(username, password); - expectResponse(graphQLResult); - const pingsResult = await executePingsRequest(username, password); expectResponse(pingsResult); } finally { @@ -153,9 +136,6 @@ export default function featureControlsTests({ getService }: FtrProviderContext) full_name: 'a kibana user', }); - const graphQLResult = await executeRESTAPIQuery(username, password); - expect404(graphQLResult); - const pingsResult = await executePingsRequest(username, password); expect404(pingsResult); } finally { @@ -222,17 +202,11 @@ export default function featureControlsTests({ getService }: FtrProviderContext) }); it('user_1 can access APIs in space_1', async () => { - const graphQLResult = await executeRESTAPIQuery(username, password, space1Id); - expectResponse(graphQLResult); - const pingsResult = await executePingsRequest(username, password, space1Id); expectResponse(pingsResult); }); it(`user_1 can't access APIs in space_2`, async () => { - const graphQLResult = await executeRESTAPIQuery(username, password); - expect404(graphQLResult); - const pingsResult = await executePingsRequest(username, password); expect404(pingsResult); }); diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states.json deleted file mode 100644 index a748225dda7cf..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": null, - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0009-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0000-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0001-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0002-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0003-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0004-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0005-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0006-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0007-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0008-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0009-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_id_filtered.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_id_filtered.json deleted file mode 100644 index 44644be5a0724..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_id_filtered.json +++ /dev/null @@ -1,169 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": null, - "nextPagePagination": null, - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0002-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_1.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_1.json deleted file mode 100644 index a748225dda7cf..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_1.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": null, - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0009-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0000-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0001-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0002-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0003-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0004-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0005-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0006-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0007-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0008-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0009-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_10.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_10.json deleted file mode 100644 index fbd0776fade62..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_10.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0090-intermittent\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": null, - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0090-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0091-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0092-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0093-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0094-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0095-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0096-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234376" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234376 - } - }, - { - "monitor_id": "0097-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234405" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234405 - } - }, - { - "monitor_id": "0098-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234406" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234406 - } - }, - { - "monitor_id": "0099-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234406" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234406 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_10_previous.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_10_previous.json deleted file mode 100644 index e630e227f473b..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_10_previous.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0080-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0089-up\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"AFTER\"}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0080-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0081-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0082-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0083-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0084-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0085-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0086-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0087-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0088-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0089-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_2.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_2.json deleted file mode 100644 index 26b4b1a195567..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_2.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0010-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0019-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0010-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0011-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0012-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0013-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0014-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0015-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0016-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0017-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0018-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0019-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_2_previous.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_2_previous.json deleted file mode 100644 index 0b93e66f50246..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_2_previous.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": null, - "nextPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0009-up\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"AFTER\"}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0000-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0001-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0002-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0003-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0004-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0005-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0006-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0007-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0008-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0009-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_3.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_3.json deleted file mode 100644 index 7b47742f8859a..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_3.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0020-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0029-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0020-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0021-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0022-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0023-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0024-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0025-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0026-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0027-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0028-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0029-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_3_previous.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_3_previous.json deleted file mode 100644 index 0d5a76059d004..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_3_previous.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0010-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0019-up\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"AFTER\"}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0010-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0011-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0012-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0013-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0014-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0015-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0016-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0017-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0018-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0019-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_4.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_4.json deleted file mode 100644 index 4caff800ac96e..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_4.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0030-intermittent\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0039-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0030-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0031-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0032-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0033-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0034-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0035-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0036-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0037-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0038-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0039-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_4_previous.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_4_previous.json deleted file mode 100644 index 02bd149b50247..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_4_previous.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0020-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0029-up\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"AFTER\"}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0020-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0021-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0022-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0023-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0024-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0025-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0026-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0027-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0028-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0029-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_5.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_5.json deleted file mode 100644 index 11e880f1ec329..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_5.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0040-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0049-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0040-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0041-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0042-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0043-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0044-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0045-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0046-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0047-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234390" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234390 - } - }, - { - "monitor_id": "0048-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234386" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234386 - } - }, - { - "monitor_id": "0049-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234405" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234405 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_5_previous.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_5_previous.json deleted file mode 100644 index 26cfa7c7162e8..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_5_previous.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0030-intermittent\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0039-up\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"AFTER\"}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0030-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0031-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0032-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0033-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0034-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0035-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0036-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0037-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0038-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0039-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_6.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_6.json deleted file mode 100644 index 8f4b5d4c52e71..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_6.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0050-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0059-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0050-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234386" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234386 - } - }, - { - "monitor_id": "0051-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0052-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0053-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0054-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0055-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0056-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0057-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0058-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0059-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_6_previous.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_6_previous.json deleted file mode 100644 index 50f8f61b13d68..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_6_previous.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0040-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0049-up\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"AFTER\"}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0040-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0041-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0042-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0043-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0044-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0045-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0046-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0047-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234390" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234390 - } - }, - { - "monitor_id": "0048-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234386" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234386 - } - }, - { - "monitor_id": "0049-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234405" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234405 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_7.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_7.json deleted file mode 100644 index 18ab2c6fdf336..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_7.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0060-intermittent\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0069-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0060-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0061-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0062-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0063-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0064-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0065-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0066-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0067-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0068-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0069-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_7_previous.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_7_previous.json deleted file mode 100644 index 825d6365e3a9d..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_7_previous.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0050-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0059-up\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"AFTER\"}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0050-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234386" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234386 - } - }, - { - "monitor_id": "0051-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0052-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0053-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0054-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0055-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0056-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0057-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0058-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0059-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_8.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_8.json deleted file mode 100644 index abb9bcdd804ed..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_8.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0070-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0079-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0070-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0071-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0072-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234376" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234376 - } - }, - { - "monitor_id": "0073-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234406" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234406 - } - }, - { - "monitor_id": "0074-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234410" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234410 - } - }, - { - "monitor_id": "0075-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234406" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234406 - } - }, - { - "monitor_id": "0076-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234387" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234387 - } - }, - { - "monitor_id": "0077-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234389" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234389 - } - }, - { - "monitor_id": "0078-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0079-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_8_previous.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_8_previous.json deleted file mode 100644 index 46a5f195e6a82..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_8_previous.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0060-intermittent\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0069-up\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"AFTER\"}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0060-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0061-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0062-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0063-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0064-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0065-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0066-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0067-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0068-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234374" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234374 - } - }, - { - "monitor_id": "0069-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_9.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_9.json deleted file mode 100644 index 035baf0ab5b5e..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_9.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0080-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorDirection\":\"AFTER\",\"sortOrder\":\"ASC\",\"cursorKey\":{\"monitor_id\":\"0089-up\"}}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0080-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0081-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0082-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234372" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234372 - } - }, - { - "monitor_id": "0083-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0084-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0085-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0086-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0087-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0088-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - }, - { - "monitor_id": "0089-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234373" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234373 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_9_previous.json b/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_9_previous.json deleted file mode 100644 index a6d274056eec6..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_states_page_9_previous.json +++ /dev/null @@ -1,1609 +0,0 @@ -{ - "monitorStates": { - "prevPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0070-down\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"BEFORE\"}", - "nextPagePagination": "{\"cursorKey\":{\"monitor_id\":\"0079-up\"},\"sortOrder\":\"ASC\",\"cursorDirection\":\"AFTER\"}", - "totalSummaryCount": 2000, - "summaries": [ - { - "monitor_id": "0070-down", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172694000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172724000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172754000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172784000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172874000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172904000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172934000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172964000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173054000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173084000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173174000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173204000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173234000, - "up": 0, - "down": 1 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "down" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "down", - "type": null - }, - "summary": { - "up": 0, - "down": 1, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=400x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0071-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234375" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234375 - } - }, - { - "monitor_id": "0072-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234376" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234376 - } - }, - { - "monitor_id": "0073-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234406" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234406 - } - }, - { - "monitor_id": "0074-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234410" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234410 - } - }, - { - "monitor_id": "0075-intermittent", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 0, - "down": 1 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234406" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x5,500x1", - "domain": "localhost" - }, - "timestamp": 1568173234406 - } - }, - { - "monitor_id": "0076-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234387" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234387 - } - }, - { - "monitor_id": "0077-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234389" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234389 - } - }, - { - "monitor_id": "0078-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - }, - { - "monitor_id": "0079-up", - "histogram": { - "count": 20, - "points": [ - { - "timestamp": 1568172664000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172694000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172724000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172754000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172784000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172814000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172844000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172874000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172904000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172934000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172964000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568172994000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173024000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173054000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173084000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173114000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173144000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173174000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173204000, - "up": 1, - "down": 0 - }, - { - "timestamp": 1568173234000, - "up": 1, - "down": 0 - } - ] - }, - "state": { - "agent": null, - "checks": [ - { - "agent": { - "id": "04e1d082-65bc-4929-8d65-d0768a2621c4" - }, - "container": null, - "kubernetes": null, - "monitor": { - "ip": "127.0.0.1", - "name": "", - "status": "up" - }, - "observer": { - "geo": { - "name": "mpls", - "location": { - "lat": 37.926867976784706, - "lon": -78.02490200847387 - } - } - }, - "timestamp": "1568173234371" - } - ], - "geo": null, - "observer": { - "geo": { - "name": [ - "mpls" - ], - "location": null - } - }, - "monitor": { - "id": null, - "name": null, - "status": "up", - "type": null - }, - "summary": { - "up": 1, - "down": 0, - "geo": null - }, - "url": { - "full": "http://localhost:5678/pattern?r=200x1", - "domain": "localhost" - }, - "timestamp": 1568173234371 - } - } - ] - } -} \ No newline at end of file diff --git a/x-pack/test/api_integration/apis/uptime/graphql/index.ts b/x-pack/test/api_integration/apis/uptime/graphql/index.ts deleted file mode 100644 index 862cce47f257a..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { FtrProviderContext } from '../../../ftr_provider_context'; - -export default function({ loadTestFile }: FtrProviderContext) { - describe('graphql', () => { - // each of these test files imports a GQL query from - // the uptime app and runs it against the live HTTP server, - // verifying the pre-loaded documents are returned in a way that - // matches the snapshots contained in './fixtures' - loadTestFile(require.resolve('./monitor_states')); - }); -} diff --git a/x-pack/test/api_integration/apis/uptime/graphql/monitor_states.ts b/x-pack/test/api_integration/apis/uptime/graphql/monitor_states.ts deleted file mode 100644 index 216560583249c..0000000000000 --- a/x-pack/test/api_integration/apis/uptime/graphql/monitor_states.ts +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { expectFixtureEql } from './helpers/expect_fixture_eql'; -import { FtrProviderContext } from '../../../ftr_provider_context'; -import { makeChecksWithStatus } from './helpers/make_checks'; -import { monitorStatesQueryString } from '../../../../../legacy/plugins/uptime/public/queries/monitor_states_query'; -import { MonitorSummary } from '../../../../../legacy/plugins/uptime/common/graphql/types'; - -export default function({ getService }: FtrProviderContext) { - const supertest = getService('supertest'); - let dateRangeStart: string; - let dateRangeEnd: string; - - const getMonitorStates = async (variables: { [key: string]: any } = {}) => { - const query = { - operationName: 'MonitorStates', - query: monitorStatesQueryString, - variables: { - dateRangeStart, - dateRangeEnd, - pageSize: 10, - ...variables, - }, - }; - - const { - body: { data }, - } = await supertest - .post('/api/uptime/graphql') - .set('kbn-xsrf', 'foo') - .send({ ...query }); - - return data; - }; - - describe('monitor states', async () => { - describe('with real world data', () => { - before('load heartbeat data', () => getService('esArchiver').load('uptime/full_heartbeat')); - after('unload heartbeat index', () => - getService('esArchiver').unload('uptime/full_heartbeat') - ); - - before('set start/end', () => { - dateRangeStart = '2019-09-11T03:31:04.380Z'; - dateRangeEnd = '2019-09-11T03:40:34.410Z'; - }); - - it('will fetch monitor state data for the given filters and range', async () => { - const data: any = await getMonitorStates({ - statusFilter: 'up', - filters: - '{"bool":{"must":[{"match":{"monitor.id":{"query":"0002-up","operator":"and"}}}]}}', - }); - // await new Promise(r => setTimeout(r, 90000)); - expectFixtureEql(data, 'monitor_states_id_filtered'); - }); - - it('will fetch monitor state data for the given date range', async () => { - expectFixtureEql(await getMonitorStates(), 'monitor_states'); - }); - - it('can navigate forward and backward using pagination', async () => { - const expectedResultsCount = 100; - const expectedPageCount = expectedResultsCount / 10; - - let pagination: string | null = null; - for (let page = 1; page <= expectedPageCount; page++) { - const data: any = await getMonitorStates({ pagination }); - pagination = data.monitorStates.nextPagePagination; - expectFixtureEql(data, `monitor_states_page_${page}`); - - // Test to see if the previous page pagination works on every page (other than the first) - if (page > 1) { - const prevData = await getMonitorStates({ - pagination: data.monitorStates.prevPagePagination, - }); - expectFixtureEql(prevData, `monitor_states_page_${page}_previous`); - } - } - }); - }); - - describe('monitor state scoping', async () => { - const numIps = 4; // Must be > 2 for IP uniqueness checks - - before('load heartbeat data', () => getService('esArchiver').load('uptime/blank')); - after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank')); - - describe('query document scoping with mismatched check statuses', async () => { - let checks: any[] = []; - let nonSummaryIp: string | null = null; - const testMonitorId = 'scope-test-id'; - const makeApiParams = (monitorId: string, filterClauses: any[] = []): any => { - return { - filters: JSON.stringify({ - bool: { - filter: [{ match: { 'monitor.id': monitorId } }, ...filterClauses], - }, - }), - }; - }; - - before(async () => { - const es = getService('legacyEs'); - dateRangeStart = new Date().toISOString(); - checks = await makeChecksWithStatus(es, testMonitorId, 1, numIps, 1, {}, 'up', d => { - // turn an all up status into having at least one down - if (d.summary) { - d.monitor.status = 'down'; - d.summary.up--; - d.summary.down++; - } - return d; - }); - - dateRangeEnd = new Date().toISOString(); - nonSummaryIp = checks[0][0].monitor.ip; - }); - - it('should return all IPs', async () => { - const res = await getMonitorStates(makeApiParams(testMonitorId)); - - const uniqueIps = new Set(); - res.monitorStates.summaries[0].state.checks.forEach((c: any) => - uniqueIps.add(c.monitor.ip) - ); - - expect(uniqueIps.size).to.eql(4); - }); - - it('should match non summary documents without a status filter', async () => { - const params = makeApiParams(testMonitorId, [{ match: { 'monitor.ip': nonSummaryIp } }]); - - const nonSummaryRes = await getMonitorStates(params); - expect(nonSummaryRes.monitorStates.summaries.length).to.eql(1); - }); - - it('should not match non summary documents if the check status does not match the document status', async () => { - const params = makeApiParams(testMonitorId, [{ match: { 'monitor.ip': nonSummaryIp } }]); - params.statusFilter = 'down'; - - const nonSummaryRes = await getMonitorStates(params); - expect(nonSummaryRes.monitorStates.summaries.length).to.eql(0); - }); - - it('should not non match non summary documents if the check status does not match', async () => { - const params = makeApiParams(testMonitorId, [{ match: { 'monitor.ip': nonSummaryIp } }]); - params.statusFilter = 'up'; - - const nonSummaryRes = await getMonitorStates(params); - expect(nonSummaryRes.monitorStates.summaries.length).to.eql(0); - }); - - describe('matching outside of the date range', async () => { - before('set date range to future', () => { - const futureDate = new Date(); - - // Set dateRangeStart to one day from now - futureDate.setDate(futureDate.getDate() + 1); - dateRangeStart = futureDate.toISOString(); - - // Set dateRangeStart to two days from now - futureDate.setDate(futureDate.getDate() + 1); - dateRangeEnd = futureDate.toISOString(); - }); - - it('should not match any documents', async () => { - const params = makeApiParams(testMonitorId); - params.statusFilter = 'up'; - - const nonSummaryRes = await getMonitorStates(params); - expect(nonSummaryRes.monitorStates.summaries.length).to.eql(0); - }); - }); - }); - }); - - describe(' test status filter', async () => { - const upMonitorId = 'up-test-id'; - const downMonitorId = 'down-test-id'; - const mixMonitorId = 'mix-test-id'; - before('generate three monitors with up, down, mix state', async () => { - await getService('esArchiver').load('uptime/blank'); - - const es = getService('legacyEs'); - - const observer = { - geo: { - name: 'US-East', - location: '40.7128, -74.0060', - }, - }; - - // Generating three monitors each with two geo locations, - // One in a down state , - // One in an up state, - // One in a mix state - - dateRangeStart = new Date().toISOString(); - - await makeChecksWithStatus(es, upMonitorId, 1, 4, 1, {}, 'up'); - await makeChecksWithStatus(es, upMonitorId, 1, 4, 1, { observer }, 'up'); - - await makeChecksWithStatus(es, downMonitorId, 1, 4, 1, {}, 'down'); - await makeChecksWithStatus(es, downMonitorId, 1, 4, 1, { observer }, 'down'); - - await makeChecksWithStatus(es, mixMonitorId, 1, 4, 1, {}, 'up'); - await makeChecksWithStatus(es, mixMonitorId, 1, 4, 1, { observer }, 'down'); - - dateRangeEnd = new Date().toISOString(); - }); - - after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank')); - - it('should return all monitor when no status filter', async () => { - const { monitorStates } = await getMonitorStates({}); - expect(monitorStates.summaries.length).to.eql(3); - // Summaries are by default sorted by monitor names - expect( - monitorStates.summaries.map((summary: MonitorSummary) => summary.monitor_id) - ).to.eql([downMonitorId, mixMonitorId, upMonitorId]); - }); - - it('should return a monitor with mix state if check status filter is down', async () => { - const { monitorStates } = await getMonitorStates({ statusFilter: 'down' }); - expect(monitorStates.summaries.length).to.eql(2); - monitorStates.summaries.forEach((summary: MonitorSummary) => { - expect(summary.monitor_id).to.not.eql(upMonitorId); - }); - }); - - it('should not return a monitor with mix state if check status filter is up', async () => { - const { monitorStates } = await getMonitorStates({ statusFilter: 'up' }); - - expect(monitorStates.summaries.length).to.eql(1); - expect(monitorStates.summaries[0].monitor_id).to.eql(upMonitorId); - }); - }); - }); -} diff --git a/x-pack/test/api_integration/apis/uptime/index.ts b/x-pack/test/api_integration/apis/uptime/index.ts index 8def64b71a110..13af60196f00d 100644 --- a/x-pack/test/api_integration/apis/uptime/index.ts +++ b/x-pack/test/api_integration/apis/uptime/index.ts @@ -20,7 +20,6 @@ export default function({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./feature_controls')); loadTestFile(require.resolve('./get_all_pings')); - loadTestFile(require.resolve('./graphql')); loadTestFile(require.resolve('./rest')); }); } diff --git a/x-pack/test/api_integration/apis/uptime/rest/certs.ts b/x-pack/test/api_integration/apis/uptime/rest/certs.ts new file mode 100644 index 0000000000000..7510ea3f34d28 --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/certs.ts @@ -0,0 +1,89 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import expect from '@kbn/expect'; +import moment from 'moment'; +import { isRight } from 'fp-ts/lib/Either'; +import { FtrProviderContext } from '../../../ftr_provider_context'; +import { API_URLS } from '../../../../../legacy/plugins/uptime/common/constants'; +import { CertType } from '../../../../../legacy/plugins/uptime/common/runtime_types'; +import { makeChecksWithStatus } from './helper/make_checks'; + +export default function({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const legacyEsService = getService('legacyEs'); + const esArchiver = getService('esArchiver'); + + describe('certs api', () => { + describe('empty index', async () => { + it('returns empty array for no data', async () => { + const apiResponse = await supertest.get(API_URLS.CERTS); + expect(JSON.stringify(apiResponse.body)).to.eql('{"certs":[]}'); + }); + }); + + describe('when data is present', async () => { + const now = moment(); + const cnva = now.add(6, 'months').toISOString(); + const cnvb = now.subtract(23, 'weeks').toISOString(); + const monitorId = 'monitor1'; + before(async () => { + makeChecksWithStatus( + legacyEsService, + monitorId, + 3, + 1, + 10000, + { + tls: { + certificate_not_valid_after: cnva, + certificate_not_valid_before: cnvb, + server: { + x509: { + issuer: { + common_name: 'issuer-common-name', + }, + subject: { + common_name: 'subject-common-name', + }, + }, + hash: { + sha1: 'fewjio23r3', + sha256: 'few9023fijoefw', + }, + }, + }, + }, + 'up', + (d: any) => d + ); + }); + after('unload test docs', () => { + esArchiver.unload('uptime/blank'); + }); + + it('retrieves expected cert data', async () => { + const apiResponse = await supertest.get(API_URLS.CERTS); + const { body } = apiResponse; + + expect(body.certs).not.to.be(undefined); + expect(Array.isArray(body.certs)).to.be(true); + expect(body.certs).to.have.length(1); + + const decoded = CertType.decode(body.certs[0]); + expect(isRight(decoded)).to.be(true); + + const cert = body.certs[0]; + expect(Array.isArray(cert.monitors)).to.be(true); + expect(cert.monitors[0]).to.eql({ id: monitorId }); + expect(cert.certificate_not_valid_after).to.eql(cnva); + expect(cert.certificate_not_valid_before).to.eql(cnvb); + expect(cert.common_name).to.eql('subject-common-name'); + expect(cert.issuer).to.eql('issuer-common-name'); + }); + }); + }); +} diff --git a/x-pack/test/api_integration/apis/uptime/rest/doc_count.ts b/x-pack/test/api_integration/apis/uptime/rest/doc_count.ts index 3f42511dd165c..5258426cf193c 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/doc_count.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/doc_count.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import { FtrProviderContext } from '../../../ftr_provider_context'; -import { expectFixtureEql } from '../graphql/helpers/expect_fixture_eql'; +import { expectFixtureEql } from './helper/expect_fixture_eql'; import { API_URLS } from '../../../../../legacy/plugins/uptime/common/constants'; export default function({ getService }: FtrProviderContext) { diff --git a/x-pack/test/api_integration/apis/uptime/rest/dynamic_settings.ts b/x-pack/test/api_integration/apis/uptime/rest/dynamic_settings.ts index f4dd7c244f8b5..a1b731169f0a0 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/dynamic_settings.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/dynamic_settings.ts @@ -18,7 +18,13 @@ export default function({ getService }: FtrProviderContext) { }); it('can change the settings', async () => { - const newSettings = { heartbeatIndices: 'myIndex1*' }; + const newSettings = { + heartbeatIndices: 'myIndex1*', + certificatesThresholds: { + errorState: 5, + warningState: 15, + }, + }; const postResponse = await supertest .post(`/api/uptime/dynamic_settings`) .set('kbn-xsrf', 'true') diff --git a/x-pack/test/api_integration/apis/uptime/rest/filters.ts b/x-pack/test/api_integration/apis/uptime/rest/filters.ts index 6cec6143a6d7c..35bf32a1d404d 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/filters.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/filters.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { expectFixtureEql } from '../graphql/helpers/expect_fixture_eql'; +import { expectFixtureEql } from './helper/expect_fixture_eql'; import { FtrProviderContext } from '../../../ftr_provider_context'; const getApiPath = (dateRangeStart: string, dateRangeEnd: string, filters?: string) => diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/filters.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/filters.json similarity index 100% rename from x-pack/test/api_integration/apis/uptime/graphql/fixtures/filters.json rename to x-pack/test/api_integration/apis/uptime/rest/fixtures/filters.json diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_status.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_status.json similarity index 100% rename from x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_status.json rename to x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_status.json diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_status_all.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_status_all.json similarity index 100% rename from x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitor_status_all.json rename to x-pack/test/api_integration/apis/uptime/rest/fixtures/monitor_status_all.json diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitors_with_location.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/monitors_with_location.json similarity index 100% rename from x-pack/test/api_integration/apis/uptime/graphql/fixtures/monitors_with_location.json rename to x-pack/test/api_integration/apis/uptime/rest/fixtures/monitors_with_location.json diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/snapshot.json similarity index 100% rename from x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot.json rename to x-pack/test/api_integration/apis/uptime/rest/fixtures/snapshot.json diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_empty.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/snapshot_empty.json similarity index 100% rename from x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_empty.json rename to x-pack/test/api_integration/apis/uptime/rest/fixtures/snapshot_empty.json diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_filtered_by_down.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/snapshot_filtered_by_down.json similarity index 100% rename from x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_filtered_by_down.json rename to x-pack/test/api_integration/apis/uptime/rest/fixtures/snapshot_filtered_by_down.json diff --git a/x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_filtered_by_up.json b/x-pack/test/api_integration/apis/uptime/rest/fixtures/snapshot_filtered_by_up.json similarity index 100% rename from x-pack/test/api_integration/apis/uptime/graphql/fixtures/snapshot_filtered_by_up.json rename to x-pack/test/api_integration/apis/uptime/rest/fixtures/snapshot_filtered_by_up.json diff --git a/x-pack/test/api_integration/apis/uptime/graphql/helpers/expect_fixture_eql.ts b/x-pack/test/api_integration/apis/uptime/rest/helper/expect_fixture_eql.ts similarity index 87% rename from x-pack/test/api_integration/apis/uptime/graphql/helpers/expect_fixture_eql.ts rename to x-pack/test/api_integration/apis/uptime/rest/helper/expect_fixture_eql.ts index d5a4f3976e079..abf5ec6f697b0 100644 --- a/x-pack/test/api_integration/apis/uptime/graphql/helpers/expect_fixture_eql.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/helper/expect_fixture_eql.ts @@ -10,7 +10,6 @@ import { join } from 'path'; import { cloneDeep, isEqual } from 'lodash'; const fixturesDir = join(__dirname, '..', 'fixtures'); -const restFixturesDir = join(__dirname, '../../rest/', 'fixtures'); const excludeFieldsFrom = (from: any, excluder?: (d: any) => any): any => { const clone = cloneDeep(from); @@ -24,10 +23,7 @@ export const expectFixtureEql = (data: T, fixtureName: string, excluder?: (d: expect(data).not.to.eql(null); expect(data).not.to.eql(undefined); - let fixturePath = join(fixturesDir, `${fixtureName}.json`); - if (!fs.existsSync(fixturePath)) { - fixturePath = join(restFixturesDir, `${fixtureName}.json`); - } + const fixturePath = join(fixturesDir, `${fixtureName}.json`); excluder = excluder || (d => d); const dataExcluded = excludeFieldsFrom(data, excluder); diff --git a/x-pack/test/api_integration/apis/uptime/graphql/helpers/make_checks.ts b/x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts similarity index 100% rename from x-pack/test/api_integration/apis/uptime/graphql/helpers/make_checks.ts rename to x-pack/test/api_integration/apis/uptime/rest/helper/make_checks.ts diff --git a/x-pack/test/api_integration/apis/uptime/rest/index.ts b/x-pack/test/api_integration/apis/uptime/rest/index.ts index 3f8df81856f5c..f77c14e960ab2 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/index.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/index.ts @@ -37,11 +37,13 @@ export default function({ getService, loadTestFile }: FtrProviderContext) { }); describe('with generated data', () => { - before('load heartbeat data', async () => await esArchiver.load('uptime/blank')); + beforeEach('load heartbeat data', async () => await esArchiver.loadIfNeeded('uptime/blank')); after('unload', async () => await esArchiver.unload('uptime/blank')); - loadTestFile(require.resolve('./snapshot')); + loadTestFile(require.resolve('./certs')); loadTestFile(require.resolve('./dynamic_settings')); + loadTestFile(require.resolve('./snapshot')); + loadTestFile(require.resolve('./monitor_states_generated')); loadTestFile(require.resolve('./telemetry_collectors')); }); describe('with real-world data', () => { @@ -52,6 +54,7 @@ export default function({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./ping_list')); loadTestFile(require.resolve('./monitor_duration')); loadTestFile(require.resolve('./doc_count')); + loadTestFile(require.resolve('./monitor_states_real_data')); }); }); } diff --git a/x-pack/test/api_integration/apis/uptime/rest/monitor_duration.ts b/x-pack/test/api_integration/apis/uptime/rest/monitor_duration.ts index acc50e9b8f3d6..7e93f9cfff8a1 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/monitor_duration.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/monitor_duration.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { expectFixtureEql } from '../graphql/helpers/expect_fixture_eql'; +import { expectFixtureEql } from './helper/expect_fixture_eql'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function({ getService }: FtrProviderContext) { diff --git a/x-pack/test/api_integration/apis/uptime/rest/monitor_latest_status.ts b/x-pack/test/api_integration/apis/uptime/rest/monitor_latest_status.ts index 749b304c87ee3..6547816bb7c16 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/monitor_latest_status.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/monitor_latest_status.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { expectFixtureEql } from '../graphql/helpers/expect_fixture_eql'; +import { expectFixtureEql } from './helper/expect_fixture_eql'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function({ getService }: FtrProviderContext) { diff --git a/x-pack/test/api_integration/apis/uptime/rest/monitor_states_generated.ts b/x-pack/test/api_integration/apis/uptime/rest/monitor_states_generated.ts new file mode 100644 index 0000000000000..3c17370532f91 --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/monitor_states_generated.ts @@ -0,0 +1,193 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; +import { makeChecksWithStatus } from './helper/make_checks'; +import { API_URLS } from '../../../../../legacy/plugins/uptime/common/constants'; +import { MonitorSummary } from '../../../../../legacy/plugins/uptime/common/runtime_types'; + +export default function({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + describe('monitor state scoping', async () => { + const numIps = 4; // Must be > 2 for IP uniqueness checks + + let dateRangeStart: string; + let dateRangeEnd: string; + + const getBaseUrl = (from: string, to: string) => + `${API_URLS.MONITOR_LIST}?dateRangeStart=${from}&dateRangeEnd=${to}&pageSize=10`; + + before('load heartbeat data', () => getService('esArchiver').load('uptime/blank')); + after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank')); + + describe('query document scoping with mismatched check statuses', async () => { + let checks: any[] = []; + let nonSummaryIp: string | null = null; + const testMonitorId = 'scope-test-id'; + const makeApiParams = (monitorId: string, filterClauses: any[] = []): any => { + return JSON.stringify({ + bool: { + filter: [{ match: { 'monitor.id': monitorId } }, ...filterClauses], + }, + }); + }; + + before(async () => { + const es = getService('legacyEs'); + dateRangeStart = new Date().toISOString(); + checks = await makeChecksWithStatus(es, testMonitorId, 1, numIps, 1, {}, 'up', d => { + // turn an all up status into having at least one down + if (d.summary) { + d.monitor.status = 'down'; + d.summary.up--; + d.summary.down++; + } + return d; + }); + + dateRangeEnd = new Date().toISOString(); + nonSummaryIp = checks[0][0].monitor.ip; + }); + + it('should return all IPs', async () => { + const filters = makeApiParams(testMonitorId); + const url = getBaseUrl(dateRangeStart, dateRangeEnd) + `&filters=${filters}`; + const apiResponse = await supertest.get(url); + const res = apiResponse.body; + + const uniqueIps = new Set(); + res.summaries[0].state.checks.forEach((c: any) => uniqueIps.add(c.monitor.ip)); + + expect(uniqueIps.size).to.eql(4); + }); + + it('should match non summary documents without a status filter', async () => { + const filters = makeApiParams(testMonitorId, [{ match: { 'monitor.ip': nonSummaryIp } }]); + + const url = getBaseUrl(dateRangeStart, dateRangeEnd) + `&filters=${filters}`; + const apiResponse = await supertest.get(url); + const nonSummaryRes = apiResponse.body; + expect(nonSummaryRes.summaries.length).to.eql(1); + }); + + it('should not match non summary documents if the check status does not match the document status', async () => { + const filters = makeApiParams(testMonitorId, [{ match: { 'monitor.ip': nonSummaryIp } }]); + const url = + getBaseUrl(dateRangeStart, dateRangeEnd) + `&filters=${filters}&statusFilter=down`; + + const apiResponse = await supertest.get(url); + const nonSummaryRes = apiResponse.body; + expect(nonSummaryRes.summaries.length).to.eql(0); + }); + + it('should not non match non summary documents if the check status does not match', async () => { + const filters = makeApiParams(testMonitorId, [{ match: { 'monitor.ip': nonSummaryIp } }]); + const url = + getBaseUrl(dateRangeStart, dateRangeEnd) + `&filters=${filters}&statusFilter=up`; + + const apiResponse = await supertest.get(url); + const nonSummaryRes = apiResponse.body; + expect(nonSummaryRes.summaries.length).to.eql(0); + }); + + describe('matching outside of the date range', async () => { + before('set date range to future', () => { + const futureDate = new Date(); + + // Set dateRangeStart to one day from now + futureDate.setDate(futureDate.getDate() + 1); + dateRangeStart = futureDate.toISOString(); + + // Set dateRangeStart to two days from now + futureDate.setDate(futureDate.getDate() + 1); + dateRangeEnd = futureDate.toISOString(); + }); + + it('should not match any documents', async () => { + const filters = makeApiParams(testMonitorId); + const url = + getBaseUrl(dateRangeStart, dateRangeEnd) + `&filters=${filters}&statusFilter=up`; + + const apiResponse = await supertest.get(url); + const nonSummaryRes = apiResponse.body; + expect(nonSummaryRes.summaries.length).to.eql(0); + }); + }); + }); + + describe('test status filter', async () => { + const upMonitorId = 'up-test-id'; + const downMonitorId = 'down-test-id'; + const mixMonitorId = 'mix-test-id'; + before('generate three monitors with up, down, mix state', async () => { + await getService('esArchiver').load('uptime/blank'); + + const es = getService('legacyEs'); + + const observer = { + geo: { + name: 'US-East', + location: '40.7128, -74.0060', + }, + }; + + // Generating three monitors each with two geo locations, + // One in a down state , + // One in an up state, + // One in a mix state + + dateRangeStart = new Date().toISOString(); + + await makeChecksWithStatus(es, upMonitorId, 1, 4, 1, {}, 'up'); + await makeChecksWithStatus(es, upMonitorId, 1, 4, 1, { observer }, 'up'); + + await makeChecksWithStatus(es, downMonitorId, 1, 4, 1, {}, 'down'); + await makeChecksWithStatus(es, downMonitorId, 1, 4, 1, { observer }, 'down'); + + await makeChecksWithStatus(es, mixMonitorId, 1, 4, 1, {}, 'up'); + await makeChecksWithStatus(es, mixMonitorId, 1, 4, 1, { observer }, 'down'); + + dateRangeEnd = new Date().toISOString(); + }); + + after('unload heartbeat index', () => getService('esArchiver').unload('uptime/blank')); + + it('should return all monitor when no status filter', async () => { + const apiResponse = await supertest.get(getBaseUrl(dateRangeStart, dateRangeEnd)); + const { summaries } = apiResponse.body; + expect(summaries.length).to.eql(3); + // Summaries are by default sorted by monitor names + expect(summaries.map((summary: MonitorSummary) => summary.monitor_id)).to.eql([ + downMonitorId, + mixMonitorId, + upMonitorId, + ]); + }); + + it('should return a monitor with mix state if check status filter is down', async () => { + const apiResponse = await supertest.get( + getBaseUrl(dateRangeStart, dateRangeEnd) + '&statusFilter=down' + ); + const { summaries } = apiResponse.body; + expect(summaries.length).to.eql(2); + summaries.forEach((summary: MonitorSummary) => { + expect(summary.monitor_id).to.not.eql(upMonitorId); + }); + }); + + it('should not return a monitor with mix state if check status filter is up', async () => { + const apiResponse = await supertest.get( + getBaseUrl(dateRangeStart, dateRangeEnd) + '&statusFilter=up' + ); + const { summaries } = apiResponse.body; + + expect(summaries.length).to.eql(1); + expect(summaries[0].monitor_id).to.eql(upMonitorId); + }); + }); + }); +} diff --git a/x-pack/test/api_integration/apis/uptime/rest/monitor_states_real_data.ts b/x-pack/test/api_integration/apis/uptime/rest/monitor_states_real_data.ts new file mode 100644 index 0000000000000..f1e37bff405fd --- /dev/null +++ b/x-pack/test/api_integration/apis/uptime/rest/monitor_states_real_data.ts @@ -0,0 +1,525 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import expect from '@kbn/expect'; +import { isRight } from 'fp-ts/lib/Either'; +import { FtrProviderContext } from '../../../ftr_provider_context'; +import { API_URLS } from '../../../../../legacy/plugins/uptime/common/constants'; +import { MonitorSummaryResultType } from '../../../../../legacy/plugins/uptime/common/runtime_types'; + +interface ExpectedMonitorStatesPage { + response: any; + statesIds: string[]; + statuses: string[]; + absFrom: number; + absTo: number; + size: number; + totalCount: number; + prevPagination: null | string; + nextPagination: null | string; +} + +type PendingExpectedMonitorStatesPage = Pick< + ExpectedMonitorStatesPage, + 'statesIds' | 'statuses' | 'prevPagination' | 'nextPagination' +>; + +const checkMonitorStatesResponse = ({ + response, + statesIds, + statuses, + absFrom, + absTo, + size, + totalCount, + prevPagination, + nextPagination, +}: ExpectedMonitorStatesPage) => { + const decoded = MonitorSummaryResultType.decode(response); + expect(isRight(decoded)).to.be.ok(); + if (isRight(decoded)) { + const { summaries, prevPagePagination, nextPagePagination, totalSummaryCount } = decoded.right; + expect(summaries).to.have.length(size); + expect(summaries?.map(s => s.monitor_id)).to.eql(statesIds); + expect( + summaries?.map(s => (s.state.summary?.up && !s.state.summary?.down ? 'up' : 'down')) + ).to.eql(statuses); + (summaries ?? []).forEach(s => { + expect(s.state.url.full).to.be.ok(); + expect(s.histogram?.count).to.be(20); + (s.histogram?.points ?? []).forEach(point => { + expect(point.timestamp).to.be.greaterThan(absFrom); + expect(point.timestamp).to.be.lessThan(absTo); + }); + }); + expect(totalSummaryCount).to.be(totalCount); + expect(prevPagePagination).to.be(prevPagination); + expect(nextPagePagination).to.eql(nextPagination); + } +}; + +export default function({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + describe('monitor states endpoint', () => { + const from = '2019-09-11T03:30:04.380Z'; + const to = '2019-09-11T03:40:34.410Z'; + const absFrom = new Date(from).valueOf(); + const absTo = new Date(to).valueOf(); + + it('will fetch monitor state data for the given filters and range', async () => { + const statusFilter = 'up'; + const size = 10; + const filters = + '{"bool":{"must":[{"match":{"monitor.id":{"query":"0002-up","operator":"and"}}}]}}'; + const apiResponse = await supertest.get( + `${API_URLS.MONITOR_LIST}?dateRangeStart=${from}&dateRangeEnd=${to}&statusFilter=${statusFilter}&filters=${filters}&pageSize=${size}` + ); + checkMonitorStatesResponse({ + response: apiResponse.body, + statesIds: ['0002-up'], + statuses: ['up'], + absFrom, + absTo, + size: 1, + totalCount: 2000, + prevPagination: null, + nextPagination: null, + }); + }); + + it('can navigate forward and backward using pagination', async () => { + const expectedResultsCount = 100; + const size = 10; + const expectedPageCount = expectedResultsCount / size; + const expectedNextResults: PendingExpectedMonitorStatesPage[] = [ + { + statesIds: [ + '0000-intermittent', + '0001-up', + '0002-up', + '0003-up', + '0004-up', + '0005-up', + '0006-up', + '0007-up', + '0008-up', + '0009-up', + ], + statuses: ['up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0009-up"}}', + prevPagination: null, + }, + { + statesIds: [ + '0010-down', + '0011-up', + '0012-up', + '0013-up', + '0014-up', + '0015-intermittent', + '0016-up', + '0017-up', + '0018-up', + '0019-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0019-up"}}', + prevPagination: + '{"cursorKey":{"monitor_id":"0010-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0020-down', + '0021-up', + '0022-up', + '0023-up', + '0024-up', + '0025-up', + '0026-up', + '0027-up', + '0028-up', + '0029-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0029-up"}}', + prevPagination: + '{"cursorKey":{"monitor_id":"0020-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0030-intermittent', + '0031-up', + '0032-up', + '0033-up', + '0034-up', + '0035-up', + '0036-up', + '0037-up', + '0038-up', + '0039-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0039-up"}}', + prevPagination: + '{"cursorKey":{"monitor_id":"0030-intermittent"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0040-down', + '0041-up', + '0042-up', + '0043-up', + '0044-up', + '0045-intermittent', + '0046-up', + '0047-up', + '0048-up', + '0049-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0049-up"}}', + prevPagination: + '{"cursorKey":{"monitor_id":"0040-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0050-down', + '0051-up', + '0052-up', + '0053-up', + '0054-up', + '0055-up', + '0056-up', + '0057-up', + '0058-up', + '0059-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0059-up"}}', + prevPagination: + '{"cursorKey":{"monitor_id":"0050-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0060-intermittent', + '0061-up', + '0062-up', + '0063-up', + '0064-up', + '0065-up', + '0066-up', + '0067-up', + '0068-up', + '0069-up', + ], + statuses: ['up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0069-up"}}', + prevPagination: + '{"cursorKey":{"monitor_id":"0060-intermittent"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0070-down', + '0071-up', + '0072-up', + '0073-up', + '0074-up', + '0075-intermittent', + '0076-up', + '0077-up', + '0078-up', + '0079-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0079-up"}}', + prevPagination: + '{"cursorKey":{"monitor_id":"0070-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0080-down', + '0081-up', + '0082-up', + '0083-up', + '0084-up', + '0085-up', + '0086-up', + '0087-up', + '0088-up', + '0089-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0089-up"}}', + prevPagination: + '{"cursorKey":{"monitor_id":"0080-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0090-intermittent', + '0091-up', + '0092-up', + '0093-up', + '0094-up', + '0095-up', + '0096-up', + '0097-up', + '0098-up', + '0099-up', + ], + statuses: ['up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: null, + prevPagination: + '{"cursorKey":{"monitor_id":"0090-intermittent"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + ]; + + const expectedPrevResults: PendingExpectedMonitorStatesPage[] = [ + { + statesIds: [ + '0000-intermittent', + '0001-up', + '0002-up', + '0003-up', + '0004-up', + '0005-up', + '0006-up', + '0007-up', + '0008-up', + '0009-up', + ], + statuses: ['up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorKey":{"monitor_id":"0009-up"},"sortOrder":"ASC","cursorDirection":"AFTER"}', + prevPagination: null, + }, + { + statesIds: [ + '0010-down', + '0011-up', + '0012-up', + '0013-up', + '0014-up', + '0015-intermittent', + '0016-up', + '0017-up', + '0018-up', + '0019-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorKey":{"monitor_id":"0019-up"},"sortOrder":"ASC","cursorDirection":"AFTER"}', + prevPagination: + '{"cursorKey":{"monitor_id":"0010-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0020-down', + '0021-up', + '0022-up', + '0023-up', + '0024-up', + '0025-up', + '0026-up', + '0027-up', + '0028-up', + '0029-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorKey":{"monitor_id":"0029-up"},"sortOrder":"ASC","cursorDirection":"AFTER"}', + prevPagination: + '{"cursorKey":{"monitor_id":"0020-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0030-intermittent', + '0031-up', + '0032-up', + '0033-up', + '0034-up', + '0035-up', + '0036-up', + '0037-up', + '0038-up', + '0039-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorKey":{"monitor_id":"0039-up"},"sortOrder":"ASC","cursorDirection":"AFTER"}', + prevPagination: + '{"cursorKey":{"monitor_id":"0030-intermittent"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0040-down', + '0041-up', + '0042-up', + '0043-up', + '0044-up', + '0045-intermittent', + '0046-up', + '0047-up', + '0048-up', + '0049-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorKey":{"monitor_id":"0049-up"},"sortOrder":"ASC","cursorDirection":"AFTER"}', + prevPagination: + '{"cursorKey":{"monitor_id":"0040-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0050-down', + '0051-up', + '0052-up', + '0053-up', + '0054-up', + '0055-up', + '0056-up', + '0057-up', + '0058-up', + '0059-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorKey":{"monitor_id":"0059-up"},"sortOrder":"ASC","cursorDirection":"AFTER"}', + prevPagination: + '{"cursorKey":{"monitor_id":"0050-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0060-intermittent', + '0061-up', + '0062-up', + '0063-up', + '0064-up', + '0065-up', + '0066-up', + '0067-up', + '0068-up', + '0069-up', + ], + statuses: ['up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorKey":{"monitor_id":"0069-up"},"sortOrder":"ASC","cursorDirection":"AFTER"}', + prevPagination: + '{"cursorKey":{"monitor_id":"0060-intermittent"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0070-down', + '0071-up', + '0072-up', + '0073-up', + '0074-up', + '0075-intermittent', + '0076-up', + '0077-up', + '0078-up', + '0079-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorKey":{"monitor_id":"0079-up"},"sortOrder":"ASC","cursorDirection":"AFTER"}', + prevPagination: + '{"cursorKey":{"monitor_id":"0070-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + { + statesIds: [ + '0080-down', + '0081-up', + '0082-up', + '0083-up', + '0084-up', + '0085-up', + '0086-up', + '0087-up', + '0088-up', + '0089-up', + ], + statuses: ['down', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + nextPagination: + '{"cursorKey":{"monitor_id":"0089-up"},"sortOrder":"ASC","cursorDirection":"AFTER"}', + prevPagination: + '{"cursorKey":{"monitor_id":"0080-down"},"sortOrder":"ASC","cursorDirection":"BEFORE"}', + }, + ]; + + const totalCount = 2000; + let pagination: string | null = null; + for (let page = 1; page <= expectedPageCount; page++) { + const baseUrl = `${API_URLS.MONITOR_LIST}?dateRangeStart=${from}&dateRangeEnd=${to}&pageSize=${size}`; + const nextUrl: string = baseUrl + `&pagination=${pagination ?? ''}`; + const nextApiResponse = await supertest.get(nextUrl); + const nextData = nextApiResponse.body; + pagination = nextData.nextPagePagination; + checkMonitorStatesResponse({ + response: nextData, + ...expectedNextResults[page - 1], + absFrom, + absTo, + size, + totalCount, + }); + + // Test to see if the previous page pagination works on every page (other than the first) + if (page > 1) { + const prevUrl: string = baseUrl + `&pagination=${nextData.prevPagePagination}`; + const prevApiResponse = await supertest.get(prevUrl); + const prevData = prevApiResponse.body; + checkMonitorStatesResponse({ + response: prevData, + ...expectedPrevResults[page - 2], + absFrom, + absTo, + size, + totalCount, + }); + } + } + }); + + it('will fetch monitor state data for the given date range', async () => { + const LENGTH = 10; + const { body } = await supertest.get( + `${API_URLS.MONITOR_LIST}?dateRangeStart=${from}&dateRangeEnd=${to}&pageSize=${LENGTH}` + ); + checkMonitorStatesResponse({ + response: body, + statesIds: [ + '0000-intermittent', + '0001-up', + '0002-up', + '0003-up', + '0004-up', + '0005-up', + '0006-up', + '0007-up', + '0008-up', + '0009-up', + ], + statuses: ['up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up', 'up'], + absFrom, + absTo, + size: LENGTH, + totalCount: 2000, + prevPagination: null, + nextPagination: + '{"cursorDirection":"AFTER","sortOrder":"ASC","cursorKey":{"monitor_id":"0009-up"}}', + }); + }); + }); +} diff --git a/x-pack/test/api_integration/apis/uptime/rest/ping_histogram.ts b/x-pack/test/api_integration/apis/uptime/rest/ping_histogram.ts index 0982d5fef7cb4..b1afe4c8e0d7d 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/ping_histogram.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/ping_histogram.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { expectFixtureEql } from '../graphql/helpers/expect_fixture_eql'; +import { expectFixtureEql } from './helper/expect_fixture_eql'; import { FtrProviderContext } from '../../../ftr_provider_context'; import { assertCloseTo } from '../../../../../plugins/uptime/server/lib/helper'; diff --git a/x-pack/test/api_integration/apis/uptime/rest/snapshot.ts b/x-pack/test/api_integration/apis/uptime/rest/snapshot.ts index 20fe59d149ae8..9a8951741948e 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/snapshot.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/snapshot.ts @@ -4,9 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { expectFixtureEql } from '../graphql/helpers/expect_fixture_eql'; +import { expectFixtureEql } from './helper/expect_fixture_eql'; import { FtrProviderContext } from '../../../ftr_provider_context'; -import { makeChecksWithStatus, getChecksDateRange } from '../graphql/helpers/make_checks'; +import { makeChecksWithStatus, getChecksDateRange } from './helper/make_checks'; export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); diff --git a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts index b2ec96be0f288..017ef02afe5ea 100644 --- a/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts +++ b/x-pack/test/api_integration/apis/uptime/rest/telemetry_collectors.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; import { API_URLS } from '../../../../../legacy/plugins/uptime/common/constants'; -import { makeChecksWithStatus } from '../graphql/helpers/make_checks'; +import { makeChecksWithStatus } from './helper/make_checks'; export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); diff --git a/x-pack/test/api_integration/services/index.ts b/x-pack/test/api_integration/services/index.ts index 9c945f557a2d8..84b8476bd1dd1 100644 --- a/x-pack/test/api_integration/services/index.ts +++ b/x-pack/test/api_integration/services/index.ts @@ -22,6 +22,7 @@ import { import { SiemGraphQLClientProvider, SiemGraphQLClientFactoryProvider } from './siem_graphql_client'; import { InfraOpsSourceConfigurationProvider } from './infraops_source_configuration'; import { MachineLearningProvider } from './ml'; +import { IngestManagerProvider } from './ingest_manager'; export const services = { ...commonServices, @@ -39,4 +40,5 @@ export const services = { supertestWithoutAuth: SupertestWithoutAuthProvider, usageAPI: UsageAPIProvider, ml: MachineLearningProvider, + ingestManager: IngestManagerProvider, }; diff --git a/x-pack/test/api_integration/services/ingest_manager.ts b/x-pack/test/api_integration/services/ingest_manager.ts new file mode 100644 index 0000000000000..2b70a20ca0362 --- /dev/null +++ b/x-pack/test/api_integration/services/ingest_manager.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { FtrProviderContext } from '../ftr_provider_context'; +import { setupRouteService, fleetSetupRouteService } from '../../../plugins/ingest_manager/common'; + +export function IngestManagerProvider({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + return { + async setup() { + const headers = { accept: 'application/json', 'kbn-xsrf': 'some-xsrf-token' }; + + const { body } = await supertest + .get(fleetSetupRouteService.getFleetSetupPath()) + .set(headers) + .expect(200); + + if (!body.isInitialized) { + await supertest + .post(setupRouteService.getSetupPath()) + .set(headers) + .expect(200); + } + }, + }; +} diff --git a/x-pack/test/api_integration/services/ml.ts b/x-pack/test/api_integration/services/ml.ts index 841b200b87080..c295af7dc73ab 100644 --- a/x-pack/test/api_integration/services/ml.ts +++ b/x-pack/test/api_integration/services/ml.ts @@ -9,14 +9,17 @@ import { FtrProviderContext } from '../../functional/ftr_provider_context'; import { MachineLearningAPIProvider, MachineLearningSecurityCommonProvider, + MachineLearningTestResourcesProvider, } from '../../functional/services/machine_learning'; export function MachineLearningProvider(context: FtrProviderContext) { const api = MachineLearningAPIProvider(context); const securityCommon = MachineLearningSecurityCommonProvider(context); + const testResources = MachineLearningTestResourcesProvider(context); return { api, securityCommon, + testResources, }; } diff --git a/x-pack/test/detection_engine_api_integration/common/config.ts b/x-pack/test/detection_engine_api_integration/common/config.ts index 89ebd902834b9..e89352118990a 100644 --- a/x-pack/test/detection_engine_api_integration/common/config.ts +++ b/x-pack/test/detection_engine_api_integration/common/config.ts @@ -8,7 +8,7 @@ import path from 'path'; import { CA_CERT_PATH } from '@kbn/dev-utils'; import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; import { services } from './services'; -import { listsEnvFeatureFlagName } from '../../../legacy/plugins/siem/server/lib/detection_engine/feature_flags'; +import { listsEnvFeatureFlagName } from '../../../plugins/siem/server/lib/detection_engine/feature_flags'; interface CreateTestConfigOptions { license: string; diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_prepackaged_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_prepackaged_rules.ts index 6ee65d5d28aa4..e787a3594dfe6 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_prepackaged_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/add_prepackaged_rules.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_PREPACKAGED_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_PREPACKAGED_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, deleteAllAlerts, deleteSignalsIndex } from './utils'; diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts index 91088acb7a51c..46645a9b5a944 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts index 8e951a31b525c..117300be417d5 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/create_rules_bulk.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules.ts index a886a5fb07a6c..fb701681419d8 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules_bulk.ts index 9e9071b82884f..ac58ba4c77e4e 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/delete_rules_bulk.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/export_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/export_rules.ts index a8f841db94bbc..51bdb9e45dc0c 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/export_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/export_rules.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { binaryToString, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_rules.ts index abbc8f77e0077..feb4ecd125f7e 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_rules.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts index 45805f03f8c0c..44847d5c8146c 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/find_statuses.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, @@ -50,17 +50,18 @@ export default ({ getService }: FtrProviderContext): void => { .send(getSimpleRule()) .expect(200); - await new Promise(resolve => setTimeout(resolve, 1000)).then(async () => { - // query the single rule from _find - const { body } = await supertest - .post(`${DETECTION_ENGINE_RULES_URL}/_find_statuses`) - .set('kbn-xsrf', 'true') - .send({ ids: [resBody.id] }) - .expect(200); + // wait for Task Manager to execute the rule and update status + await new Promise(resolve => setTimeout(resolve, 5000)); - // expected result for status should be 'going to run' or 'succeeded - expect(['succeeded', 'going to run']).to.contain(body[resBody.id].current_status.status); - }); + // query the single rule from _find + const { body } = await supertest + .post(`${DETECTION_ENGINE_RULES_URL}/_find_statuses`) + .set('kbn-xsrf', 'true') + .send({ ids: [resBody.id] }) + .expect(200); + + // expected result for status should be 'going to run' or 'succeeded + expect(['succeeded', 'going to run']).to.contain(body[resBody.id].current_status.status); }); }); }; diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_prepackaged_rules_status.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_prepackaged_rules_status.ts index 49cf150126fda..e2dce77c1d70a 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_prepackaged_rules_status.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/get_prepackaged_rules_status.ts @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; import { DETECTION_ENGINE_PREPACKAGED_URL, DETECTION_ENGINE_RULES_URL, -} from '../../../../legacy/plugins/siem/common/constants'; +} from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, deleteAllAlerts, deleteSignalsIndex, getSimpleRule } from './utils'; diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/import_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/import_rules.ts index ae4589e32ec11..4def508fabbc3 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/import_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/import_rules.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts index e9e3e4299d108..3c8c20646885a 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/open_close_signals.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_SIGNALS_STATUS_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_SIGNALS_STATUS_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules.ts index 53a3d15690efc..c3ecf79e58955 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules_bulk.ts index c13e8909dacf9..8515d1cf404ea 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/patch_rules_bulk.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/query_signals.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/query_signals.ts index 6fa62412ed467..7c8bd8981db10 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/query_signals.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/query_signals.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_QUERY_SIGNALS_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_QUERY_SIGNALS_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { getSignalStatus, createSignalsIndex, deleteSignalsIndex } from './utils'; diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/read_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/read_rules.ts index 2ea62b0756f73..4d7449dae2dbd 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/read_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/read_rules.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts index 92c78be72bf01..4b81b7d4304b2 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts index 220a4af4c5c5e..760e17ae1752e 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/update_rules_bulk.ts @@ -6,7 +6,7 @@ import expect from '@kbn/expect'; -import { DETECTION_ENGINE_RULES_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { DETECTION_ENGINE_RULES_URL } from '../../../../plugins/siem/common/constants'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { createSignalsIndex, diff --git a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/utils.ts b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/utils.ts index 0a5b2def3eb18..e508cf1aaa2e0 100644 --- a/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/utils.ts +++ b/x-pack/test/detection_engine_api_integration/security_and_spaces/tests/utils.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { OutputRuleAlertRest } from '../../../../legacy/plugins/siem/server/lib/detection_engine/types'; -import { DETECTION_ENGINE_INDEX_URL } from '../../../../legacy/plugins/siem/common/constants'; +import { OutputRuleAlertRest } from '../../../../plugins/siem/server/lib/detection_engine/types'; +import { DETECTION_ENGINE_INDEX_URL } from '../../../../plugins/siem/common/constants'; /** * This will remove server generated properties such as date times, etc... @@ -154,7 +154,7 @@ export const getSimpleRuleOutput = (ruleId = 'rule-1'): Partial = core.savedObjects.registerType({ name: SAVED_OBJECT_WITH_SECRET_TYPE, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: deepFreeze({ properties: { publicProperty: { type: 'keyword' }, diff --git a/x-pack/test/endpoint_api_integration_no_ingest/apis/alerts.ts b/x-pack/test/endpoint_api_integration_no_ingest/apis/alerts.ts new file mode 100644 index 0000000000000..b75d69238d653 --- /dev/null +++ b/x-pack/test/endpoint_api_integration_no_ingest/apis/alerts.ts @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { FtrProviderContext } from '../ftr_provider_context'; + +export default function({ getService }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const supertest = getService('supertest'); + + describe('Endpoint alert API without ingest manager initialized', () => { + before(async () => { + await esArchiver.load('endpoint/alerts/api_feature'); + await esArchiver.load('endpoint/alerts/host_api_feature'); + }); + + after(async () => { + await esArchiver.unload('endpoint/alerts/api_feature'); + await esArchiver.unload('endpoint/alerts/host_api_feature'); + }); + + it('should return a 500', async () => { + await supertest.get('/api/endpoint/alerts').expect(500); + }); + }); +} diff --git a/x-pack/test/endpoint_api_integration_no_ingest/apis/index.ts b/x-pack/test/endpoint_api_integration_no_ingest/apis/index.ts new file mode 100644 index 0000000000000..6110f398df5a0 --- /dev/null +++ b/x-pack/test/endpoint_api_integration_no_ingest/apis/index.ts @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { FtrProviderContext } from '../ftr_provider_context'; + +export default function endpointAPIIntegrationTests({ loadTestFile }: FtrProviderContext) { + describe('Endpoint plugin', function() { + this.tags('ciGroup7'); + loadTestFile(require.resolve('./index_pattern')); + loadTestFile(require.resolve('./metadata')); + loadTestFile(require.resolve('./alerts')); + }); +} diff --git a/x-pack/test/endpoint_api_integration_no_ingest/apis/index_pattern.ts b/x-pack/test/endpoint_api_integration_no_ingest/apis/index_pattern.ts new file mode 100644 index 0000000000000..664ef7d96847c --- /dev/null +++ b/x-pack/test/endpoint_api_integration_no_ingest/apis/index_pattern.ts @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { FtrProviderContext } from '../ftr_provider_context'; + +export default function({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + + describe('Endpoint index pattern API without ingest manager initialized', () => { + it('should not retrieve the index pattern for events', async () => { + await supertest.get('/api/endpoint/index_pattern/events').expect(404); + }); + }); +} diff --git a/x-pack/test/endpoint_api_integration_no_ingest/apis/metadata.ts b/x-pack/test/endpoint_api_integration_no_ingest/apis/metadata.ts new file mode 100644 index 0000000000000..886d3cf3d9516 --- /dev/null +++ b/x-pack/test/endpoint_api_integration_no_ingest/apis/metadata.ts @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { FtrProviderContext } from '../ftr_provider_context'; + +export default function({ getService }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); + const supertest = getService('supertest'); + describe('test metadata api when ingest manager is not initialized', () => { + before(async () => await esArchiver.load('endpoint/metadata/api_feature')); + after(async () => await esArchiver.unload('endpoint/metadata/api_feature')); + it('metadata api should return a 500', async () => { + await supertest + .post('/api/endpoint/metadata') + .set('kbn-xsrf', 'xxx') + .send() + .expect(500); + }); + }); +} diff --git a/x-pack/test/endpoint_api_integration_no_ingest/config.ts b/x-pack/test/endpoint_api_integration_no_ingest/config.ts new file mode 100644 index 0000000000000..bf8b68a7e991c --- /dev/null +++ b/x-pack/test/endpoint_api_integration_no_ingest/config.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; + +export default async function({ readConfigFile }: FtrConfigProviderContext) { + const xPackAPITestsConfig = await readConfigFile(require.resolve('../api_integration/config.js')); + + return { + ...xPackAPITestsConfig.getAll(), + testFiles: [require.resolve('./apis')], + junit: { + reportName: 'X-Pack Endpoint API Integration Without Ingest Tests', + }, + }; +} diff --git a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/index.ts b/x-pack/test/endpoint_api_integration_no_ingest/ftr_provider_context.d.ts similarity index 54% rename from x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/index.ts rename to x-pack/test/endpoint_api_integration_no_ingest/ftr_provider_context.d.ts index ac77aa5268660..2751dbcdc6539 100644 --- a/x-pack/plugins/snapshot_restore/public/application/lib/authorization/components/index.ts +++ b/x-pack/test/endpoint_api_integration_no_ingest/ftr_provider_context.d.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -export { AuthorizationProvider, AuthorizationContext } from './authorization_provider'; +import { GenericFtrProviderContext } from '@kbn/test/types/ftr'; -export { WithPrivileges } from './with_privileges'; +import { services } from '../api_integration/services'; -export { NotAuthorizedSection } from './not_authorized_section'; +export type FtrProviderContext = GenericFtrProviderContext; diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/advanced_job.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/advanced_job.ts index 53b1cb83c524b..a5faf325aa6cb 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/advanced_job.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/advanced_job.ts @@ -110,13 +110,13 @@ export default function({ getService }: FtrProviderContext) { const testDataList = [ { suiteTitle: 'with multiple metric detectors and custom datafeed settings', - jobSource: 'ecommerce', + jobSource: 'ft_ecommerce', jobId: `ec_advanced_1_${Date.now()}`, get jobIdClone(): string { return `${this.jobId}_clone`; }, jobDescription: - 'Create advanced job from ecommerce dataset with multiple metric detectors and custom datafeed settings', + 'Create advanced job from ft_ecommerce dataset with multiple metric detectors and custom datafeed settings', jobGroups: ['automated', 'ecommerce', 'advanced'], get jobGroupsClone(): string[] { return [...this.jobGroups, 'clone']; @@ -207,13 +207,13 @@ export default function({ getService }: FtrProviderContext) { }, { suiteTitle: 'with categorization detector and default datafeed settings', - jobSource: 'ecommerce', + jobSource: 'ft_ecommerce', jobId: `ec_advanced_2_${Date.now()}`, get jobIdClone(): string { return `${this.jobId}_clone`; }, jobDescription: - 'Create advanced job from ecommerce dataset with a categorization detector and default datafeed settings', + 'Create advanced job from ft_ecommerce dataset with a categorization detector and default datafeed settings', jobGroups: ['automated', 'ecommerce', 'advanced'], get jobGroupsClone(): string[] { return [...this.jobGroups, 'clone']; @@ -274,16 +274,20 @@ export default function({ getService }: FtrProviderContext) { }, ]; + const calendarId = `wizard-test-calendar_${Date.now()}`; + describe('advanced job', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/ecommerce'); - await ml.api.createCalendar('wizard-test-calendar'); + await esArchiver.loadIfNeeded('ml/ecommerce'); + await ml.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); + await ml.testResources.setKibanaTimeZoneToUTC(); + + await ml.api.createCalendar(calendarId); await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { - await esArchiver.unload('ml/ecommerce'); await ml.api.cleanMlIndices(); }); @@ -475,7 +479,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job creation assigns calendars', async () => { - await ml.jobWizardCommon.addCalendar('wizard-test-calendar'); + await ml.jobWizardCommon.addCalendar(calendarId); }); it('job creation displays the model plot switch', async () => { @@ -734,7 +738,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job cloning persists assigned calendars', async () => { - await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']); + await ml.jobWizardCommon.assertCalendarsSelection([calendarId]); }); it('job cloning pre-fills the model plot switch', async () => { diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/anomaly_explorer.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/anomaly_explorer.ts index 83e9c01a46319..8827559a5f470 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/anomaly_explorer.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/anomaly_explorer.ts @@ -29,7 +29,7 @@ const JOB_CONFIG: Job = { const DATAFEED_CONFIG: Datafeed = { datafeed_id: 'datafeed-fq_multi_1_se', - indices: ['farequote'], + indices: ['ft_farequote'], job_id: 'fq_multi_1_ae', query: { bool: { must: [{ match_all: {} }] } }, }; @@ -59,12 +59,11 @@ export default function({ getService }: FtrProviderContext) { describe('anomaly explorer', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/farequote'); - await ml.securityUI.loginAsMlPowerUser(); - }); + await esArchiver.loadIfNeeded('ml/farequote'); + await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); + await ml.testResources.setKibanaTimeZoneToUTC(); - after(async () => { - await esArchiver.unload('ml/farequote'); + await ml.securityUI.loginAsMlPowerUser(); }); for (const testData of testDataList) { diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/categorization_job.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/categorization_job.ts index 6408c6de1f928..9b5ae171d4115 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/categorization_job.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/categorization_job.ts @@ -16,7 +16,7 @@ export default function({ getService }: FtrProviderContext) { const jobId = `categorization_${Date.now()}`; const jobIdClone = `${jobId}_clone`; const jobDescription = - 'Create categorization job based on the categorization_functional_test dataset with a count rare'; + 'Create categorization job based on the ft_categorization dataset with a count rare'; const jobGroups = ['automated', 'categorization']; const jobGroupsClone = [...jobGroups, 'clone']; const detectorTypeIdentifier = 'Rare'; @@ -74,16 +74,20 @@ export default function({ getService }: FtrProviderContext) { }; } + const calendarId = `wizard-test-calendar_${Date.now()}`; + describe('categorization', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/categorization'); - await ml.api.createCalendar('wizard-test-calendar'); + await esArchiver.loadIfNeeded('ml/categorization'); + await ml.testResources.createIndexPatternIfNeeded('ft_categorization', '@timestamp'); + await ml.testResources.setKibanaTimeZoneToUTC(); + + await ml.api.createCalendar(calendarId); await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { - await esArchiver.unload('ml/categorization'); await ml.api.cleanMlIndices(); }); @@ -97,9 +101,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job creation loads the job type selection page', async () => { - await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob( - 'categorization_functional_test' - ); + await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ft_categorization'); }); it('job creation loads the categorization job wizard page', async () => { @@ -178,7 +180,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job creation assigns calendars', async () => { - await ml.jobWizardCommon.addCalendar('wizard-test-calendar'); + await ml.jobWizardCommon.addCalendar(calendarId); }); it('job creation opens the advanced section', async () => { @@ -310,7 +312,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job cloning persists assigned calendars', async () => { - await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']); + await ml.jobWizardCommon.assertCalendarsSelection([calendarId]); }); it('job cloning opens the advanced section', async () => { diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/date_nanos_job.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/date_nanos_job.ts index 2a9824f46778d..570deee01c684 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/date_nanos_job.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/date_nanos_job.ts @@ -104,7 +104,7 @@ export default function({ getService }: FtrProviderContext) { const testDataList = [ { suiteTitle: 'with count detector and model plot disabled', - jobSource: 'event_rate_gen_trend_nanos', + jobSource: 'ft_event_rate_gen_trend_nanos', jobId: `event_rate_nanos_count_1_${Date.now()}`, jobDescription: 'Create advanced job based on the event rate dataset with a date_nanos time field, 30m bucketspan and count', @@ -168,12 +168,18 @@ export default function({ getService }: FtrProviderContext) { describe('job on data set with date_nanos time field', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/event_rate_nanos'); + await esArchiver.loadIfNeeded('ml/event_rate_nanos'); + await ml.testResources.createIndexPatternIfNeeded( + 'ft_event_rate_gen_trend_nanos', + '@timestamp' + ); + await ml.testResources.setKibanaTimeZoneToUTC(); + + await esArchiver.loadIfNeeded('ml/event_rate_nanos'); await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { - await esArchiver.unload('ml/event_rate_nanos'); await ml.api.cleanMlIndices(); }); diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/multi_metric_job.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/multi_metric_job.ts index 08175b7946259..4739f987541d6 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/multi_metric_job.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/multi_metric_job.ts @@ -71,16 +71,20 @@ export default function({ getService }: FtrProviderContext) { }; } + const calendarId = `wizard-test-calendar_${Date.now()}`; + describe('multi metric', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/farequote'); - await ml.api.createCalendar('wizard-test-calendar'); + await esArchiver.loadIfNeeded('ml/farequote'); + await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); + await ml.testResources.setKibanaTimeZoneToUTC(); + + await ml.api.createCalendar(calendarId); await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { - await esArchiver.unload('ml/farequote'); await ml.api.cleanMlIndices(); }); @@ -94,7 +98,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job creation loads the job type selection page', async () => { - await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('farequote'); + await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ft_farequote'); }); it('job creation loads the multi metric job wizard page', async () => { @@ -181,7 +185,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job creation assigns calendars', async () => { - await ml.jobWizardCommon.addCalendar('wizard-test-calendar'); + await ml.jobWizardCommon.addCalendar(calendarId); }); it('job creation opens the advanced section', async () => { @@ -329,7 +333,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job cloning persists assigned calendars', async () => { - await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']); + await ml.jobWizardCommon.assertCalendarsSelection([calendarId]); }); it('job cloning opens the advanced section', async () => { diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/population_job.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/population_job.ts index 512d13307ea05..0279c70bb73a9 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/population_job.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/population_job.ts @@ -85,16 +85,20 @@ export default function({ getService }: FtrProviderContext) { }; } + const calendarId = `wizard-test-calendar_${Date.now()}`; + describe('population', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/ecommerce'); - await ml.api.createCalendar('wizard-test-calendar'); + await esArchiver.loadIfNeeded('ml/ecommerce'); + await ml.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); + await ml.testResources.setKibanaTimeZoneToUTC(); + + await ml.api.createCalendar(calendarId); await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { - await esArchiver.unload('ml/farequote'); await ml.api.cleanMlIndices(); }); @@ -108,7 +112,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job creation loads the job type selection page', async () => { - await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ecommerce'); + await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ft_ecommerce'); }); it('job creation loads the population job wizard page', async () => { @@ -208,7 +212,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job creation assigns calendars', async () => { - await ml.jobWizardCommon.addCalendar('wizard-test-calendar'); + await ml.jobWizardCommon.addCalendar(calendarId); }); it('job creation opens the advanced section', async () => { @@ -367,7 +371,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job cloning persists assigned calendars', async () => { - await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']); + await ml.jobWizardCommon.assertCalendarsSelection([calendarId]); }); it('job cloning opens the advanced section', async () => { diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job.ts index a13cf3d61128e..a5652d76358eb 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job.ts @@ -15,7 +15,7 @@ export default function({ getService }: FtrProviderContext) { const testDataList = [ { suiteTitle: 'with filter', - jobSource: 'farequote_filter', + jobSource: 'ft_farequote_filter', jobId: `fq_saved_search_1_${Date.now()}`, jobDescription: 'Create multi metric job based on a saved search with filter', jobGroups: ['automated', 'farequote', 'multi-metric', 'saved-search'], @@ -66,7 +66,7 @@ export default function({ getService }: FtrProviderContext) { }, { suiteTitle: 'with lucene query', - jobSource: 'farequote_lucene', + jobSource: 'ft_farequote_lucene', jobId: `fq_saved_search_2_${Date.now()}`, jobDescription: 'Create multi metric job based on a saved search with lucene query', jobGroups: ['automated', 'farequote', 'multi-metric', 'saved-search'], @@ -117,7 +117,7 @@ export default function({ getService }: FtrProviderContext) { }, { suiteTitle: 'with kuery query', - jobSource: 'farequote_kuery', + jobSource: 'ft_farequote_kuery', jobId: `fq_saved_search_3_${Date.now()}`, jobDescription: 'Create multi metric job based on a saved search with kuery query', jobGroups: ['automated', 'farequote', 'multi-metric', 'saved-search'], @@ -168,7 +168,7 @@ export default function({ getService }: FtrProviderContext) { }, { suiteTitle: 'with filter and lucene query', - jobSource: 'farequote_filter_and_lucene', + jobSource: 'ft_farequote_filter_and_lucene', jobId: `fq_saved_search_4_${Date.now()}`, jobDescription: 'Create multi metric job based on a saved search with filter and lucene query', @@ -220,7 +220,7 @@ export default function({ getService }: FtrProviderContext) { }, { suiteTitle: 'with filter and kuery query', - jobSource: 'farequote_filter_and_kuery', + jobSource: 'ft_farequote_filter_and_kuery', jobId: `fq_saved_search_5_${Date.now()}`, jobDescription: 'Create multi metric job based on a saved search with filter and kuery query', jobGroups: ['automated', 'farequote', 'multi-metric', 'saved-search'], @@ -274,12 +274,19 @@ export default function({ getService }: FtrProviderContext) { describe('saved search', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/farequote'); + await esArchiver.loadIfNeeded('ml/farequote'); + await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); + await ml.testResources.createSavedSearchFarequoteFilterIfNeeded(); + await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded(); + await ml.testResources.createSavedSearchFarequoteKueryIfNeeded(); + await ml.testResources.createSavedSearchFarequoteFilterAndLuceneIfNeeded(); + await ml.testResources.createSavedSearchFarequoteFilterAndKueryIfNeeded(); + await ml.testResources.setKibanaTimeZoneToUTC(); + await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { - await esArchiver.unload('ml/farequote'); await ml.api.cleanMlIndices(); }); diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/single_metric_job.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/single_metric_job.ts index 4e6d480c12d82..43053decb3924 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/single_metric_job.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/single_metric_job.ts @@ -70,16 +70,20 @@ export default function({ getService }: FtrProviderContext) { }; } + const calendarId = `wizard-test-calendar_${Date.now()}`; + describe('single metric', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/farequote'); - await ml.api.createCalendar('wizard-test-calendar'); + await esArchiver.loadIfNeeded('ml/farequote'); + await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); + await ml.testResources.setKibanaTimeZoneToUTC(); + + await ml.api.createCalendar(calendarId); await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { - await esArchiver.unload('ml/farequote'); await ml.api.cleanMlIndices(); }); @@ -93,7 +97,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job creation loads the job type selection page', async () => { - await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('farequote'); + await ml.jobSourceSelection.selectSourceForAnomalyDetectionJob('ft_farequote'); }); it('job creation loads the single metric job wizard page', async () => { @@ -162,7 +166,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job creation assigns calendars', async () => { - await ml.jobWizardCommon.addCalendar('wizard-test-calendar'); + await ml.jobWizardCommon.addCalendar(calendarId); }); it('job creation opens the advanced section', async () => { @@ -294,7 +298,7 @@ export default function({ getService }: FtrProviderContext) { }); it('job cloning persists assigned calendars', async () => { - await ml.jobWizardCommon.assertCalendarsSelection(['wizard-test-calendar']); + await ml.jobWizardCommon.assertCalendarsSelection([calendarId]); }); it('job cloning opens the advanced section', async () => { diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/single_metric_viewer.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/single_metric_viewer.ts index 62b801daa3479..cc7c9828ce87d 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/single_metric_viewer.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/single_metric_viewer.ts @@ -29,7 +29,7 @@ const JOB_CONFIG: Job = { const DATAFEED_CONFIG: Datafeed = { datafeed_id: 'datafeed-fq_single_1_smv', - indices: ['farequote'], + indices: ['ft_farequote'], job_id: 'fq_single_1_smv', query: { bool: { must: [{ match_all: {} }] } }, }; @@ -42,13 +42,15 @@ export default function({ getService }: FtrProviderContext) { describe('single metric viewer', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/farequote'); + await esArchiver.loadIfNeeded('ml/farequote'); + await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); + await ml.testResources.setKibanaTimeZoneToUTC(); + await ml.api.createAndRunAnomalyDetectionLookbackJob(JOB_CONFIG, DATAFEED_CONFIG); await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { - await esArchiver.unload('ml/farequote'); await ml.api.cleanMlIndices(); }); diff --git a/x-pack/test/functional/apps/machine_learning/data_frame_analytics/classification_creation.ts b/x-pack/test/functional/apps/machine_learning/data_frame_analytics/classification_creation.ts index a7c92cac2072f..8a6741bd88daa 100644 --- a/x-pack/test/functional/apps/machine_learning/data_frame_analytics/classification_creation.ts +++ b/x-pack/test/functional/apps/machine_learning/data_frame_analytics/classification_creation.ts @@ -14,13 +14,15 @@ export default function({ getService }: FtrProviderContext) { describe('classification creation', function() { this.tags(['smoke']); before(async () => { - await esArchiver.load('ml/bm_classification'); + await esArchiver.loadIfNeeded('ml/bm_classification'); + await ml.testResources.createIndexPatternIfNeeded('ft_bank_marketing', '@timestamp'); + await ml.testResources.setKibanaTimeZoneToUTC(); + await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { await ml.api.cleanMlIndices(); - await esArchiver.unload('ml/bm_classification'); }); const testDataList = [ @@ -29,8 +31,8 @@ export default function({ getService }: FtrProviderContext) { jobType: 'classification', jobId: `bm_1_${Date.now()}`, jobDescription: - "Classification job based on 'bank-marketing' dataset with dependentVariable 'y' and trainingPercent '20'", - source: 'bank-marketing*', + "Classification job based on 'ft_bank_marketing' dataset with dependentVariable 'y' and trainingPercent '20'", + source: 'ft_bank_marketing', get destinationIndex(): string { return `user-${this.jobId}`; }, @@ -51,6 +53,7 @@ export default function({ getService }: FtrProviderContext) { describe(`${testData.suiteTitle}`, function() { after(async () => { await ml.api.deleteIndices(testData.destinationIndex); + await ml.testResources.deleteIndexPattern(testData.destinationIndex); }); it('loads the data frame analytics page', async () => { diff --git a/x-pack/test/functional/apps/machine_learning/data_frame_analytics/cloning.ts b/x-pack/test/functional/apps/machine_learning/data_frame_analytics/cloning.ts index caf382b532273..d98d8feaaf4fe 100644 --- a/x-pack/test/functional/apps/machine_learning/data_frame_analytics/cloning.ts +++ b/x-pack/test/functional/apps/machine_learning/data_frame_analytics/cloning.ts @@ -19,6 +19,7 @@ export default function({ getService }: FtrProviderContext) { const testDataList: Array<{ suiteTitle: string; archive: string; + indexPattern: { name: string; timeField: string }; job: DeepPartial; }> = (() => { const timestamp = Date.now(); @@ -27,12 +28,13 @@ export default function({ getService }: FtrProviderContext) { { suiteTitle: 'classification job supported by the form', archive: 'ml/bm_classification', + indexPattern: { name: 'ft_bank_marketing', timeField: '@timestamp' }, job: { id: `bm_1_${timestamp}`, description: - "Classification job based on 'bank-marketing' dataset with dependentVariable 'y' and trainingPercent '20'", + "Classification job based on 'ft_bank_marketing' dataset with dependentVariable 'y' and trainingPercent '20'", source: { - index: ['bank-marketing*'], + index: ['ft_bank_marketing'], query: { match_all: {}, }, @@ -60,11 +62,12 @@ export default function({ getService }: FtrProviderContext) { { suiteTitle: 'outlier detection job supported by the form', archive: 'ml/ihp_outlier', + indexPattern: { name: 'ft_ihp_outlier', timeField: '@timestamp' }, job: { id: `ihp_1_${timestamp}`, description: 'This is the job description', source: { - index: ['ihp_outlier'], + index: ['ft_ihp_outlier'], query: { match_all: {}, }, @@ -88,11 +91,12 @@ export default function({ getService }: FtrProviderContext) { { suiteTitle: 'regression job supported by the form', archive: 'ml/egs_regression', + indexPattern: { name: 'ft_egs_regression', timeField: '@timestamp' }, job: { id: `egs_1_${timestamp}`, description: 'This is the job description', source: { - index: ['egs_regression'], + index: ['ft_egs_regression'], query: { match_all: {}, }, @@ -120,6 +124,7 @@ export default function({ getService }: FtrProviderContext) { })(); before(async () => { + await ml.testResources.setKibanaTimeZoneToUTC(); await ml.securityUI.loginAsMlPowerUser(); }); @@ -133,7 +138,11 @@ export default function({ getService }: FtrProviderContext) { const cloneDestIndex = `${testData.job!.dest!.index}_clone`; before(async () => { - await esArchiver.load(testData.archive); + await esArchiver.loadIfNeeded(testData.archive); + await ml.testResources.createIndexPatternIfNeeded( + testData.indexPattern.name, + testData.indexPattern.timeField + ); await ml.api.createDataFrameAnalyticsJob(testData.job as DataFrameAnalyticsConfig); await ml.navigation.navigateToMl(); @@ -146,7 +155,7 @@ export default function({ getService }: FtrProviderContext) { after(async () => { await ml.api.deleteIndices(cloneDestIndex); await ml.api.deleteIndices(testData.job.dest!.index as string); - await esArchiver.unload(testData.archive); + await ml.testResources.deleteIndexPattern(testData.job.dest!.index as string); }); it('should open the flyout with a proper header', async () => { diff --git a/x-pack/test/functional/apps/machine_learning/data_frame_analytics/outlier_detection_creation.ts b/x-pack/test/functional/apps/machine_learning/data_frame_analytics/outlier_detection_creation.ts index 5481977351d8b..8dfe058cf6885 100644 --- a/x-pack/test/functional/apps/machine_learning/data_frame_analytics/outlier_detection_creation.ts +++ b/x-pack/test/functional/apps/machine_learning/data_frame_analytics/outlier_detection_creation.ts @@ -14,13 +14,15 @@ export default function({ getService }: FtrProviderContext) { describe('outlier detection creation', function() { this.tags(['smoke']); before(async () => { - await esArchiver.load('ml/ihp_outlier'); + await esArchiver.loadIfNeeded('ml/ihp_outlier'); + await ml.testResources.createIndexPatternIfNeeded('ft_ihp_outlier', '@timestamp'); + await ml.testResources.setKibanaTimeZoneToUTC(); + await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { await ml.api.cleanMlIndices(); - await esArchiver.unload('ml/ihp_outlier'); }); const testDataList = [ @@ -29,7 +31,7 @@ export default function({ getService }: FtrProviderContext) { jobType: 'outlier_detection', jobId: `ihp_1_${Date.now()}`, jobDescription: 'This is the job description', - source: 'ihp_outlier', + source: 'ft_ihp_outlier', get destinationIndex(): string { return `user-${this.jobId}`; }, @@ -49,6 +51,7 @@ export default function({ getService }: FtrProviderContext) { describe(`${testData.suiteTitle}`, function() { after(async () => { await ml.api.deleteIndices(testData.destinationIndex); + await ml.testResources.deleteIndexPattern(testData.destinationIndex); }); it('loads the data frame analytics page', async () => { diff --git a/x-pack/test/functional/apps/machine_learning/data_frame_analytics/regression_creation.ts b/x-pack/test/functional/apps/machine_learning/data_frame_analytics/regression_creation.ts index aa1a133c81187..271f3e2018dad 100644 --- a/x-pack/test/functional/apps/machine_learning/data_frame_analytics/regression_creation.ts +++ b/x-pack/test/functional/apps/machine_learning/data_frame_analytics/regression_creation.ts @@ -14,13 +14,15 @@ export default function({ getService }: FtrProviderContext) { describe('regression creation', function() { this.tags(['smoke']); before(async () => { - await esArchiver.load('ml/egs_regression'); + await esArchiver.loadIfNeeded('ml/egs_regression'); + await ml.testResources.createIndexPatternIfNeeded('ft_egs_regression', '@timestamp'); + await ml.testResources.setKibanaTimeZoneToUTC(); + await ml.securityUI.loginAsMlPowerUser(); }); after(async () => { await ml.api.cleanMlIndices(); - await esArchiver.unload('ml/egs_regression'); }); const testDataList = [ @@ -29,7 +31,7 @@ export default function({ getService }: FtrProviderContext) { jobType: 'regression', jobId: `egs_1_${Date.now()}`, jobDescription: 'This is the job description', - source: 'egs_regression', + source: 'ft_egs_regression', get destinationIndex(): string { return `user-${this.jobId}`; }, @@ -51,6 +53,7 @@ export default function({ getService }: FtrProviderContext) { describe(`${testData.suiteTitle}`, function() { after(async () => { await ml.api.deleteIndices(testData.destinationIndex); + await ml.testResources.deleteIndexPattern(testData.destinationIndex); }); it('loads the data frame analytics page', async () => { diff --git a/x-pack/test/functional/apps/machine_learning/data_visualizer/file_data_visualizer.ts b/x-pack/test/functional/apps/machine_learning/data_visualizer/file_data_visualizer.ts index 94b28e5035edf..ae958ad7f570f 100644 --- a/x-pack/test/functional/apps/machine_learning/data_visualizer/file_data_visualizer.ts +++ b/x-pack/test/functional/apps/machine_learning/data_visualizer/file_data_visualizer.ts @@ -36,6 +36,8 @@ export default function({ getService }: FtrProviderContext) { describe('file based', function() { this.tags(['smoke', 'mlqa']); before(async () => { + await ml.testResources.setKibanaTimeZoneToUTC(); + await ml.securityUI.loginAsMlPowerUser(); await ml.navigation.navigateToMl(); }); diff --git a/x-pack/test/functional/apps/machine_learning/data_visualizer/index_data_visualizer.ts b/x-pack/test/functional/apps/machine_learning/data_visualizer/index_data_visualizer.ts index 1ee74368c72fa..e71b57a4562e7 100644 --- a/x-pack/test/functional/apps/machine_learning/data_visualizer/index_data_visualizer.ts +++ b/x-pack/test/functional/apps/machine_learning/data_visualizer/index_data_visualizer.ts @@ -45,7 +45,7 @@ export default function({ getService }: FtrProviderContext) { const farequoteIndexPatternTestData: TestData = { suiteTitle: 'index pattern', - sourceIndexOrSavedSearch: 'farequote', + sourceIndexOrSavedSearch: 'ft_farequote', advancedJobWizardDatafeedQuery: `{ "bool": { "must": [ @@ -128,7 +128,7 @@ export default function({ getService }: FtrProviderContext) { const farequoteKQLSearchTestData: TestData = { suiteTitle: 'KQL saved search', - sourceIndexOrSavedSearch: 'farequote_kuery', + sourceIndexOrSavedSearch: 'ft_farequote_kuery', advancedJobWizardDatafeedQuery: `{ "bool": { "must": [ @@ -211,7 +211,7 @@ export default function({ getService }: FtrProviderContext) { const farequoteLuceneSearchTestData: TestData = { suiteTitle: 'lucene saved search', - sourceIndexOrSavedSearch: 'farequote_lucene', + sourceIndexOrSavedSearch: 'ft_farequote_lucene', advancedJobWizardDatafeedQuery: `{ "bool": { "must": [ @@ -378,12 +378,13 @@ export default function({ getService }: FtrProviderContext) { describe('index based', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('ml/farequote'); - await ml.securityUI.loginAsMlPowerUser(); - }); + await esArchiver.loadIfNeeded('ml/farequote'); + await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); + await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded(); + await ml.testResources.createSavedSearchFarequoteKueryIfNeeded(); + await ml.testResources.setKibanaTimeZoneToUTC(); - after(async () => { - await esArchiver.unload('ml/farequote'); + await ml.securityUI.loginAsMlPowerUser(); }); // TODO - add tests for diff --git a/x-pack/test/functional/apps/machine_learning/feature_controls/ml_security.ts b/x-pack/test/functional/apps/machine_learning/feature_controls/ml_security.ts index f3731f46a5bce..ec4b708152a4c 100644 --- a/x-pack/test/functional/apps/machine_learning/feature_controls/ml_security.ts +++ b/x-pack/test/functional/apps/machine_learning/feature_controls/ml_security.ts @@ -7,15 +7,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function({ getPageObjects, getService }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); const security = getService('security'); const appsMenu = getService('appsMenu'); const PageObjects = getPageObjects(['common', 'security']); describe('security', function() { before(async () => { - await esArchiver.load('empty_kibana'); - await security.role.create('global_all_role', { elasticsearch: { indices: [{ names: ['logstash-*'], privileges: ['read', 'view_index_metadata'] }], @@ -33,7 +30,6 @@ export default function({ getPageObjects, getService }: FtrProviderContext) { }); after(async () => { - await esArchiver.unload('empty_kibana'); await security.role.delete('global_all_role'); // logout, so the other tests don't accidentally run as the custom users we're testing below diff --git a/x-pack/test/functional/apps/machine_learning/feature_controls/ml_spaces.ts b/x-pack/test/functional/apps/machine_learning/feature_controls/ml_spaces.ts index fc94688e98811..828d7bcc0ae2f 100644 --- a/x-pack/test/functional/apps/machine_learning/feature_controls/ml_spaces.ts +++ b/x-pack/test/functional/apps/machine_learning/feature_controls/ml_spaces.ts @@ -7,21 +7,12 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../../ftr_provider_context'; export default function({ getPageObjects, getService }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); const spacesService = getService('spaces'); const PageObjects = getPageObjects(['common', 'dashboard', 'security', 'error']); const appsMenu = getService('appsMenu'); const testSubjects = getService('testSubjects'); describe('spaces', () => { - before(async () => { - await esArchiver.load('empty_kibana'); - }); - - after(async () => { - await esArchiver.unload('empty_kibana'); - }); - describe('space with no features disabled', () => { before(async () => { await spacesService.create({ diff --git a/x-pack/test/functional/apps/machine_learning/index.ts b/x-pack/test/functional/apps/machine_learning/index.ts index 47c699e309491..3e1991120d2d2 100644 --- a/x-pack/test/functional/apps/machine_learning/index.ts +++ b/x-pack/test/functional/apps/machine_learning/index.ts @@ -6,6 +6,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function({ getService, loadTestFile }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); const ml = getService('ml'); describe('machine learning', function() { @@ -19,6 +20,26 @@ export default function({ getService, loadTestFile }: FtrProviderContext) { after(async () => { await ml.securityCommon.cleanMlUsers(); await ml.securityCommon.cleanMlRoles(); + + await ml.testResources.deleteSavedSearches(); + + await ml.testResources.deleteIndexPattern('ft_farequote'); + await ml.testResources.deleteIndexPattern('ft_ecommerce'); + await ml.testResources.deleteIndexPattern('ft_categorization'); + await ml.testResources.deleteIndexPattern('ft_event_rate_gen_trend_nanos'); + await ml.testResources.deleteIndexPattern('ft_bank_marketing'); + await ml.testResources.deleteIndexPattern('ft_ihp_outlier'); + await ml.testResources.deleteIndexPattern('ft_egs_regression'); + + await esArchiver.unload('ml/farequote'); + await esArchiver.unload('ml/ecommerce'); + await esArchiver.unload('ml/categorization'); + await esArchiver.unload('ml/event_rate_nanos'); + await esArchiver.unload('ml/bm_classification'); + await esArchiver.unload('ml/ihp_outlier'); + await esArchiver.unload('ml/egs_regression'); + + await ml.testResources.resetKibanaTimeZone(); }); loadTestFile(require.resolve('./feature_controls')); diff --git a/x-pack/test/functional/apps/machine_learning/pages.ts b/x-pack/test/functional/apps/machine_learning/pages.ts index 78c6ec4f1b2ff..95930f18061fa 100644 --- a/x-pack/test/functional/apps/machine_learning/pages.ts +++ b/x-pack/test/functional/apps/machine_learning/pages.ts @@ -7,20 +7,15 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function({ getService }: FtrProviderContext) { - const esArchiver = getService('esArchiver'); const ml = getService('ml'); describe('page navigation', function() { this.tags(['smoke', 'mlqa']); before(async () => { - await esArchiver.load('empty_kibana'); + await ml.api.cleanMlIndices(); await ml.securityUI.loginAsMlPowerUser(); }); - after(async () => { - await esArchiver.unload('empty_kibana'); - }); - it('loads the home page', async () => { await ml.navigation.navigateToMl(); }); diff --git a/x-pack/test/functional/apps/maps/embeddable/dashboard.js b/x-pack/test/functional/apps/maps/embeddable/dashboard.js index 43d5cccb20905..9027bb5309ff8 100644 --- a/x-pack/test/functional/apps/maps/embeddable/dashboard.js +++ b/x-pack/test/functional/apps/maps/embeddable/dashboard.js @@ -13,6 +13,7 @@ export default function({ getPageObjects, getService }) { const dashboardPanelActions = getService('dashboardPanelActions'); const inspector = getService('inspector'); const testSubjects = getService('testSubjects'); + const browser = getService('browser'); describe('embed in dashboard', () => { before(async () => { @@ -111,5 +112,15 @@ export default function({ getPageObjects, getService }) { const afterRefreshTimerTimestamp = await getRequestTimestamp(); expect(beforeRefreshTimerTimestamp).not.to.equal(afterRefreshTimerTimestamp); }); + + // see https://github.com/elastic/kibana/issues/61596 on why it is specific to maps + it("dashboard's back button should navigate to previous page", async () => { + await PageObjects.common.navigateToApp('dashboard'); + await PageObjects.dashboard.preserveCrossAppState(); + await PageObjects.dashboard.loadSavedDashboard('map embeddable example'); + await PageObjects.dashboard.waitForRenderComplete(); + await browser.goBack(); + expect(await PageObjects.dashboard.onDashboardLandingPage()).to.be(true); + }); }); } diff --git a/x-pack/test/functional/apps/maps/joins.js b/x-pack/test/functional/apps/maps/joins.js index 89a6c6ea82e53..4b36109a4de9c 100644 --- a/x-pack/test/functional/apps/maps/joins.js +++ b/x-pack/test/functional/apps/maps/joins.js @@ -9,7 +9,7 @@ import _ from 'lodash'; import { MAPBOX_STYLES } from './mapbox_styles'; -const JOIN_PROPERTY_NAME = '__kbnjoin__max_of_prop1_groupby_meta_for_geo_shapes*.shape_name'; +const JOIN_PROPERTY_NAME = '__kbnjoin__max_of_prop1__855ccb86-fe42-11e8-8eb2-f2801f1b9fd1'; const EXPECTED_JOIN_VALUES = { alpha: 10, bravo: 3, diff --git a/x-pack/test/functional/apps/maps/mapbox_styles.js b/x-pack/test/functional/apps/maps/mapbox_styles.js index 508a019db1764..63bfc331d8886 100644 --- a/x-pack/test/functional/apps/maps/mapbox_styles.js +++ b/x-pack/test/functional/apps/maps/mapbox_styles.js @@ -27,7 +27,7 @@ export const MAPBOX_STYLES = { 'case', [ '==', - ['feature-state', '__kbnjoin__max_of_prop1_groupby_meta_for_geo_shapes*.shape_name'], + ['feature-state', '__kbnjoin__max_of_prop1__855ccb86-fe42-11e8-8eb2-f2801f1b9fd1'], null, ], 2, @@ -39,7 +39,7 @@ export const MAPBOX_STYLES = { 'to-number', [ 'feature-state', - '__kbnjoin__max_of_prop1_groupby_meta_for_geo_shapes*.shape_name', + '__kbnjoin__max_of_prop1__855ccb86-fe42-11e8-8eb2-f2801f1b9fd1', ], ], 12, @@ -97,7 +97,7 @@ export const MAPBOX_STYLES = { 'case', [ '==', - ['feature-state', '__kbnjoin__max_of_prop1_groupby_meta_for_geo_shapes*.shape_name'], + ['feature-state', '__kbnjoin__max_of_prop1__855ccb86-fe42-11e8-8eb2-f2801f1b9fd1'], null, ], 2, @@ -109,7 +109,7 @@ export const MAPBOX_STYLES = { 'to-number', [ 'feature-state', - '__kbnjoin__max_of_prop1_groupby_meta_for_geo_shapes*.shape_name', + '__kbnjoin__max_of_prop1__855ccb86-fe42-11e8-8eb2-f2801f1b9fd1', ], ], 12, diff --git a/x-pack/test/functional/apps/transform/cloning.ts b/x-pack/test/functional/apps/transform/cloning.ts index 5f05fdb093d10..e6e12f60f0bcc 100644 --- a/x-pack/test/functional/apps/transform/cloning.ts +++ b/x-pack/test/functional/apps/transform/cloning.ts @@ -11,7 +11,7 @@ function getTransformConfig(): TransformPivotConfig { const date = Date.now(); return { id: `ec_2_${date}`, - source: { index: ['ecommerce'] }, + source: { index: ['ft_ecommerce'] }, pivot: { group_by: { category: { terms: { field: 'category.keyword' } } }, aggregations: { 'products.base_price.avg': { avg: { field: 'products.base_price' } } }, @@ -31,13 +31,16 @@ export default function({ getService }: FtrProviderContext) { const transformConfig = getTransformConfig(); before(async () => { - await esArchiver.load('ml/ecommerce'); + await esArchiver.loadIfNeeded('ml/ecommerce'); + await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); await transform.api.createAndRunTransform(transformConfig); + await transform.testResources.setKibanaTimeZoneToUTC(); + await transform.securityUI.loginAsTransformPowerUser(); }); after(async () => { - await esArchiver.unload('ml/ecommerce'); + await transform.testResources.deleteIndexPattern(transformConfig.dest.index); await transform.api.deleteIndices(transformConfig.dest.index); await transform.api.cleanTransformIndices(); }); diff --git a/x-pack/test/functional/apps/transform/creation_index_pattern.ts b/x-pack/test/functional/apps/transform/creation_index_pattern.ts index f3cc4ab8d7601..bea6b814ee8a3 100644 --- a/x-pack/test/functional/apps/transform/creation_index_pattern.ts +++ b/x-pack/test/functional/apps/transform/creation_index_pattern.ts @@ -20,19 +20,21 @@ export default function({ getService }: FtrProviderContext) { describe('creation_index_pattern', function() { this.tags(['smoke']); before(async () => { - await esArchiver.load('ml/ecommerce'); + await esArchiver.loadIfNeeded('ml/ecommerce'); + await transform.testResources.createIndexPatternIfNeeded('ft_ecommerce', 'order_date'); + await transform.testResources.setKibanaTimeZoneToUTC(); + await transform.securityUI.loginAsTransformPowerUser(); }); after(async () => { - await esArchiver.unload('ml/ecommerce'); await transform.api.cleanTransformIndices(); }); const testDataList = [ { suiteTitle: 'batch transform with terms+date_histogram groups and avg agg', - source: 'ecommerce', + source: 'ft_ecommerce', groupByEntries: [ { identifier: 'terms(category.keyword)', @@ -96,7 +98,7 @@ export default function({ getService }: FtrProviderContext) { }, { suiteTitle: 'batch transform with terms group and percentiles agg', - source: 'ecommerce', + source: 'ft_ecommerce', groupByEntries: [ { identifier: 'terms(geoip.country_iso_code)', @@ -154,6 +156,7 @@ export default function({ getService }: FtrProviderContext) { describe(`${testData.suiteTitle}`, function() { after(async () => { await transform.api.deleteIndices(testData.destinationIndex); + await transform.testResources.deleteIndexPattern(testData.destinationIndex); }); it('loads the home page', async () => { diff --git a/x-pack/test/functional/apps/transform/creation_saved_search.ts b/x-pack/test/functional/apps/transform/creation_saved_search.ts index bf501c65bc79b..993bd3a79abbc 100644 --- a/x-pack/test/functional/apps/transform/creation_saved_search.ts +++ b/x-pack/test/functional/apps/transform/creation_saved_search.ts @@ -20,19 +20,22 @@ export default function({ getService }: FtrProviderContext) { describe('creation_saved_search', function() { this.tags(['smoke']); before(async () => { - await esArchiver.load('ml/farequote'); + await esArchiver.loadIfNeeded('ml/farequote'); + await transform.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); + await transform.testResources.createSavedSearchFarequoteFilterIfNeeded(); + await transform.testResources.setKibanaTimeZoneToUTC(); + await transform.securityUI.loginAsTransformPowerUser(); }); after(async () => { - await esArchiver.unload('ml/farequote'); await transform.api.cleanTransformIndices(); }); const testDataList = [ { suiteTitle: 'batch transform with terms groups and avg agg with saved search filter', - source: 'farequote_filter', + source: 'ft_farequote_filter', groupByEntries: [ { identifier: 'terms(airline)', @@ -61,7 +64,7 @@ export default function({ getService }: FtrProviderContext) { mode: 'batch', progress: '100', }, - sourceIndex: 'farequote', + sourceIndex: 'ft_farequote', sourcePreview: { column: 2, values: ['ASA'], @@ -74,6 +77,7 @@ export default function({ getService }: FtrProviderContext) { describe(`${testData.suiteTitle}`, function() { after(async () => { await transform.api.deleteIndices(testData.destinationIndex); + await transform.testResources.deleteIndexPattern(testData.destinationIndex); }); it('loads the home page', async () => { diff --git a/x-pack/test/functional/apps/transform/index.ts b/x-pack/test/functional/apps/transform/index.ts index 60b72f122f113..bf720ce85d824 100644 --- a/x-pack/test/functional/apps/transform/index.ts +++ b/x-pack/test/functional/apps/transform/index.ts @@ -6,6 +6,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function({ getService, loadTestFile }: FtrProviderContext) { + const esArchiver = getService('esArchiver'); const transform = getService('transform'); describe('transform', function() { @@ -19,6 +20,16 @@ export default function({ getService, loadTestFile }: FtrProviderContext) { after(async () => { await transform.securityCommon.cleanTransformUsers(); await transform.securityCommon.cleanTransformRoles(); + + await transform.testResources.deleteSavedSearches(); + + await transform.testResources.deleteIndexPattern('ft_farequote'); + await transform.testResources.deleteIndexPattern('ft_ecommerce'); + + await esArchiver.unload('ml/farequote'); + await esArchiver.unload('ml/ecommerce'); + + await transform.testResources.resetKibanaTimeZone(); }); loadTestFile(require.resolve('./creation_index_pattern')); diff --git a/x-pack/test/functional/apps/uptime/locations.ts b/x-pack/test/functional/apps/uptime/locations.ts index bbf50344f3493..e266594e6a762 100644 --- a/x-pack/test/functional/apps/uptime/locations.ts +++ b/x-pack/test/functional/apps/uptime/locations.ts @@ -5,7 +5,7 @@ */ import moment from 'moment'; -import { makeChecksWithStatus } from '../../../api_integration/apis/uptime/graphql/helpers/make_checks'; +import { makeChecksWithStatus } from '../../../api_integration/apis/uptime/rest/helper/make_checks'; import { FtrProviderContext } from '../../ftr_provider_context'; export default ({ getPageObjects, getService }: FtrProviderContext) => { diff --git a/x-pack/test/functional/apps/uptime/settings.ts b/x-pack/test/functional/apps/uptime/settings.ts index 3294d928b61b3..e81bbc5ae42f9 100644 --- a/x-pack/test/functional/apps/uptime/settings.ts +++ b/x-pack/test/functional/apps/uptime/settings.ts @@ -10,7 +10,7 @@ import { defaultDynamicSettings, DynamicSettings, } from '../../../../legacy/plugins/uptime/common/runtime_types'; -import { makeChecks } from '../../../api_integration/apis/uptime/graphql/helpers/make_checks'; +import { makeChecks } from '../../../api_integration/apis/uptime/rest/helper/make_checks'; export default ({ getPageObjects, getService }: FtrProviderContext) => { const { uptime: uptimePage } = getPageObjects(['uptime']); @@ -74,7 +74,41 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { // Verify that the settings page shows the value we previously saved await settings.go(); const fields = await settings.loadFields(); - expect(fields).to.eql(newFieldValues); + expect(fields.heartbeatIndices).to.eql(newFieldValues.heartbeatIndices); + }); + + it('changing certificate expiration error threshold is reflected in settings page', async () => { + const settings = uptimeService.settings; + + await settings.go(); + + const newErrorThreshold = '5'; + await settings.changeErrorThresholdInput(newErrorThreshold); + await settings.apply(); + + await uptimePage.goToRoot(); + + // Verify that the settings page shows the value we previously saved + await settings.go(); + const fields = await settings.loadFields(); + expect(fields.certificatesThresholds.errorState).to.eql(newErrorThreshold); + }); + + it('changing certificate expiration warning threshold is reflected in settings page', async () => { + const settings = uptimeService.settings; + + await settings.go(); + + const newWarningThreshold = '15'; + await settings.changeWarningThresholdInput(newWarningThreshold); + await settings.apply(); + + await uptimePage.goToRoot(); + + // Verify that the settings page shows the value we previously saved + await settings.go(); + const fields = await settings.loadFields(); + expect(fields.certificatesThresholds.warningState).to.eql(newWarningThreshold); }); }); }; diff --git a/x-pack/test/functional/es_archives/endpoint/alerts/host_api_feature/data.json.gz b/x-pack/test/functional/es_archives/endpoint/alerts/host_api_feature/data.json.gz index 94a96c54ee9cb..a71281c0ecfec 100644 Binary files a/x-pack/test/functional/es_archives/endpoint/alerts/host_api_feature/data.json.gz and b/x-pack/test/functional/es_archives/endpoint/alerts/host_api_feature/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/endpoint/alerts/host_api_feature/mappings.json b/x-pack/test/functional/es_archives/endpoint/alerts/host_api_feature/mappings.json index 61ddf3c4e65db..f9d5de0d0a94c 100644 --- a/x-pack/test/functional/es_archives/endpoint/alerts/host_api_feature/mappings.json +++ b/x-pack/test/functional/es_archives/endpoint/alerts/host_api_feature/mappings.json @@ -1,33 +1,62 @@ { "type": "index", "value": { - "aliases": { - }, - "index": "endpoint-agent-1", + "aliases": {}, + "index": "metrics-endpoint-default-1", "mappings": { + "_meta": { + "version": "1.5.0-dev" + }, + "date_detection": false, + "dynamic_templates": [ + { + "strings_as_keyword": { + "mapping": { + "ignore_above": 1024, + "type": "keyword" + }, + "match_mapping_type": "string" + } + } + ], "properties": { "@timestamp": { - "type": "long" + "type": "date" }, - "agent": { + "elastic": { "properties": { - "id": { - "fields": { - "keyword": { - "ignore_above": 256, + "agent": { + "properties": { + "id": { + "ignore_above": 1024, "type": "keyword" } }, - "type": "text" + "type": "object" + } + } + }, + "agent": { + "properties": { + "id": { + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" }, "version": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "ecs": { + "properties": { + "version": { + "ignore_above": 1024, + "type": "keyword" } } }, @@ -36,109 +65,71 @@ "policy": { "properties": { "id": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" } - } + }, + "type": "object" } } }, "event": { "properties": { "created": { - "type": "long" + "type": "date" } } }, "host": { "properties": { + "architecture": { + "ignore_above": 1024, + "type": "keyword" + }, "hostname": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "id": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "ip": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "type": "ip" }, "mac": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "os": { "properties": { "full": { "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" + "text": { + "norms": false, + "type": "text" } }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "name": { "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" + "text": { + "norms": false, + "type": "text" } }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "variant": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "version": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" } } } @@ -146,11 +137,16 @@ } } }, + "order": 1, "settings": { "index": { - "number_of_replicas": "1", - "number_of_shards": "1" + "mapping": { + "total_fields": { + "limit": 10000 + } + }, + "refresh_interval": "5s" } } } -} \ No newline at end of file +} diff --git a/x-pack/test/functional/es_archives/endpoint/metadata/api_feature/data.json b/x-pack/test/functional/es_archives/endpoint/metadata/api_feature/data.json index 2046f46db9f53..d3617dc236375 100644 --- a/x-pack/test/functional/es_archives/endpoint/metadata/api_feature/data.json +++ b/x-pack/test/functional/es_archives/endpoint/metadata/api_feature/data.json @@ -2,7 +2,7 @@ "type": "doc", "value": { "id": "3KVN2G8BYQH1gtPUuYk7", - "index": "endpoint-agent-1", + "index": "metrics-endpoint-default-1", "source": { "@timestamp": 1579881969541, "agent": { @@ -51,7 +51,7 @@ "type": "doc", "value": { "id": "3aVN2G8BYQH1gtPUuYk7", - "index": "endpoint-agent-1", + "index": "metrics-endpoint-default-1", "source": { "@timestamp": 1579881969541, "agent": { @@ -99,7 +99,7 @@ "type": "doc", "value": { "id": "3qVN2G8BYQH1gtPUuYk7", - "index": "endpoint-agent-1", + "index": "metrics-endpoint-default-1", "source": { "@timestamp": 1579881969541, "agent": { @@ -145,7 +145,7 @@ "type": "doc", "value": { "id": "36VN2G8BYQH1gtPUuYk7", - "index": "endpoint-agent-1", + "index": "metrics-endpoint-default-1", "source": { "@timestamp": 1579878369541, "agent": { @@ -194,7 +194,7 @@ "type": "doc", "value": { "id": "4KVN2G8BYQH1gtPUuYk7", - "index": "endpoint-agent-1", + "index": "metrics-endpoint-default-1", "source": { "@timestamp": 1579878369541, "agent": { @@ -241,7 +241,7 @@ "type": "doc", "value": { "id": "4aVN2G8BYQH1gtPUuYk7", - "index": "endpoint-agent-1", + "index": "metrics-endpoint-default-1", "source": { "@timestamp": 1579878369541, "agent": { @@ -288,7 +288,7 @@ "type": "doc", "value": { "id": "4qVN2G8BYQH1gtPUuYk7", - "index": "endpoint-agent-1", + "index": "metrics-endpoint-default-1", "source": { "@timestamp": 1579874769541, "agent": { @@ -336,7 +336,7 @@ "type": "doc", "value": { "id": "46VN2G8BYQH1gtPUuYk7", - "index": "endpoint-agent-1", + "index": "metrics-endpoint-default-1", "source": { "@timestamp": 1579874769541, "agent": { @@ -383,7 +383,7 @@ "type": "doc", "value": { "id": "5KVN2G8BYQH1gtPUuYk7", - "index": "endpoint-agent-1", + "index": "metrics-endpoint-default-1", "source": { "@timestamp": 1579874769541, "agent": { diff --git a/x-pack/test/functional/es_archives/endpoint/metadata/api_feature/mappings.json b/x-pack/test/functional/es_archives/endpoint/metadata/api_feature/mappings.json index c9a6c183f0489..f9d5de0d0a94c 100644 --- a/x-pack/test/functional/es_archives/endpoint/metadata/api_feature/mappings.json +++ b/x-pack/test/functional/es_archives/endpoint/metadata/api_feature/mappings.json @@ -1,50 +1,62 @@ { "type": "index", "value": { - "aliases": { - }, - "index": "endpoint-agent-1", + "aliases": {}, + "index": "metrics-endpoint-default-1", "mappings": { + "_meta": { + "version": "1.5.0-dev" + }, + "date_detection": false, + "dynamic_templates": [ + { + "strings_as_keyword": { + "mapping": { + "ignore_above": 1024, + "type": "keyword" + }, + "match_mapping_type": "string" + } + } + ], "properties": { "@timestamp": { - "type": "long" + "type": "date" }, "elastic": { "properties": { "agent": { "properties": { "id": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" } - } + }, + "type": "object" } } }, "agent": { "properties": { "id": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" + }, + "name": { + "ignore_above": 1024, + "type": "keyword" }, "version": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" + } + } + }, + "ecs": { + "properties": { + "version": { + "ignore_above": 1024, + "type": "keyword" } } }, @@ -53,109 +65,71 @@ "policy": { "properties": { "id": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" } - } + }, + "type": "object" } } }, "event": { "properties": { "created": { - "type": "long" + "type": "date" } } }, "host": { "properties": { + "architecture": { + "ignore_above": 1024, + "type": "keyword" + }, "hostname": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "id": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "ip": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "type": "ip" }, "mac": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "os": { "properties": { "full": { "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" + "text": { + "norms": false, + "type": "text" } }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "name": { "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" + "text": { + "norms": false, + "type": "text" } }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "variant": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" }, "version": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" + "ignore_above": 1024, + "type": "keyword" } } } @@ -163,10 +137,15 @@ } } }, + "order": 1, "settings": { "index": { - "number_of_replicas": "1", - "number_of_shards": "1" + "mapping": { + "total_fields": { + "limit": 10000 + } + }, + "refresh_interval": "5s" } } } diff --git a/x-pack/test/functional/es_archives/ml/bm_classification/data.json.gz b/x-pack/test/functional/es_archives/ml/bm_classification/data.json.gz index 12ccf6ae60512..8c0dc38d3dedb 100644 Binary files a/x-pack/test/functional/es_archives/ml/bm_classification/data.json.gz and b/x-pack/test/functional/es_archives/ml/bm_classification/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/ml/bm_classification/mappings.json b/x-pack/test/functional/es_archives/ml/bm_classification/mappings.json index 9d2cca22bf300..380a0d8fa4d15 100644 --- a/x-pack/test/functional/es_archives/ml/bm_classification/mappings.json +++ b/x-pack/test/functional/es_archives/ml/bm_classification/mappings.json @@ -3,7 +3,7 @@ "value": { "aliases": { }, - "index": "bank-marketing", + "index": "ft_bank_marketing", "mappings": { "properties": { "age": { @@ -94,1455 +94,3 @@ } } } - -{ - "type": "index", - "value": { - "aliases": { - ".kibana": { - } - }, - "index": ".kibana_1", - "mappings": { - "_meta": { - "migrationMappingPropertyHashes": { - "action": "c0c235fba02ebd2a2412bcda79009b58", - "action_task_params": "a9d49f184ee89641044be0ca2950fa3a", - "alert": "e588043a01d3d43477e7cad7efa0f5d8", - "apm-indices": "9bb9b2bf1fa636ed8619cbab5ce6a1dd", - "apm-services-telemetry": "07ee1939fa4302c62ddc052ec03fed90", - "canvas-element": "7390014e1091044523666d97247392fc", - "canvas-workpad": "b0a1706d356228dbdcb4a17e6b9eb231", - "config": "87aca8fdb053154f11383fce3dbf3edf", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", - "graph-workspace": "cd7ba1330e6682e9cc00b78850874be1", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", - "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", - "inventory-view": "84b320fd67209906333ffce261128462", - "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", - "lens": "21c3ea0763beb1ecb0162529706b88c5", - "lens-ui-telemetry": "509bfa5978586998e05f9e303c07a327", - "map": "23d7aa4a720d4938ccde3983f87bd58d", - "maps-telemetry": "268da3a48066123fc5baf35abaa55014", - "metrics-explorer-view": "53c5365793677328df0ccb6138bf3cdd", - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", - "namespace": "2f4316de49999235636386fe51dc06c1", - "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", - "references": "7997cf5a56cc02bdc9c93361bde732b0", - "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", - "server": "ec97f1c5da1a19609a60874e5af1100c", - "siem-detection-engine-rule-status": "0367e4d775814b56a4bee29384f9aafe", - "siem-ui-timeline": "ac8020190f5950dd3250b6499144e7fb", - "siem-ui-timeline-note": "8874706eedc49059d4cf0f5094559084", - "siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29", - "space": "c5ca8acafa0beaa4d08d014a97b6bc6b", - "telemetry": "358ffaa88ba34a97d55af0933a117de4", - "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "tsvb-validation-telemetry": "3a37ef6c8700ae6fc97d5c7da00e9215", - "type": "2f4316de49999235636386fe51dc06c1", - "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", - "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", - "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", - "url": "c7f66a0df8b1b52f17c28c4adb111105", - "visualization": "52d7a13ad68a150c4525b292d23e12cc" - } - }, - "dynamic": "strict", - "properties": { - "action": { - "properties": { - "actionTypeId": { - "type": "keyword" - }, - "config": { - "enabled": false, - "type": "object" - }, - "name": { - "type": "text" - }, - "secrets": { - "type": "binary" - } - } - }, - "action_task_params": { - "properties": { - "actionId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "params": { - "enabled": false, - "type": "object" - } - } - }, - "alert": { - "properties": { - "actions": { - "properties": { - "actionRef": { - "type": "keyword" - }, - "actionTypeId": { - "type": "keyword" - }, - "group": { - "type": "keyword" - }, - "params": { - "enabled": false, - "type": "object" - } - }, - "type": "nested" - }, - "alertTypeId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "apiKeyOwner": { - "type": "keyword" - }, - "consumer": { - "type": "keyword" - }, - "createdAt": { - "type": "date" - }, - "createdBy": { - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "muteAll": { - "type": "boolean" - }, - "mutedInstanceIds": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "params": { - "enabled": false, - "type": "object" - }, - "schedule": { - "properties": { - "interval": { - "type": "keyword" - } - } - }, - "scheduledTaskId": { - "type": "keyword" - }, - "tags": { - "type": "keyword" - }, - "throttle": { - "type": "keyword" - }, - "updatedBy": { - "type": "keyword" - } - } - }, - "apm-indices": { - "properties": { - "apm_oss": { - "properties": { - "errorIndices": { - "type": "keyword" - }, - "metricsIndices": { - "type": "keyword" - }, - "onboardingIndices": { - "type": "keyword" - }, - "sourcemapIndices": { - "type": "keyword" - }, - "spanIndices": { - "type": "keyword" - }, - "transactionIndices": { - "type": "keyword" - } - } - } - } - }, - "apm-services-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "dotnet": { - "null_value": 0, - "type": "long" - }, - "go": { - "null_value": 0, - "type": "long" - }, - "java": { - "null_value": 0, - "type": "long" - }, - "js-base": { - "null_value": 0, - "type": "long" - }, - "nodejs": { - "null_value": 0, - "type": "long" - }, - "python": { - "null_value": 0, - "type": "long" - }, - "ruby": { - "null_value": 0, - "type": "long" - }, - "rum-js": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "canvas-element": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "content": { - "type": "text" - }, - "help": { - "type": "text" - }, - "image": { - "type": "text" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "canvas-workpad": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultIndex": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "dashboard": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "file-upload-telemetry": { - "properties": { - "filesUploadedTotalCount": { - "type": "long" - } - } - }, - "graph-workspace": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" - } - } - }, - "index-pattern": { - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "typeMeta": { - "type": "keyword" - } - } - }, - "infrastructure-ui-source": { - "properties": { - "description": { - "type": "text" - }, - "fields": { - "properties": { - "container": { - "type": "keyword" - }, - "host": { - "type": "keyword" - }, - "pod": { - "type": "keyword" - }, - "tiebreaker": { - "type": "keyword" - }, - "timestamp": { - "type": "keyword" - } - } - }, - "logAlias": { - "type": "keyword" - }, - "logColumns": { - "properties": { - "fieldColumn": { - "properties": { - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - } - } - }, - "messageColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - }, - "timestampColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - } - }, - "type": "nested" - }, - "metricAlias": { - "type": "keyword" - }, - "name": { - "type": "text" - } - } - }, - "inventory-view": { - "properties": { - "autoBounds": { - "type": "boolean" - }, - "autoReload": { - "type": "boolean" - }, - "boundsOverride": { - "properties": { - "max": { - "type": "integer" - }, - "min": { - "type": "integer" - } - } - }, - "customOptions": { - "properties": { - "field": { - "type": "keyword" - }, - "text": { - "type": "keyword" - } - }, - "type": "nested" - }, - "filterQuery": { - "properties": { - "expression": { - "type": "keyword" - }, - "kind": { - "type": "keyword" - } - } - }, - "groupBy": { - "properties": { - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - }, - "metric": { - "properties": { - "type": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "nodeType": { - "type": "keyword" - }, - "time": { - "type": "integer" - }, - "view": { - "type": "keyword" - } - } - }, - "kql-telemetry": { - "properties": { - "optInCount": { - "type": "long" - }, - "optOutCount": { - "type": "long" - } - } - }, - "lens": { - "properties": { - "expression": { - "index": false, - "type": "keyword" - }, - "state": { - "type": "flattened" - }, - "title": { - "type": "text" - }, - "visualizationType": { - "type": "keyword" - } - } - }, - "lens-ui-telemetry": { - "properties": { - "count": { - "type": "integer" - }, - "date": { - "type": "date" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "map": { - "properties": { - "bounds": { - "type": "geo_shape" - }, - "description": { - "type": "text" - }, - "layerListJSON": { - "type": "text" - }, - "mapStateJSON": { - "type": "text" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "maps-telemetry": { - "properties": { - "attributesPerMap": { - "properties": { - "dataSourcesCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - }, - "emsVectorLayersCount": { - "dynamic": "true", - "type": "object" - }, - "layerTypesCount": { - "dynamic": "true", - "type": "object" - }, - "layersCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - } - } - }, - "indexPatternsWithGeoFieldCount": { - "type": "long" - }, - "mapsTotalCount": { - "type": "long" - }, - "settings": { - "properties": { - "showMapVisualizationTypes": { - "type": "boolean" - } - } - }, - "timeCaptured": { - "type": "date" - } - } - }, - "metrics-explorer-view": { - "properties": { - "chartOptions": { - "properties": { - "stack": { - "type": "boolean" - }, - "type": { - "type": "keyword" - }, - "yAxisMode": { - "type": "keyword" - } - } - }, - "currentTimerange": { - "properties": { - "from": { - "type": "keyword" - }, - "interval": { - "type": "keyword" - }, - "to": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "options": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "filterQuery": { - "type": "keyword" - }, - "groupBy": { - "type": "keyword" - }, - "limit": { - "type": "integer" - }, - "metrics": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "color": { - "type": "keyword" - }, - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - } - } - } - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "space": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "ml-telemetry": { - "properties": { - "file_data_visualizer": { - "properties": { - "index_creation_count": { - "type": "long" - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, - "query": { - "properties": { - "description": { - "type": "text" - }, - "filters": { - "enabled": false, - "type": "object" - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "index": false, - "type": "keyword" - } - } - }, - "timefilter": { - "enabled": false, - "type": "object" - }, - "title": { - "type": "text" - } - } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "sample-data-telemetry": { - "properties": { - "installCount": { - "type": "long" - }, - "unInstallCount": { - "type": "long" - } - } - }, - "search": { - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "siem-detection-engine-rule-status": { - "properties": { - "alertId": { - "type": "keyword" - }, - "lastFailureAt": { - "type": "date" - }, - "lastFailureMessage": { - "type": "text" - }, - "lastSuccessAt": { - "type": "date" - }, - "lastSuccessMessage": { - "type": "text" - }, - "status": { - "type": "keyword" - }, - "statusDate": { - "type": "date" - } - } - }, - "siem-ui-timeline": { - "properties": { - "columns": { - "properties": { - "aggregatable": { - "type": "boolean" - }, - "category": { - "type": "keyword" - }, - "columnHeaderType": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "example": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "indexes": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "placeholder": { - "type": "text" - }, - "searchable": { - "type": "boolean" - }, - "type": { - "type": "keyword" - } - } - }, - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "dataProviders": { - "properties": { - "and": { - "properties": { - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "dateRange": { - "properties": { - "end": { - "type": "date" - }, - "start": { - "type": "date" - } - } - }, - "description": { - "type": "text" - }, - "eventType": { - "type": "keyword" - }, - "favorite": { - "properties": { - "favoriteDate": { - "type": "date" - }, - "fullName": { - "type": "text" - }, - "keySearch": { - "type": "text" - }, - "userName": { - "type": "text" - } - } - }, - "filters": { - "properties": { - "exists": { - "type": "text" - }, - "match_all": { - "type": "text" - }, - "meta": { - "properties": { - "alias": { - "type": "text" - }, - "controlledBy": { - "type": "text" - }, - "disabled": { - "type": "boolean" - }, - "field": { - "type": "text" - }, - "formattedValue": { - "type": "text" - }, - "index": { - "type": "keyword" - }, - "key": { - "type": "keyword" - }, - "negate": { - "type": "boolean" - }, - "params": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "value": { - "type": "text" - } - } - }, - "missing": { - "type": "text" - }, - "query": { - "type": "text" - }, - "range": { - "type": "text" - }, - "script": { - "type": "text" - } - } - }, - "kqlMode": { - "type": "keyword" - }, - "kqlQuery": { - "properties": { - "filterQuery": { - "properties": { - "kuery": { - "properties": { - "expression": { - "type": "text" - }, - "kind": { - "type": "keyword" - } - } - }, - "serializedQuery": { - "type": "text" - } - } - } - } - }, - "savedQueryId": { - "type": "keyword" - }, - "sort": { - "properties": { - "columnId": { - "type": "keyword" - }, - "sortDirection": { - "type": "keyword" - } - } - }, - "title": { - "type": "text" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-note": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "note": { - "type": "text" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-pinned-event": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "imageUrl": { - "index": false, - "type": "text" - }, - "initials": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - }, - "lastReported": { - "type": "date" - }, - "lastVersionChecked": { - "ignore_above": 256, - "type": "keyword" - }, - "sendUsageFrom": { - "ignore_above": 256, - "type": "keyword" - }, - "userHasSeenNotice": { - "type": "boolean" - } - } - }, - "timelion-sheet": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "timelion_chart_height": { - "type": "integer" - }, - "timelion_columns": { - "type": "integer" - }, - "timelion_interval": { - "type": "keyword" - }, - "timelion_other_interval": { - "type": "keyword" - }, - "timelion_rows": { - "type": "integer" - }, - "timelion_sheet": { - "type": "text" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "tsvb-validation-telemetry": { - "properties": { - "failedRequests": { - "type": "long" - } - } - }, - "type": { - "type": "keyword" - }, - "ui-metric": { - "properties": { - "count": { - "type": "integer" - } - } - }, - "updated_at": { - "type": "date" - }, - "upgrade-assistant-reindex-operation": { - "dynamic": "true", - "properties": { - "indexName": { - "type": "keyword" - }, - "status": { - "type": "integer" - } - } - }, - "upgrade-assistant-telemetry": { - "properties": { - "features": { - "properties": { - "deprecation_logging": { - "properties": { - "enabled": { - "null_value": true, - "type": "boolean" - } - } - } - } - }, - "ui_open": { - "properties": { - "cluster": { - "null_value": 0, - "type": "long" - }, - "indices": { - "null_value": 0, - "type": "long" - }, - "overview": { - "null_value": 0, - "type": "long" - } - } - }, - "ui_reindex": { - "properties": { - "close": { - "null_value": 0, - "type": "long" - }, - "open": { - "null_value": 0, - "type": "long" - }, - "start": { - "null_value": 0, - "type": "long" - }, - "stop": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "url": { - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "visualization": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchRefName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "auto_expand_replicas": "0-1", - "number_of_replicas": "0", - "number_of_shards": "1" - } - } - } -} \ No newline at end of file diff --git a/x-pack/test/functional/es_archives/ml/categorization/data.json.gz b/x-pack/test/functional/es_archives/ml/categorization/data.json.gz index a66b68d815943..30b25cf944db8 100644 Binary files a/x-pack/test/functional/es_archives/ml/categorization/data.json.gz and b/x-pack/test/functional/es_archives/ml/categorization/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/ml/categorization/mappings.json b/x-pack/test/functional/es_archives/ml/categorization/mappings.json index 5c97427b6fb0a..56280dbdf0d57 100644 --- a/x-pack/test/functional/es_archives/ml/categorization/mappings.json +++ b/x-pack/test/functional/es_archives/ml/categorization/mappings.json @@ -2,7 +2,7 @@ "type": "index", "value": { "aliases": {}, - "index": "categorization_functional_test", + "index": "ft_categorization", "mappings": { "properties": { "@timestamp": { @@ -39,835 +39,3 @@ } } } - -{ - "type": "index", - "value": { - "aliases": { - ".kibana": {} - }, - "index": ".kibana_1", - "mappings": { - "_meta": { - "migrationMappingPropertyHashes": { - "action": "c0c235fba02ebd2a2412bcda79009b58", - "action_task_params": "a9d49f184ee89641044be0ca2950fa3a", - "alert": "e588043a01d3d43477e7cad7efa0f5d8", - "apm-indices": "9bb9b2bf1fa636ed8619cbab5ce6a1dd", - "apm-services-telemetry": "07ee1939fa4302c62ddc052ec03fed90", - "config": "87aca8fdb053154f11383fce3dbf3edf", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", - "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", - "lens": "21c3ea0763beb1ecb0162529706b88c5", - "lens-ui-telemetry": "509bfa5978586998e05f9e303c07a327", - "map": "23d7aa4a720d4938ccde3983f87bd58d", - "maps-telemetry": "268da3a48066123fc5baf35abaa55014", - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", - "namespace": "2f4316de49999235636386fe51dc06c1", - "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", - "references": "7997cf5a56cc02bdc9c93361bde732b0", - "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", - "server": "ec97f1c5da1a19609a60874e5af1100c", - "space": "c5ca8acafa0beaa4d08d014a97b6bc6b", - "telemetry": "358ffaa88ba34a97d55af0933a117de4", - "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "tsvb-validation-telemetry": "3a37ef6c8700ae6fc97d5c7da00e9215", - "type": "2f4316de49999235636386fe51dc06c1", - "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", - "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", - "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", - "url": "c7f66a0df8b1b52f17c28c4adb111105", - "visualization": "52d7a13ad68a150c4525b292d23e12cc" - } - }, - "dynamic": "strict", - "properties": { - "action": { - "properties": { - "actionTypeId": { - "type": "keyword" - }, - "config": { - "enabled": false, - "type": "object" - }, - "name": { - "type": "text" - }, - "secrets": { - "type": "binary" - } - } - }, - "action_task_params": { - "properties": { - "actionId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "params": { - "enabled": false, - "type": "object" - } - } - }, - "alert": { - "properties": { - "actions": { - "properties": { - "actionRef": { - "type": "keyword" - }, - "actionTypeId": { - "type": "keyword" - }, - "group": { - "type": "keyword" - }, - "params": { - "enabled": false, - "type": "object" - } - }, - "type": "nested" - }, - "alertTypeId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "apiKeyOwner": { - "type": "keyword" - }, - "consumer": { - "type": "keyword" - }, - "createdAt": { - "type": "date" - }, - "createdBy": { - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "muteAll": { - "type": "boolean" - }, - "mutedInstanceIds": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "params": { - "enabled": false, - "type": "object" - }, - "schedule": { - "properties": { - "interval": { - "type": "keyword" - } - } - }, - "scheduledTaskId": { - "type": "keyword" - }, - "tags": { - "type": "keyword" - }, - "throttle": { - "type": "keyword" - }, - "updatedBy": { - "type": "keyword" - } - } - }, - "apm-indices": { - "properties": { - "apm_oss": { - "properties": { - "errorIndices": { - "type": "keyword" - }, - "metricsIndices": { - "type": "keyword" - }, - "onboardingIndices": { - "type": "keyword" - }, - "sourcemapIndices": { - "type": "keyword" - }, - "spanIndices": { - "type": "keyword" - }, - "transactionIndices": { - "type": "keyword" - } - } - } - } - }, - "apm-services-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "dotnet": { - "null_value": 0, - "type": "long" - }, - "go": { - "null_value": 0, - "type": "long" - }, - "java": { - "null_value": 0, - "type": "long" - }, - "js-base": { - "null_value": 0, - "type": "long" - }, - "nodejs": { - "null_value": 0, - "type": "long" - }, - "python": { - "null_value": 0, - "type": "long" - }, - "ruby": { - "null_value": 0, - "type": "long" - }, - "rum-js": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultIndex": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "dashboard": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "file-upload-telemetry": { - "properties": { - "filesUploadedTotalCount": { - "type": "long" - } - } - }, - "index-pattern": { - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "typeMeta": { - "type": "keyword" - } - } - }, - "kql-telemetry": { - "properties": { - "optInCount": { - "type": "long" - }, - "optOutCount": { - "type": "long" - } - } - }, - "lens": { - "properties": { - "expression": { - "index": false, - "type": "keyword" - }, - "state": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "visualizationType": { - "type": "keyword" - } - } - }, - "lens-ui-telemetry": { - "properties": { - "count": { - "type": "integer" - }, - "date": { - "type": "date" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "map": { - "properties": { - "bounds": { - "type": "geo_shape" - }, - "description": { - "type": "text" - }, - "layerListJSON": { - "type": "text" - }, - "mapStateJSON": { - "type": "text" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "maps-telemetry": { - "properties": { - "attributesPerMap": { - "properties": { - "dataSourcesCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - }, - "emsVectorLayersCount": { - "dynamic": "true", - "type": "object" - }, - "layerTypesCount": { - "dynamic": "true", - "type": "object" - }, - "layersCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - } - } - }, - "indexPatternsWithGeoFieldCount": { - "type": "long" - }, - "mapsTotalCount": { - "type": "long" - }, - "settings": { - "properties": { - "showMapVisualizationTypes": { - "type": "boolean" - } - } - }, - "timeCaptured": { - "type": "date" - } - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "space": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "ml-telemetry": { - "properties": { - "file_data_visualizer": { - "properties": { - "index_creation_count": { - "type": "long" - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, - "query": { - "properties": { - "description": { - "type": "text" - }, - "filters": { - "enabled": false, - "type": "object" - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "index": false, - "type": "keyword" - } - } - }, - "timefilter": { - "enabled": false, - "type": "object" - }, - "title": { - "type": "text" - } - } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "sample-data-telemetry": { - "properties": { - "installCount": { - "type": "long" - }, - "unInstallCount": { - "type": "long" - } - } - }, - "search": { - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "imageUrl": { - "index": false, - "type": "text" - }, - "initials": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - }, - "lastReported": { - "type": "date" - }, - "lastVersionChecked": { - "ignore_above": 256, - "type": "keyword" - }, - "sendUsageFrom": { - "ignore_above": 256, - "type": "keyword" - }, - "userHasSeenNotice": { - "type": "boolean" - } - } - }, - "timelion-sheet": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "timelion_chart_height": { - "type": "integer" - }, - "timelion_columns": { - "type": "integer" - }, - "timelion_interval": { - "type": "keyword" - }, - "timelion_other_interval": { - "type": "keyword" - }, - "timelion_rows": { - "type": "integer" - }, - "timelion_sheet": { - "type": "text" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "tsvb-validation-telemetry": { - "properties": { - "failedRequests": { - "type": "long" - } - } - }, - "type": { - "type": "keyword" - }, - "ui-metric": { - "properties": { - "count": { - "type": "integer" - } - } - }, - "updated_at": { - "type": "date" - }, - "upgrade-assistant-reindex-operation": { - "dynamic": "true", - "properties": { - "indexName": { - "type": "keyword" - }, - "status": { - "type": "integer" - } - } - }, - "upgrade-assistant-telemetry": { - "properties": { - "features": { - "properties": { - "deprecation_logging": { - "properties": { - "enabled": { - "null_value": true, - "type": "boolean" - } - } - } - } - }, - "ui_open": { - "properties": { - "cluster": { - "null_value": 0, - "type": "long" - }, - "indices": { - "null_value": 0, - "type": "long" - }, - "overview": { - "null_value": 0, - "type": "long" - } - } - }, - "ui_reindex": { - "properties": { - "close": { - "null_value": 0, - "type": "long" - }, - "open": { - "null_value": 0, - "type": "long" - }, - "start": { - "null_value": 0, - "type": "long" - }, - "stop": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "url": { - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "visualization": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchRefName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "auto_expand_replicas": "0-1", - "number_of_replicas": "0", - "number_of_shards": "1" - } - } - } -} diff --git a/x-pack/test/functional/es_archives/ml/ecommerce/data.json.gz b/x-pack/test/functional/es_archives/ml/ecommerce/data.json.gz index b38981c03417e..75fbf6fcdb845 100644 Binary files a/x-pack/test/functional/es_archives/ml/ecommerce/data.json.gz and b/x-pack/test/functional/es_archives/ml/ecommerce/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/ml/ecommerce/mappings.json b/x-pack/test/functional/es_archives/ml/ecommerce/mappings.json index 9e3275bd40bfe..2910c4639162b 100644 --- a/x-pack/test/functional/es_archives/ml/ecommerce/mappings.json +++ b/x-pack/test/functional/es_archives/ml/ecommerce/mappings.json @@ -3,7 +3,7 @@ "value": { "aliases": { }, - "index": "ecommerce", + "index": "ft_ecommerce", "mappings": { "properties": { "category": { @@ -209,1018 +209,3 @@ } } } - -{ - "type": "index", - "value": { - "aliases": { - ".kibana": { - } - }, - "index": ".kibana_1", - "mappings": { - "_meta": { - "migrationMappingPropertyHashes": { - "apm-telemetry": "07ee1939fa4302c62ddc052ec03fed90", - "canvas-element": "7390014e1091044523666d97247392fc", - "canvas-workpad": "b0a1706d356228dbdcb4a17e6b9eb231", - "config": "87aca8fdb053154f11383fce3dbf3edf", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", - "graph-workspace": "cd7ba1330e6682e9cc00b78850874be1", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", - "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", - "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", - "map": "23d7aa4a720d4938ccde3983f87bd58d", - "maps-telemetry": "a4229f8b16a6820c6d724b7e0c1f729d", - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", - "namespace": "2f4316de49999235636386fe51dc06c1", - "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", - "references": "7997cf5a56cc02bdc9c93361bde732b0", - "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", - "server": "ec97f1c5da1a19609a60874e5af1100c", - "siem-ui-timeline": "1f6f0860ad7bc0dba3e42467ca40470d", - "siem-ui-timeline-note": "8874706eedc49059d4cf0f5094559084", - "siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29", - "space": "25de8c2deec044392922989cfcf24c54", - "telemetry": "e1c8bc94e443aefd9458932cc0697a4d", - "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "type": "2f4316de49999235636386fe51dc06c1", - "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", - "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", - "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", - "url": "c7f66a0df8b1b52f17c28c4adb111105", - "visualization": "52d7a13ad68a150c4525b292d23e12cc" - } - }, - "dynamic": "strict", - "properties": { - "apm-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "dotnet": { - "null_value": 0, - "type": "long" - }, - "go": { - "null_value": 0, - "type": "long" - }, - "java": { - "null_value": 0, - "type": "long" - }, - "js-base": { - "null_value": 0, - "type": "long" - }, - "nodejs": { - "null_value": 0, - "type": "long" - }, - "python": { - "null_value": 0, - "type": "long" - }, - "ruby": { - "null_value": 0, - "type": "long" - }, - "rum-js": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "canvas-element": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "content": { - "type": "text" - }, - "help": { - "type": "text" - }, - "image": { - "type": "text" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "canvas-workpad": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultIndex": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "dashboard": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "file-upload-telemetry": { - "properties": { - "filesUploadedTotalCount": { - "type": "long" - } - } - }, - "graph-workspace": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" - } - } - }, - "index-pattern": { - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "typeMeta": { - "type": "keyword" - } - } - }, - "infrastructure-ui-source": { - "properties": { - "description": { - "type": "text" - }, - "fields": { - "properties": { - "container": { - "type": "keyword" - }, - "host": { - "type": "keyword" - }, - "pod": { - "type": "keyword" - }, - "tiebreaker": { - "type": "keyword" - }, - "timestamp": { - "type": "keyword" - } - } - }, - "logAlias": { - "type": "keyword" - }, - "logColumns": { - "properties": { - "fieldColumn": { - "properties": { - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - } - } - }, - "messageColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - }, - "timestampColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - } - }, - "type": "nested" - }, - "metricAlias": { - "type": "keyword" - }, - "name": { - "type": "text" - } - } - }, - "kql-telemetry": { - "properties": { - "optInCount": { - "type": "long" - }, - "optOutCount": { - "type": "long" - } - } - }, - "map": { - "properties": { - "bounds": { - "type": "geo_shape" - }, - "description": { - "type": "text" - }, - "layerListJSON": { - "type": "text" - }, - "mapStateJSON": { - "type": "text" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "maps-telemetry": { - "properties": { - "attributesPerMap": { - "properties": { - "dataSourcesCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - }, - "emsVectorLayersCount": { - "dynamic": "true", - "type": "object" - }, - "layerTypesCount": { - "dynamic": "true", - "type": "object" - }, - "layersCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - } - } - }, - "mapsTotalCount": { - "type": "long" - }, - "timeCaptured": { - "type": "date" - } - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "space": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "ml-telemetry": { - "properties": { - "file_data_visualizer": { - "properties": { - "index_creation_count": { - "type": "long" - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, - "query": { - "properties": { - "description": { - "type": "text" - }, - "filters": { - "enabled": false, - "type": "object" - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "index": false, - "type": "keyword" - } - } - }, - "timefilter": { - "enabled": false, - "type": "object" - }, - "title": { - "type": "text" - } - } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "sample-data-telemetry": { - "properties": { - "installCount": { - "type": "long" - }, - "unInstallCount": { - "type": "long" - } - } - }, - "search": { - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "siem-ui-timeline": { - "properties": { - "columns": { - "properties": { - "aggregatable": { - "type": "boolean" - }, - "category": { - "type": "keyword" - }, - "columnHeaderType": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "example": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "indexes": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "placeholder": { - "type": "text" - }, - "searchable": { - "type": "boolean" - }, - "type": { - "type": "keyword" - } - } - }, - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "dataProviders": { - "properties": { - "and": { - "properties": { - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "dateRange": { - "properties": { - "end": { - "type": "date" - }, - "start": { - "type": "date" - } - } - }, - "description": { - "type": "text" - }, - "favorite": { - "properties": { - "favoriteDate": { - "type": "date" - }, - "fullName": { - "type": "text" - }, - "keySearch": { - "type": "text" - }, - "userName": { - "type": "text" - } - } - }, - "kqlMode": { - "type": "keyword" - }, - "kqlQuery": { - "properties": { - "filterQuery": { - "properties": { - "kuery": { - "properties": { - "expression": { - "type": "text" - }, - "kind": { - "type": "keyword" - } - } - }, - "serializedQuery": { - "type": "text" - } - } - } - } - }, - "sort": { - "properties": { - "columnId": { - "type": "keyword" - }, - "sortDirection": { - "type": "keyword" - } - } - }, - "title": { - "type": "text" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-note": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "note": { - "type": "text" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-pinned-event": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "initials": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - } - } - }, - "timelion-sheet": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "timelion_chart_height": { - "type": "integer" - }, - "timelion_columns": { - "type": "integer" - }, - "timelion_interval": { - "type": "keyword" - }, - "timelion_other_interval": { - "type": "keyword" - }, - "timelion_rows": { - "type": "integer" - }, - "timelion_sheet": { - "type": "text" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "type": { - "type": "keyword" - }, - "ui-metric": { - "properties": { - "count": { - "type": "integer" - } - } - }, - "updated_at": { - "type": "date" - }, - "upgrade-assistant-reindex-operation": { - "dynamic": "true", - "properties": { - "indexName": { - "type": "keyword" - }, - "status": { - "type": "integer" - } - } - }, - "upgrade-assistant-telemetry": { - "properties": { - "features": { - "properties": { - "deprecation_logging": { - "properties": { - "enabled": { - "null_value": true, - "type": "boolean" - } - } - } - } - }, - "ui_open": { - "properties": { - "cluster": { - "null_value": 0, - "type": "long" - }, - "indices": { - "null_value": 0, - "type": "long" - }, - "overview": { - "null_value": 0, - "type": "long" - } - } - }, - "ui_reindex": { - "properties": { - "close": { - "null_value": 0, - "type": "long" - }, - "open": { - "null_value": 0, - "type": "long" - }, - "start": { - "null_value": 0, - "type": "long" - }, - "stop": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "url": { - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "visualization": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchRefName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "auto_expand_replicas": "0-1", - "number_of_replicas": "0", - "number_of_shards": "1" - } - } - } -} \ No newline at end of file diff --git a/x-pack/test/functional/es_archives/ml/egs_regression/data.json.gz b/x-pack/test/functional/es_archives/ml/egs_regression/data.json.gz index 78a8b65b4a124..477c2e638ee0f 100644 Binary files a/x-pack/test/functional/es_archives/ml/egs_regression/data.json.gz and b/x-pack/test/functional/es_archives/ml/egs_regression/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/ml/egs_regression/mappings.json b/x-pack/test/functional/es_archives/ml/egs_regression/mappings.json index bfaecc6820469..72a411819b0ac 100644 --- a/x-pack/test/functional/es_archives/ml/egs_regression/mappings.json +++ b/x-pack/test/functional/es_archives/ml/egs_regression/mappings.json @@ -3,7 +3,7 @@ "value": { "aliases": { }, - "index": "egs_regression", + "index": "ft_egs_regression", "mappings": { "properties": { "g1": { @@ -58,1395 +58,3 @@ } } } - -{ - "type": "index", - "value": { - "aliases": { - ".kibana": { - } - }, - "index": ".kibana_1", - "mappings": { - "_meta": { - "migrationMappingPropertyHashes": { - "action": "ecc01e367a369542bc2b15dae1fb1773", - "action_task_params": "a9d49f184ee89641044be0ca2950fa3a", - "alert": "3cdf52bff6f482e53b825b45686604db", - "apm-indices": "9bb9b2bf1fa636ed8619cbab5ce6a1dd", - "apm-services-telemetry": "07ee1939fa4302c62ddc052ec03fed90", - "canvas-element": "7390014e1091044523666d97247392fc", - "canvas-workpad": "b0a1706d356228dbdcb4a17e6b9eb231", - "config": "87aca8fdb053154f11383fce3dbf3edf", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", - "graph-workspace": "cd7ba1330e6682e9cc00b78850874be1", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", - "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", - "inventory-view": "84b320fd67209906333ffce261128462", - "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", - "lens": "21c3ea0763beb1ecb0162529706b88c5", - "lens-ui-telemetry": "509bfa5978586998e05f9e303c07a327", - "map": "23d7aa4a720d4938ccde3983f87bd58d", - "maps-telemetry": "a4229f8b16a6820c6d724b7e0c1f729d", - "metrics-explorer-view": "53c5365793677328df0ccb6138bf3cdd", - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", - "namespace": "2f4316de49999235636386fe51dc06c1", - "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", - "references": "7997cf5a56cc02bdc9c93361bde732b0", - "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", - "server": "ec97f1c5da1a19609a60874e5af1100c", - "siem-ui-timeline": "6485ab095be8d15246667b98a1a34295", - "siem-ui-timeline-note": "8874706eedc49059d4cf0f5094559084", - "siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29", - "space": "c5ca8acafa0beaa4d08d014a97b6bc6b", - "telemetry": "358ffaa88ba34a97d55af0933a117de4", - "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "type": "2f4316de49999235636386fe51dc06c1", - "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", - "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", - "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", - "url": "c7f66a0df8b1b52f17c28c4adb111105", - "visualization": "52d7a13ad68a150c4525b292d23e12cc" - } - }, - "dynamic": "strict", - "properties": { - "action": { - "properties": { - "actionTypeId": { - "type": "keyword" - }, - "config": { - "enabled": false, - "type": "object" - }, - "description": { - "type": "text" - }, - "secrets": { - "type": "binary" - } - } - }, - "action_task_params": { - "properties": { - "actionId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "params": { - "enabled": false, - "type": "object" - } - } - }, - "alert": { - "properties": { - "actions": { - "properties": { - "actionRef": { - "type": "keyword" - }, - "group": { - "type": "keyword" - }, - "params": { - "enabled": false, - "type": "object" - } - }, - "type": "nested" - }, - "alertTypeId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "apiKeyOwner": { - "type": "keyword" - }, - "createdBy": { - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "interval": { - "type": "keyword" - }, - "muteAll": { - "type": "boolean" - }, - "mutedInstanceIds": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "params": { - "enabled": false, - "type": "object" - }, - "scheduledTaskId": { - "type": "keyword" - }, - "tags": { - "type": "keyword" - }, - "throttle": { - "type": "keyword" - }, - "updatedBy": { - "type": "keyword" - } - } - }, - "apm-indices": { - "properties": { - "apm_oss": { - "properties": { - "errorIndices": { - "type": "keyword" - }, - "metricsIndices": { - "type": "keyword" - }, - "onboardingIndices": { - "type": "keyword" - }, - "sourcemapIndices": { - "type": "keyword" - }, - "spanIndices": { - "type": "keyword" - }, - "transactionIndices": { - "type": "keyword" - } - } - } - } - }, - "apm-services-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "dotnet": { - "null_value": 0, - "type": "long" - }, - "go": { - "null_value": 0, - "type": "long" - }, - "java": { - "null_value": 0, - "type": "long" - }, - "js-base": { - "null_value": 0, - "type": "long" - }, - "nodejs": { - "null_value": 0, - "type": "long" - }, - "python": { - "null_value": 0, - "type": "long" - }, - "ruby": { - "null_value": 0, - "type": "long" - }, - "rum-js": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "canvas-element": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "content": { - "type": "text" - }, - "help": { - "type": "text" - }, - "image": { - "type": "text" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "canvas-workpad": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultIndex": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "dashboard": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "file-upload-telemetry": { - "properties": { - "filesUploadedTotalCount": { - "type": "long" - } - } - }, - "graph-workspace": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" - } - } - }, - "index-pattern": { - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "typeMeta": { - "type": "keyword" - } - } - }, - "infrastructure-ui-source": { - "properties": { - "description": { - "type": "text" - }, - "fields": { - "properties": { - "container": { - "type": "keyword" - }, - "host": { - "type": "keyword" - }, - "pod": { - "type": "keyword" - }, - "tiebreaker": { - "type": "keyword" - }, - "timestamp": { - "type": "keyword" - } - } - }, - "logAlias": { - "type": "keyword" - }, - "logColumns": { - "properties": { - "fieldColumn": { - "properties": { - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - } - } - }, - "messageColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - }, - "timestampColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - } - }, - "type": "nested" - }, - "metricAlias": { - "type": "keyword" - }, - "name": { - "type": "text" - } - } - }, - "inventory-view": { - "properties": { - "autoBounds": { - "type": "boolean" - }, - "autoReload": { - "type": "boolean" - }, - "boundsOverride": { - "properties": { - "max": { - "type": "integer" - }, - "min": { - "type": "integer" - } - } - }, - "customOptions": { - "properties": { - "field": { - "type": "keyword" - }, - "text": { - "type": "keyword" - } - }, - "type": "nested" - }, - "filterQuery": { - "properties": { - "expression": { - "type": "keyword" - }, - "kind": { - "type": "keyword" - } - } - }, - "groupBy": { - "properties": { - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - }, - "metric": { - "properties": { - "type": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "nodeType": { - "type": "keyword" - }, - "time": { - "type": "integer" - }, - "view": { - "type": "keyword" - } - } - }, - "kql-telemetry": { - "properties": { - "optInCount": { - "type": "long" - }, - "optOutCount": { - "type": "long" - } - } - }, - "lens": { - "properties": { - "expression": { - "index": false, - "type": "keyword" - }, - "state": { - "type": "flattened" - }, - "title": { - "type": "text" - }, - "visualizationType": { - "type": "keyword" - } - } - }, - "lens-ui-telemetry": { - "properties": { - "count": { - "type": "integer" - }, - "date": { - "type": "date" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "map": { - "properties": { - "bounds": { - "type": "geo_shape" - }, - "description": { - "type": "text" - }, - "layerListJSON": { - "type": "text" - }, - "mapStateJSON": { - "type": "text" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "maps-telemetry": { - "properties": { - "attributesPerMap": { - "properties": { - "dataSourcesCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - }, - "emsVectorLayersCount": { - "dynamic": "true", - "type": "object" - }, - "layerTypesCount": { - "dynamic": "true", - "type": "object" - }, - "layersCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - } - } - }, - "mapsTotalCount": { - "type": "long" - }, - "timeCaptured": { - "type": "date" - } - } - }, - "metrics-explorer-view": { - "properties": { - "chartOptions": { - "properties": { - "stack": { - "type": "boolean" - }, - "type": { - "type": "keyword" - }, - "yAxisMode": { - "type": "keyword" - } - } - }, - "currentTimerange": { - "properties": { - "from": { - "type": "keyword" - }, - "interval": { - "type": "keyword" - }, - "to": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "options": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "filterQuery": { - "type": "keyword" - }, - "groupBy": { - "type": "keyword" - }, - "limit": { - "type": "integer" - }, - "metrics": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "color": { - "type": "keyword" - }, - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - } - } - } - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "space": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "ml-telemetry": { - "properties": { - "file_data_visualizer": { - "properties": { - "index_creation_count": { - "type": "long" - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, - "query": { - "properties": { - "description": { - "type": "text" - }, - "filters": { - "enabled": false, - "type": "object" - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "index": false, - "type": "keyword" - } - } - }, - "timefilter": { - "enabled": false, - "type": "object" - }, - "title": { - "type": "text" - } - } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "sample-data-telemetry": { - "properties": { - "installCount": { - "type": "long" - }, - "unInstallCount": { - "type": "long" - } - } - }, - "search": { - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "siem-ui-timeline": { - "properties": { - "columns": { - "properties": { - "aggregatable": { - "type": "boolean" - }, - "category": { - "type": "keyword" - }, - "columnHeaderType": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "example": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "indexes": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "placeholder": { - "type": "text" - }, - "searchable": { - "type": "boolean" - }, - "type": { - "type": "keyword" - } - } - }, - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "dataProviders": { - "properties": { - "and": { - "properties": { - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "dateRange": { - "properties": { - "end": { - "type": "date" - }, - "start": { - "type": "date" - } - } - }, - "description": { - "type": "text" - }, - "favorite": { - "properties": { - "favoriteDate": { - "type": "date" - }, - "fullName": { - "type": "text" - }, - "keySearch": { - "type": "text" - }, - "userName": { - "type": "text" - } - } - }, - "filters": { - "properties": { - "exists": { - "type": "text" - }, - "match_all": { - "type": "text" - }, - "meta": { - "properties": { - "alias": { - "type": "text" - }, - "controlledBy": { - "type": "text" - }, - "disabled": { - "type": "boolean" - }, - "field": { - "type": "text" - }, - "formattedValue": { - "type": "text" - }, - "index": { - "type": "keyword" - }, - "key": { - "type": "keyword" - }, - "negate": { - "type": "boolean" - }, - "params": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "value": { - "type": "text" - } - } - }, - "missing": { - "type": "text" - }, - "query": { - "type": "text" - }, - "range": { - "type": "text" - }, - "script": { - "type": "text" - } - } - }, - "kqlMode": { - "type": "keyword" - }, - "kqlQuery": { - "properties": { - "filterQuery": { - "properties": { - "kuery": { - "properties": { - "expression": { - "type": "text" - }, - "kind": { - "type": "keyword" - } - } - }, - "serializedQuery": { - "type": "text" - } - } - } - } - }, - "savedQueryId": { - "type": "keyword" - }, - "sort": { - "properties": { - "columnId": { - "type": "keyword" - }, - "sortDirection": { - "type": "keyword" - } - } - }, - "title": { - "type": "text" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-note": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "note": { - "type": "text" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-pinned-event": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "imageUrl": { - "index": false, - "type": "text" - }, - "initials": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - }, - "lastReported": { - "type": "date" - }, - "lastVersionChecked": { - "ignore_above": 256, - "type": "keyword" - }, - "sendUsageFrom": { - "ignore_above": 256, - "type": "keyword" - }, - "userHasSeenNotice": { - "type": "boolean" - } - } - }, - "timelion-sheet": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "timelion_chart_height": { - "type": "integer" - }, - "timelion_columns": { - "type": "integer" - }, - "timelion_interval": { - "type": "keyword" - }, - "timelion_other_interval": { - "type": "keyword" - }, - "timelion_rows": { - "type": "integer" - }, - "timelion_sheet": { - "type": "text" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "type": { - "type": "keyword" - }, - "ui-metric": { - "properties": { - "count": { - "type": "integer" - } - } - }, - "updated_at": { - "type": "date" - }, - "upgrade-assistant-reindex-operation": { - "dynamic": "true", - "properties": { - "indexName": { - "type": "keyword" - }, - "status": { - "type": "integer" - } - } - }, - "upgrade-assistant-telemetry": { - "properties": { - "features": { - "properties": { - "deprecation_logging": { - "properties": { - "enabled": { - "null_value": true, - "type": "boolean" - } - } - } - } - }, - "ui_open": { - "properties": { - "cluster": { - "null_value": 0, - "type": "long" - }, - "indices": { - "null_value": 0, - "type": "long" - }, - "overview": { - "null_value": 0, - "type": "long" - } - } - }, - "ui_reindex": { - "properties": { - "close": { - "null_value": 0, - "type": "long" - }, - "open": { - "null_value": 0, - "type": "long" - }, - "start": { - "null_value": 0, - "type": "long" - }, - "stop": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "url": { - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "visualization": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchRefName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "auto_expand_replicas": "0-1", - "number_of_replicas": "0", - "number_of_shards": "1" - } - } - } -} \ No newline at end of file diff --git a/x-pack/test/functional/es_archives/ml/event_rate_nanos/data.json.gz b/x-pack/test/functional/es_archives/ml/event_rate_nanos/data.json.gz index 838b8d1872c0a..6170d9affd5a6 100644 Binary files a/x-pack/test/functional/es_archives/ml/event_rate_nanos/data.json.gz and b/x-pack/test/functional/es_archives/ml/event_rate_nanos/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/ml/event_rate_nanos/mappings.json b/x-pack/test/functional/es_archives/ml/event_rate_nanos/mappings.json index 6897e05e75c2e..dbed30f3f855c 100644 --- a/x-pack/test/functional/es_archives/ml/event_rate_nanos/mappings.json +++ b/x-pack/test/functional/es_archives/ml/event_rate_nanos/mappings.json @@ -3,7 +3,7 @@ "value": { "aliases": { }, - "index": "event_rate_gen_trend_nanos", + "index": "ft_event_rate_gen_trend_nanos", "mappings": { "properties": { "@timestamp": { @@ -23,1455 +23,3 @@ } } } - -{ - "type": "index", - "value": { - "aliases": { - ".kibana": { - } - }, - "index": ".kibana_1", - "mappings": { - "_meta": { - "migrationMappingPropertyHashes": { - "action": "c0c235fba02ebd2a2412bcda79009b58", - "action_task_params": "a9d49f184ee89641044be0ca2950fa3a", - "alert": "e588043a01d3d43477e7cad7efa0f5d8", - "apm-indices": "9bb9b2bf1fa636ed8619cbab5ce6a1dd", - "apm-services-telemetry": "07ee1939fa4302c62ddc052ec03fed90", - "canvas-element": "7390014e1091044523666d97247392fc", - "canvas-workpad": "b0a1706d356228dbdcb4a17e6b9eb231", - "config": "87aca8fdb053154f11383fce3dbf3edf", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", - "graph-workspace": "cd7ba1330e6682e9cc00b78850874be1", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", - "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", - "inventory-view": "84b320fd67209906333ffce261128462", - "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", - "lens": "21c3ea0763beb1ecb0162529706b88c5", - "lens-ui-telemetry": "509bfa5978586998e05f9e303c07a327", - "map": "23d7aa4a720d4938ccde3983f87bd58d", - "maps-telemetry": "268da3a48066123fc5baf35abaa55014", - "metrics-explorer-view": "53c5365793677328df0ccb6138bf3cdd", - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", - "namespace": "2f4316de49999235636386fe51dc06c1", - "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", - "references": "7997cf5a56cc02bdc9c93361bde732b0", - "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", - "server": "ec97f1c5da1a19609a60874e5af1100c", - "siem-detection-engine-rule-status": "0367e4d775814b56a4bee29384f9aafe", - "siem-ui-timeline": "ac8020190f5950dd3250b6499144e7fb", - "siem-ui-timeline-note": "8874706eedc49059d4cf0f5094559084", - "siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29", - "space": "c5ca8acafa0beaa4d08d014a97b6bc6b", - "telemetry": "358ffaa88ba34a97d55af0933a117de4", - "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "tsvb-validation-telemetry": "3a37ef6c8700ae6fc97d5c7da00e9215", - "type": "2f4316de49999235636386fe51dc06c1", - "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", - "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", - "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", - "url": "c7f66a0df8b1b52f17c28c4adb111105", - "visualization": "52d7a13ad68a150c4525b292d23e12cc" - } - }, - "dynamic": "strict", - "properties": { - "action": { - "properties": { - "actionTypeId": { - "type": "keyword" - }, - "config": { - "enabled": false, - "type": "object" - }, - "name": { - "type": "text" - }, - "secrets": { - "type": "binary" - } - } - }, - "action_task_params": { - "properties": { - "actionId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "params": { - "enabled": false, - "type": "object" - } - } - }, - "alert": { - "properties": { - "actions": { - "properties": { - "actionRef": { - "type": "keyword" - }, - "actionTypeId": { - "type": "keyword" - }, - "group": { - "type": "keyword" - }, - "params": { - "enabled": false, - "type": "object" - } - }, - "type": "nested" - }, - "alertTypeId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "apiKeyOwner": { - "type": "keyword" - }, - "consumer": { - "type": "keyword" - }, - "createdAt": { - "type": "date" - }, - "createdBy": { - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "muteAll": { - "type": "boolean" - }, - "mutedInstanceIds": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "params": { - "enabled": false, - "type": "object" - }, - "schedule": { - "properties": { - "interval": { - "type": "keyword" - } - } - }, - "scheduledTaskId": { - "type": "keyword" - }, - "tags": { - "type": "keyword" - }, - "throttle": { - "type": "keyword" - }, - "updatedBy": { - "type": "keyword" - } - } - }, - "apm-indices": { - "properties": { - "apm_oss": { - "properties": { - "errorIndices": { - "type": "keyword" - }, - "metricsIndices": { - "type": "keyword" - }, - "onboardingIndices": { - "type": "keyword" - }, - "sourcemapIndices": { - "type": "keyword" - }, - "spanIndices": { - "type": "keyword" - }, - "transactionIndices": { - "type": "keyword" - } - } - } - } - }, - "apm-services-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "dotnet": { - "null_value": 0, - "type": "long" - }, - "go": { - "null_value": 0, - "type": "long" - }, - "java": { - "null_value": 0, - "type": "long" - }, - "js-base": { - "null_value": 0, - "type": "long" - }, - "nodejs": { - "null_value": 0, - "type": "long" - }, - "python": { - "null_value": 0, - "type": "long" - }, - "ruby": { - "null_value": 0, - "type": "long" - }, - "rum-js": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "canvas-element": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "content": { - "type": "text" - }, - "help": { - "type": "text" - }, - "image": { - "type": "text" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "canvas-workpad": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultIndex": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "dashboard": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "file-upload-telemetry": { - "properties": { - "filesUploadedTotalCount": { - "type": "long" - } - } - }, - "graph-workspace": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" - } - } - }, - "index-pattern": { - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "typeMeta": { - "type": "keyword" - } - } - }, - "infrastructure-ui-source": { - "properties": { - "description": { - "type": "text" - }, - "fields": { - "properties": { - "container": { - "type": "keyword" - }, - "host": { - "type": "keyword" - }, - "pod": { - "type": "keyword" - }, - "tiebreaker": { - "type": "keyword" - }, - "timestamp": { - "type": "keyword" - } - } - }, - "logAlias": { - "type": "keyword" - }, - "logColumns": { - "properties": { - "fieldColumn": { - "properties": { - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - } - } - }, - "messageColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - }, - "timestampColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - } - }, - "type": "nested" - }, - "metricAlias": { - "type": "keyword" - }, - "name": { - "type": "text" - } - } - }, - "inventory-view": { - "properties": { - "autoBounds": { - "type": "boolean" - }, - "autoReload": { - "type": "boolean" - }, - "boundsOverride": { - "properties": { - "max": { - "type": "integer" - }, - "min": { - "type": "integer" - } - } - }, - "customOptions": { - "properties": { - "field": { - "type": "keyword" - }, - "text": { - "type": "keyword" - } - }, - "type": "nested" - }, - "filterQuery": { - "properties": { - "expression": { - "type": "keyword" - }, - "kind": { - "type": "keyword" - } - } - }, - "groupBy": { - "properties": { - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - }, - "metric": { - "properties": { - "type": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "nodeType": { - "type": "keyword" - }, - "time": { - "type": "integer" - }, - "view": { - "type": "keyword" - } - } - }, - "kql-telemetry": { - "properties": { - "optInCount": { - "type": "long" - }, - "optOutCount": { - "type": "long" - } - } - }, - "lens": { - "properties": { - "expression": { - "index": false, - "type": "keyword" - }, - "state": { - "type": "flattened" - }, - "title": { - "type": "text" - }, - "visualizationType": { - "type": "keyword" - } - } - }, - "lens-ui-telemetry": { - "properties": { - "count": { - "type": "integer" - }, - "date": { - "type": "date" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "map": { - "properties": { - "bounds": { - "type": "geo_shape" - }, - "description": { - "type": "text" - }, - "layerListJSON": { - "type": "text" - }, - "mapStateJSON": { - "type": "text" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "maps-telemetry": { - "properties": { - "attributesPerMap": { - "properties": { - "dataSourcesCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - }, - "emsVectorLayersCount": { - "dynamic": "true", - "type": "object" - }, - "layerTypesCount": { - "dynamic": "true", - "type": "object" - }, - "layersCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - } - } - }, - "indexPatternsWithGeoFieldCount": { - "type": "long" - }, - "mapsTotalCount": { - "type": "long" - }, - "settings": { - "properties": { - "showMapVisualizationTypes": { - "type": "boolean" - } - } - }, - "timeCaptured": { - "type": "date" - } - } - }, - "metrics-explorer-view": { - "properties": { - "chartOptions": { - "properties": { - "stack": { - "type": "boolean" - }, - "type": { - "type": "keyword" - }, - "yAxisMode": { - "type": "keyword" - } - } - }, - "currentTimerange": { - "properties": { - "from": { - "type": "keyword" - }, - "interval": { - "type": "keyword" - }, - "to": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "options": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "filterQuery": { - "type": "keyword" - }, - "groupBy": { - "type": "keyword" - }, - "limit": { - "type": "integer" - }, - "metrics": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "color": { - "type": "keyword" - }, - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - } - } - } - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "space": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "ml-telemetry": { - "properties": { - "file_data_visualizer": { - "properties": { - "index_creation_count": { - "type": "long" - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, - "query": { - "properties": { - "description": { - "type": "text" - }, - "filters": { - "enabled": false, - "type": "object" - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "index": false, - "type": "keyword" - } - } - }, - "timefilter": { - "enabled": false, - "type": "object" - }, - "title": { - "type": "text" - } - } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "sample-data-telemetry": { - "properties": { - "installCount": { - "type": "long" - }, - "unInstallCount": { - "type": "long" - } - } - }, - "search": { - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "siem-detection-engine-rule-status": { - "properties": { - "alertId": { - "type": "keyword" - }, - "lastFailureAt": { - "type": "date" - }, - "lastFailureMessage": { - "type": "text" - }, - "lastSuccessAt": { - "type": "date" - }, - "lastSuccessMessage": { - "type": "text" - }, - "status": { - "type": "keyword" - }, - "statusDate": { - "type": "date" - } - } - }, - "siem-ui-timeline": { - "properties": { - "columns": { - "properties": { - "aggregatable": { - "type": "boolean" - }, - "category": { - "type": "keyword" - }, - "columnHeaderType": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "example": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "indexes": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "placeholder": { - "type": "text" - }, - "searchable": { - "type": "boolean" - }, - "type": { - "type": "keyword" - } - } - }, - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "dataProviders": { - "properties": { - "and": { - "properties": { - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "dateRange": { - "properties": { - "end": { - "type": "date" - }, - "start": { - "type": "date" - } - } - }, - "description": { - "type": "text" - }, - "eventType": { - "type": "keyword" - }, - "favorite": { - "properties": { - "favoriteDate": { - "type": "date" - }, - "fullName": { - "type": "text" - }, - "keySearch": { - "type": "text" - }, - "userName": { - "type": "text" - } - } - }, - "filters": { - "properties": { - "exists": { - "type": "text" - }, - "match_all": { - "type": "text" - }, - "meta": { - "properties": { - "alias": { - "type": "text" - }, - "controlledBy": { - "type": "text" - }, - "disabled": { - "type": "boolean" - }, - "field": { - "type": "text" - }, - "formattedValue": { - "type": "text" - }, - "index": { - "type": "keyword" - }, - "key": { - "type": "keyword" - }, - "negate": { - "type": "boolean" - }, - "params": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "value": { - "type": "text" - } - } - }, - "missing": { - "type": "text" - }, - "query": { - "type": "text" - }, - "range": { - "type": "text" - }, - "script": { - "type": "text" - } - } - }, - "kqlMode": { - "type": "keyword" - }, - "kqlQuery": { - "properties": { - "filterQuery": { - "properties": { - "kuery": { - "properties": { - "expression": { - "type": "text" - }, - "kind": { - "type": "keyword" - } - } - }, - "serializedQuery": { - "type": "text" - } - } - } - } - }, - "savedQueryId": { - "type": "keyword" - }, - "sort": { - "properties": { - "columnId": { - "type": "keyword" - }, - "sortDirection": { - "type": "keyword" - } - } - }, - "title": { - "type": "text" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-note": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "note": { - "type": "text" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-pinned-event": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "imageUrl": { - "index": false, - "type": "text" - }, - "initials": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - }, - "lastReported": { - "type": "date" - }, - "lastVersionChecked": { - "ignore_above": 256, - "type": "keyword" - }, - "sendUsageFrom": { - "ignore_above": 256, - "type": "keyword" - }, - "userHasSeenNotice": { - "type": "boolean" - } - } - }, - "timelion-sheet": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "timelion_chart_height": { - "type": "integer" - }, - "timelion_columns": { - "type": "integer" - }, - "timelion_interval": { - "type": "keyword" - }, - "timelion_other_interval": { - "type": "keyword" - }, - "timelion_rows": { - "type": "integer" - }, - "timelion_sheet": { - "type": "text" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "tsvb-validation-telemetry": { - "properties": { - "failedRequests": { - "type": "long" - } - } - }, - "type": { - "type": "keyword" - }, - "ui-metric": { - "properties": { - "count": { - "type": "integer" - } - } - }, - "updated_at": { - "type": "date" - }, - "upgrade-assistant-reindex-operation": { - "dynamic": "true", - "properties": { - "indexName": { - "type": "keyword" - }, - "status": { - "type": "integer" - } - } - }, - "upgrade-assistant-telemetry": { - "properties": { - "features": { - "properties": { - "deprecation_logging": { - "properties": { - "enabled": { - "null_value": true, - "type": "boolean" - } - } - } - } - }, - "ui_open": { - "properties": { - "cluster": { - "null_value": 0, - "type": "long" - }, - "indices": { - "null_value": 0, - "type": "long" - }, - "overview": { - "null_value": 0, - "type": "long" - } - } - }, - "ui_reindex": { - "properties": { - "close": { - "null_value": 0, - "type": "long" - }, - "open": { - "null_value": 0, - "type": "long" - }, - "start": { - "null_value": 0, - "type": "long" - }, - "stop": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "url": { - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "visualization": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchRefName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "auto_expand_replicas": "0-1", - "number_of_replicas": "0", - "number_of_shards": "1" - } - } - } -} \ No newline at end of file diff --git a/x-pack/test/functional/es_archives/ml/farequote/data.json.gz b/x-pack/test/functional/es_archives/ml/farequote/data.json.gz index 17cf75a4624f7..7b56c3de6954b 100644 Binary files a/x-pack/test/functional/es_archives/ml/farequote/data.json.gz and b/x-pack/test/functional/es_archives/ml/farequote/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/ml/farequote/mappings.json b/x-pack/test/functional/es_archives/ml/farequote/mappings.json index b00545c015a74..1252967ac9679 100644 --- a/x-pack/test/functional/es_archives/ml/farequote/mappings.json +++ b/x-pack/test/functional/es_archives/ml/farequote/mappings.json @@ -3,7 +3,7 @@ "value": { "aliases": { }, - "index": "farequote", + "index": "ft_farequote", "mappings": { "properties": { "@timestamp": { @@ -46,1042 +46,3 @@ } } } - -{ - "type": "index", - "value": { - "aliases": { - ".kibana": { - } - }, - "index": ".kibana_1", - "mappings": { - "_meta": { - "migrationMappingPropertyHashes": { - "action": "ecc01e367a369542bc2b15dae1fb1773", - "alert": "66fb7d877c9f102755357c30c7b98e02", - "apm-telemetry": "07ee1939fa4302c62ddc052ec03fed90", - "canvas-element": "7390014e1091044523666d97247392fc", - "canvas-workpad": "b0a1706d356228dbdcb4a17e6b9eb231", - "config": "87aca8fdb053154f11383fce3dbf3edf", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", - "graph-workspace": "cd7ba1330e6682e9cc00b78850874be1", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", - "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", - "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", - "map": "23d7aa4a720d4938ccde3983f87bd58d", - "maps-telemetry": "a4229f8b16a6820c6d724b7e0c1f729d", - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", - "namespace": "2f4316de49999235636386fe51dc06c1", - "references": "7997cf5a56cc02bdc9c93361bde732b0", - "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", - "server": "ec97f1c5da1a19609a60874e5af1100c", - "siem-ui-timeline": "1f6f0860ad7bc0dba3e42467ca40470d", - "siem-ui-timeline-note": "8874706eedc49059d4cf0f5094559084", - "siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29", - "space": "25de8c2deec044392922989cfcf24c54", - "telemetry": "e1c8bc94e443aefd9458932cc0697a4d", - "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "type": "2f4316de49999235636386fe51dc06c1", - "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", - "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", - "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", - "url": "c7f66a0df8b1b52f17c28c4adb111105", - "visualization": "52d7a13ad68a150c4525b292d23e12cc" - } - }, - "dynamic": "strict", - "properties": { - "action": { - "properties": { - "actionTypeId": { - "type": "keyword" - }, - "config": { - "enabled": false, - "type": "object" - }, - "description": { - "type": "text" - }, - "secrets": { - "type": "binary" - } - } - }, - "alert": { - "properties": { - "actions": { - "properties": { - "actionRef": { - "type": "keyword" - }, - "group": { - "type": "keyword" - }, - "params": { - "enabled": false, - "type": "object" - } - }, - "type": "nested" - }, - "alertTypeId": { - "type": "keyword" - }, - "params": { - "enabled": false, - "type": "object" - }, - "enabled": { - "type": "boolean" - }, - "interval": { - "type": "keyword" - }, - "scheduledTaskId": { - "type": "keyword" - } - } - }, - "apm-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "dotnet": { - "null_value": 0, - "type": "long" - }, - "go": { - "null_value": 0, - "type": "long" - }, - "java": { - "null_value": 0, - "type": "long" - }, - "js-base": { - "null_value": 0, - "type": "long" - }, - "nodejs": { - "null_value": 0, - "type": "long" - }, - "python": { - "null_value": 0, - "type": "long" - }, - "ruby": { - "null_value": 0, - "type": "long" - }, - "rum-js": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "canvas-element": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "content": { - "type": "text" - }, - "help": { - "type": "text" - }, - "image": { - "type": "text" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "canvas-workpad": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultIndex": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "dashboard": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "file-upload-telemetry": { - "properties": { - "filesUploadedTotalCount": { - "type": "long" - } - } - }, - "graph-workspace": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" - } - } - }, - "index-pattern": { - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "typeMeta": { - "type": "keyword" - } - } - }, - "infrastructure-ui-source": { - "properties": { - "description": { - "type": "text" - }, - "fields": { - "properties": { - "container": { - "type": "keyword" - }, - "host": { - "type": "keyword" - }, - "pod": { - "type": "keyword" - }, - "tiebreaker": { - "type": "keyword" - }, - "timestamp": { - "type": "keyword" - } - } - }, - "logAlias": { - "type": "keyword" - }, - "logColumns": { - "properties": { - "fieldColumn": { - "properties": { - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - } - } - }, - "messageColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - }, - "timestampColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - } - }, - "type": "nested" - }, - "metricAlias": { - "type": "keyword" - }, - "name": { - "type": "text" - } - } - }, - "kql-telemetry": { - "properties": { - "optInCount": { - "type": "long" - }, - "optOutCount": { - "type": "long" - } - } - }, - "map": { - "properties": { - "bounds": { - "type": "geo_shape" - }, - "description": { - "type": "text" - }, - "layerListJSON": { - "type": "text" - }, - "mapStateJSON": { - "type": "text" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "maps-telemetry": { - "properties": { - "attributesPerMap": { - "properties": { - "dataSourcesCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - }, - "emsVectorLayersCount": { - "dynamic": "true", - "type": "object" - }, - "layerTypesCount": { - "dynamic": "true", - "type": "object" - }, - "layersCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - } - } - }, - "mapsTotalCount": { - "type": "long" - }, - "timeCaptured": { - "type": "date" - } - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "space": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "ml-telemetry": { - "properties": { - "file_data_visualizer": { - "properties": { - "index_creation_count": { - "type": "long" - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "sample-data-telemetry": { - "properties": { - "installCount": { - "type": "long" - }, - "unInstallCount": { - "type": "long" - } - } - }, - "search": { - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "siem-ui-timeline": { - "properties": { - "columns": { - "properties": { - "aggregatable": { - "type": "boolean" - }, - "category": { - "type": "keyword" - }, - "columnHeaderType": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "example": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "indexes": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "placeholder": { - "type": "text" - }, - "searchable": { - "type": "boolean" - }, - "type": { - "type": "keyword" - } - } - }, - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "dataProviders": { - "properties": { - "and": { - "properties": { - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "dateRange": { - "properties": { - "end": { - "type": "date" - }, - "start": { - "type": "date" - } - } - }, - "description": { - "type": "text" - }, - "favorite": { - "properties": { - "favoriteDate": { - "type": "date" - }, - "fullName": { - "type": "text" - }, - "keySearch": { - "type": "text" - }, - "userName": { - "type": "text" - } - } - }, - "kqlMode": { - "type": "keyword" - }, - "kqlQuery": { - "properties": { - "filterQuery": { - "properties": { - "kuery": { - "properties": { - "expression": { - "type": "text" - }, - "kind": { - "type": "keyword" - } - } - }, - "serializedQuery": { - "type": "text" - } - } - } - } - }, - "sort": { - "properties": { - "columnId": { - "type": "keyword" - }, - "sortDirection": { - "type": "keyword" - } - } - }, - "title": { - "type": "text" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-note": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "note": { - "type": "text" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-pinned-event": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "initials": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - } - } - }, - "timelion-sheet": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "timelion_chart_height": { - "type": "integer" - }, - "timelion_columns": { - "type": "integer" - }, - "timelion_interval": { - "type": "keyword" - }, - "timelion_other_interval": { - "type": "keyword" - }, - "timelion_rows": { - "type": "integer" - }, - "timelion_sheet": { - "type": "text" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "type": { - "type": "keyword" - }, - "ui-metric": { - "properties": { - "count": { - "type": "integer" - } - } - }, - "updated_at": { - "type": "date" - }, - "upgrade-assistant-reindex-operation": { - "dynamic": "true", - "properties": { - "indexName": { - "type": "keyword" - }, - "status": { - "type": "integer" - } - } - }, - "upgrade-assistant-telemetry": { - "properties": { - "features": { - "properties": { - "deprecation_logging": { - "properties": { - "enabled": { - "null_value": true, - "type": "boolean" - } - } - } - } - }, - "ui_open": { - "properties": { - "cluster": { - "null_value": 0, - "type": "long" - }, - "indices": { - "null_value": 0, - "type": "long" - }, - "overview": { - "null_value": 0, - "type": "long" - } - } - }, - "ui_reindex": { - "properties": { - "close": { - "null_value": 0, - "type": "long" - }, - "open": { - "null_value": 0, - "type": "long" - }, - "start": { - "null_value": 0, - "type": "long" - }, - "stop": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "url": { - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "visualization": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchRefName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "auto_expand_replicas": "0-1", - "number_of_replicas": "0", - "number_of_shards": "1" - } - } - } -} diff --git a/x-pack/test/functional/es_archives/ml/ihp_outlier/data.json.gz b/x-pack/test/functional/es_archives/ml/ihp_outlier/data.json.gz index de0d2d6dd4ccc..34637dfd812d1 100644 Binary files a/x-pack/test/functional/es_archives/ml/ihp_outlier/data.json.gz and b/x-pack/test/functional/es_archives/ml/ihp_outlier/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/ml/ihp_outlier/mappings.json b/x-pack/test/functional/es_archives/ml/ihp_outlier/mappings.json index f90c6e67daac4..a20b1de81010f 100644 --- a/x-pack/test/functional/es_archives/ml/ihp_outlier/mappings.json +++ b/x-pack/test/functional/es_archives/ml/ihp_outlier/mappings.json @@ -3,7 +3,7 @@ "value": { "aliases": { }, - "index": "ihp_outlier", + "index": "ft_ihp_outlier", "mappings": { "properties": { "1stFlrSF": { @@ -109,1395 +109,3 @@ } } } - -{ - "type": "index", - "value": { - "aliases": { - ".kibana": { - } - }, - "index": ".kibana_1", - "mappings": { - "_meta": { - "migrationMappingPropertyHashes": { - "action": "ecc01e367a369542bc2b15dae1fb1773", - "action_task_params": "a9d49f184ee89641044be0ca2950fa3a", - "alert": "3cdf52bff6f482e53b825b45686604db", - "apm-indices": "9bb9b2bf1fa636ed8619cbab5ce6a1dd", - "apm-services-telemetry": "07ee1939fa4302c62ddc052ec03fed90", - "canvas-element": "7390014e1091044523666d97247392fc", - "canvas-workpad": "b0a1706d356228dbdcb4a17e6b9eb231", - "config": "87aca8fdb053154f11383fce3dbf3edf", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", - "graph-workspace": "cd7ba1330e6682e9cc00b78850874be1", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", - "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", - "inventory-view": "84b320fd67209906333ffce261128462", - "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", - "lens": "21c3ea0763beb1ecb0162529706b88c5", - "lens-ui-telemetry": "509bfa5978586998e05f9e303c07a327", - "map": "23d7aa4a720d4938ccde3983f87bd58d", - "maps-telemetry": "a4229f8b16a6820c6d724b7e0c1f729d", - "metrics-explorer-view": "53c5365793677328df0ccb6138bf3cdd", - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", - "namespace": "2f4316de49999235636386fe51dc06c1", - "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", - "references": "7997cf5a56cc02bdc9c93361bde732b0", - "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", - "server": "ec97f1c5da1a19609a60874e5af1100c", - "siem-ui-timeline": "6485ab095be8d15246667b98a1a34295", - "siem-ui-timeline-note": "8874706eedc49059d4cf0f5094559084", - "siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29", - "space": "c5ca8acafa0beaa4d08d014a97b6bc6b", - "telemetry": "358ffaa88ba34a97d55af0933a117de4", - "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "type": "2f4316de49999235636386fe51dc06c1", - "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", - "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", - "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", - "url": "c7f66a0df8b1b52f17c28c4adb111105", - "visualization": "52d7a13ad68a150c4525b292d23e12cc" - } - }, - "dynamic": "strict", - "properties": { - "action": { - "properties": { - "actionTypeId": { - "type": "keyword" - }, - "config": { - "enabled": false, - "type": "object" - }, - "description": { - "type": "text" - }, - "secrets": { - "type": "binary" - } - } - }, - "action_task_params": { - "properties": { - "actionId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "params": { - "enabled": false, - "type": "object" - } - } - }, - "alert": { - "properties": { - "actions": { - "properties": { - "actionRef": { - "type": "keyword" - }, - "group": { - "type": "keyword" - }, - "params": { - "enabled": false, - "type": "object" - } - }, - "type": "nested" - }, - "alertTypeId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "apiKeyOwner": { - "type": "keyword" - }, - "createdBy": { - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "interval": { - "type": "keyword" - }, - "muteAll": { - "type": "boolean" - }, - "mutedInstanceIds": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "params": { - "enabled": false, - "type": "object" - }, - "scheduledTaskId": { - "type": "keyword" - }, - "tags": { - "type": "keyword" - }, - "throttle": { - "type": "keyword" - }, - "updatedBy": { - "type": "keyword" - } - } - }, - "apm-indices": { - "properties": { - "apm_oss": { - "properties": { - "errorIndices": { - "type": "keyword" - }, - "metricsIndices": { - "type": "keyword" - }, - "onboardingIndices": { - "type": "keyword" - }, - "sourcemapIndices": { - "type": "keyword" - }, - "spanIndices": { - "type": "keyword" - }, - "transactionIndices": { - "type": "keyword" - } - } - } - } - }, - "apm-services-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "dotnet": { - "null_value": 0, - "type": "long" - }, - "go": { - "null_value": 0, - "type": "long" - }, - "java": { - "null_value": 0, - "type": "long" - }, - "js-base": { - "null_value": 0, - "type": "long" - }, - "nodejs": { - "null_value": 0, - "type": "long" - }, - "python": { - "null_value": 0, - "type": "long" - }, - "ruby": { - "null_value": 0, - "type": "long" - }, - "rum-js": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "canvas-element": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "content": { - "type": "text" - }, - "help": { - "type": "text" - }, - "image": { - "type": "text" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "canvas-workpad": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultIndex": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "dashboard": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "file-upload-telemetry": { - "properties": { - "filesUploadedTotalCount": { - "type": "long" - } - } - }, - "graph-workspace": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" - } - } - }, - "index-pattern": { - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "typeMeta": { - "type": "keyword" - } - } - }, - "infrastructure-ui-source": { - "properties": { - "description": { - "type": "text" - }, - "fields": { - "properties": { - "container": { - "type": "keyword" - }, - "host": { - "type": "keyword" - }, - "pod": { - "type": "keyword" - }, - "tiebreaker": { - "type": "keyword" - }, - "timestamp": { - "type": "keyword" - } - } - }, - "logAlias": { - "type": "keyword" - }, - "logColumns": { - "properties": { - "fieldColumn": { - "properties": { - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - } - } - }, - "messageColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - }, - "timestampColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - } - }, - "type": "nested" - }, - "metricAlias": { - "type": "keyword" - }, - "name": { - "type": "text" - } - } - }, - "inventory-view": { - "properties": { - "autoBounds": { - "type": "boolean" - }, - "autoReload": { - "type": "boolean" - }, - "boundsOverride": { - "properties": { - "max": { - "type": "integer" - }, - "min": { - "type": "integer" - } - } - }, - "customOptions": { - "properties": { - "field": { - "type": "keyword" - }, - "text": { - "type": "keyword" - } - }, - "type": "nested" - }, - "filterQuery": { - "properties": { - "expression": { - "type": "keyword" - }, - "kind": { - "type": "keyword" - } - } - }, - "groupBy": { - "properties": { - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - }, - "metric": { - "properties": { - "type": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "nodeType": { - "type": "keyword" - }, - "time": { - "type": "integer" - }, - "view": { - "type": "keyword" - } - } - }, - "kql-telemetry": { - "properties": { - "optInCount": { - "type": "long" - }, - "optOutCount": { - "type": "long" - } - } - }, - "lens": { - "properties": { - "expression": { - "index": false, - "type": "keyword" - }, - "state": { - "type": "flattened" - }, - "title": { - "type": "text" - }, - "visualizationType": { - "type": "keyword" - } - } - }, - "lens-ui-telemetry": { - "properties": { - "count": { - "type": "integer" - }, - "date": { - "type": "date" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "map": { - "properties": { - "bounds": { - "type": "geo_shape" - }, - "description": { - "type": "text" - }, - "layerListJSON": { - "type": "text" - }, - "mapStateJSON": { - "type": "text" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "maps-telemetry": { - "properties": { - "attributesPerMap": { - "properties": { - "dataSourcesCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - }, - "emsVectorLayersCount": { - "dynamic": "true", - "type": "object" - }, - "layerTypesCount": { - "dynamic": "true", - "type": "object" - }, - "layersCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - } - } - }, - "mapsTotalCount": { - "type": "long" - }, - "timeCaptured": { - "type": "date" - } - } - }, - "metrics-explorer-view": { - "properties": { - "chartOptions": { - "properties": { - "stack": { - "type": "boolean" - }, - "type": { - "type": "keyword" - }, - "yAxisMode": { - "type": "keyword" - } - } - }, - "currentTimerange": { - "properties": { - "from": { - "type": "keyword" - }, - "interval": { - "type": "keyword" - }, - "to": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "options": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "filterQuery": { - "type": "keyword" - }, - "groupBy": { - "type": "keyword" - }, - "limit": { - "type": "integer" - }, - "metrics": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "color": { - "type": "keyword" - }, - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - } - } - } - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "index-pattern": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "space": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "ml-telemetry": { - "properties": { - "file_data_visualizer": { - "properties": { - "index_creation_count": { - "type": "long" - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, - "query": { - "properties": { - "description": { - "type": "text" - }, - "filters": { - "enabled": false, - "type": "object" - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "index": false, - "type": "keyword" - } - } - }, - "timefilter": { - "enabled": false, - "type": "object" - }, - "title": { - "type": "text" - } - } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "sample-data-telemetry": { - "properties": { - "installCount": { - "type": "long" - }, - "unInstallCount": { - "type": "long" - } - } - }, - "search": { - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "siem-ui-timeline": { - "properties": { - "columns": { - "properties": { - "aggregatable": { - "type": "boolean" - }, - "category": { - "type": "keyword" - }, - "columnHeaderType": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "example": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "indexes": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "placeholder": { - "type": "text" - }, - "searchable": { - "type": "boolean" - }, - "type": { - "type": "keyword" - } - } - }, - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "dataProviders": { - "properties": { - "and": { - "properties": { - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "dateRange": { - "properties": { - "end": { - "type": "date" - }, - "start": { - "type": "date" - } - } - }, - "description": { - "type": "text" - }, - "favorite": { - "properties": { - "favoriteDate": { - "type": "date" - }, - "fullName": { - "type": "text" - }, - "keySearch": { - "type": "text" - }, - "userName": { - "type": "text" - } - } - }, - "filters": { - "properties": { - "exists": { - "type": "text" - }, - "match_all": { - "type": "text" - }, - "meta": { - "properties": { - "alias": { - "type": "text" - }, - "controlledBy": { - "type": "text" - }, - "disabled": { - "type": "boolean" - }, - "field": { - "type": "text" - }, - "formattedValue": { - "type": "text" - }, - "index": { - "type": "keyword" - }, - "key": { - "type": "keyword" - }, - "negate": { - "type": "boolean" - }, - "params": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "value": { - "type": "text" - } - } - }, - "missing": { - "type": "text" - }, - "query": { - "type": "text" - }, - "range": { - "type": "text" - }, - "script": { - "type": "text" - } - } - }, - "kqlMode": { - "type": "keyword" - }, - "kqlQuery": { - "properties": { - "filterQuery": { - "properties": { - "kuery": { - "properties": { - "expression": { - "type": "text" - }, - "kind": { - "type": "keyword" - } - } - }, - "serializedQuery": { - "type": "text" - } - } - } - } - }, - "savedQueryId": { - "type": "keyword" - }, - "sort": { - "properties": { - "columnId": { - "type": "keyword" - }, - "sortDirection": { - "type": "keyword" - } - } - }, - "title": { - "type": "text" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-note": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "note": { - "type": "text" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-pinned-event": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "imageUrl": { - "index": false, - "type": "text" - }, - "initials": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - }, - "lastReported": { - "type": "date" - }, - "lastVersionChecked": { - "ignore_above": 256, - "type": "keyword" - }, - "sendUsageFrom": { - "ignore_above": 256, - "type": "keyword" - }, - "userHasSeenNotice": { - "type": "boolean" - } - } - }, - "timelion-sheet": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "timelion_chart_height": { - "type": "integer" - }, - "timelion_columns": { - "type": "integer" - }, - "timelion_interval": { - "type": "keyword" - }, - "timelion_other_interval": { - "type": "keyword" - }, - "timelion_rows": { - "type": "integer" - }, - "timelion_sheet": { - "type": "text" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "type": { - "type": "keyword" - }, - "ui-metric": { - "properties": { - "count": { - "type": "integer" - } - } - }, - "updated_at": { - "type": "date" - }, - "upgrade-assistant-reindex-operation": { - "dynamic": "true", - "properties": { - "indexName": { - "type": "keyword" - }, - "status": { - "type": "integer" - } - } - }, - "upgrade-assistant-telemetry": { - "properties": { - "features": { - "properties": { - "deprecation_logging": { - "properties": { - "enabled": { - "null_value": true, - "type": "boolean" - } - } - } - } - }, - "ui_open": { - "properties": { - "cluster": { - "null_value": 0, - "type": "long" - }, - "indices": { - "null_value": 0, - "type": "long" - }, - "overview": { - "null_value": 0, - "type": "long" - } - } - }, - "ui_reindex": { - "properties": { - "close": { - "null_value": 0, - "type": "long" - }, - "open": { - "null_value": 0, - "type": "long" - }, - "start": { - "null_value": 0, - "type": "long" - }, - "stop": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "url": { - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "visualization": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchRefName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "auto_expand_replicas": "0-1", - "number_of_replicas": "0", - "number_of_shards": "1" - } - } - } -} \ No newline at end of file diff --git a/x-pack/test/functional/es_archives/ml/sample_logs/data.json.gz b/x-pack/test/functional/es_archives/ml/sample_logs/data.json.gz index 03ceb319a6afe..88937d484d24e 100644 Binary files a/x-pack/test/functional/es_archives/ml/sample_logs/data.json.gz and b/x-pack/test/functional/es_archives/ml/sample_logs/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/ml/sample_logs/mappings.json b/x-pack/test/functional/es_archives/ml/sample_logs/mappings.json index 1c7490e139be5..62f69063695e7 100644 --- a/x-pack/test/functional/es_archives/ml/sample_logs/mappings.json +++ b/x-pack/test/functional/es_archives/ml/sample_logs/mappings.json @@ -165,2998 +165,3 @@ } } } - -{ - "type": "index", - "value": { - "aliases": { - ".kibana": { - } - }, - "index": ".kibana_1", - "mappings": { - "_meta": { - "migrationMappingPropertyHashes": { - "action": "6e96ac5e648f57523879661ea72525b7", - "action_task_params": "a9d49f184ee89641044be0ca2950fa3a", - "agent_configs": "38abaf89513877745c359e7700c0c66a", - "agent_events": "3231653fafe4ef3196fe3b32ab774bf2", - "agents": "75c0f4a11560dbc38b65e5e1d98fc9da", - "alert": "7b44fba6773e37c806ce290ea9b7024e", - "apm-indices": "9bb9b2bf1fa636ed8619cbab5ce6a1dd", - "apm-telemetry": "e8619030e08b671291af04c4603b4944", - "application_usage_totals": "c897e4310c5f24b07caaff3db53ae2c1", - "application_usage_transactional": "965839e75f809fefe04f92dc4d99722a", - "canvas-element": "7390014e1091044523666d97247392fc", - "canvas-workpad": "b0a1706d356228dbdcb4a17e6b9eb231", - "cases": "08b8b110dbca273d37e8aef131ecab61", - "cases-comments": "c2061fb929f585df57425102fa928b4b", - "cases-configure": "42711cbb311976c0687853f4c1354572", - "cases-user-actions": "32277330ec6b721abe3b846cfd939a71", - "config": "ae24d22d5986d04124cc6568f771066f", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "datasources": "d4bc0c252b2b5683ff21ea32d00acffc", - "enrollment_api_keys": "28b91e20b105b6f928e2012600085d8f", - "epm-package": "75d12cd13c867fd713d7dfb27366bc20", - "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", - "graph-workspace": "cd7ba1330e6682e9cc00b78850874be1", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", - "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", - "inventory-view": "9ecce5b58867403613d82fe496470b34", - "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", - "lens": "21c3ea0763beb1ecb0162529706b88c5", - "lens-ui-telemetry": "509bfa5978586998e05f9e303c07a327", - "map": "23d7aa4a720d4938ccde3983f87bd58d", - "maps-telemetry": "268da3a48066123fc5baf35abaa55014", - "metrics-explorer-view": "53c5365793677328df0ccb6138bf3cdd", - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", - "namespace": "2f4316de49999235636386fe51dc06c1", - "outputs": "aee9782e0d500b867859650a36280165", - "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", - "references": "7997cf5a56cc02bdc9c93361bde732b0", - "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", - "server": "ec97f1c5da1a19609a60874e5af1100c", - "siem-detection-engine-rule-status": "ae783f41c6937db6b7a2ef5c93a9e9b0", - "siem-ui-timeline": "ac8020190f5950dd3250b6499144e7fb", - "siem-ui-timeline-note": "8874706eedc49059d4cf0f5094559084", - "siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29", - "space": "c5ca8acafa0beaa4d08d014a97b6bc6b", - "telemetry": "36a616f7026dfa617d6655df850fe16d", - "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "tsvb-validation-telemetry": "3a37ef6c8700ae6fc97d5c7da00e9215", - "type": "2f4316de49999235636386fe51dc06c1", - "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", - "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", - "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", - "uptime-dynamic-settings": "b6289473c8985c79b6c47eebc19a0ca5", - "url": "c7f66a0df8b1b52f17c28c4adb111105", - "visualization": "52d7a13ad68a150c4525b292d23e12cc" - } - }, - "dynamic": "strict", - "properties": { - "action": { - "properties": { - "actionTypeId": { - "type": "keyword" - }, - "config": { - "enabled": false, - "type": "object" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - }, - "secrets": { - "type": "binary" - } - } - }, - "action_task_params": { - "properties": { - "actionId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "params": { - "enabled": false, - "type": "object" - } - } - }, - "agent_configs": { - "properties": { - "datasources": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "is_default": { - "type": "boolean" - }, - "name": { - "type": "text" - }, - "namespace": { - "type": "keyword" - }, - "revision": { - "type": "integer" - }, - "status": { - "type": "keyword" - }, - "updated_by": { - "type": "keyword" - }, - "updated_on": { - "type": "keyword" - } - } - }, - "agent_events": { - "properties": { - "action_id": { - "type": "keyword" - }, - "agent_id": { - "type": "keyword" - }, - "config_id": { - "type": "keyword" - }, - "data": { - "type": "text" - }, - "message": { - "type": "text" - }, - "payload": { - "type": "text" - }, - "stream_id": { - "type": "keyword" - }, - "subtype": { - "type": "keyword" - }, - "timestamp": { - "type": "date" - }, - "type": { - "type": "keyword" - } - } - }, - "agents": { - "properties": { - "access_api_key_id": { - "type": "keyword" - }, - "actions": { - "properties": { - "created_at": { - "type": "date" - }, - "data": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "sent_at": { - "type": "date" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "active": { - "type": "boolean" - }, - "config_id": { - "type": "keyword" - }, - "config_newest_revision": { - "type": "integer" - }, - "config_revision": { - "type": "integer" - }, - "current_error_events": { - "type": "text" - }, - "default_api_key": { - "type": "keyword" - }, - "enrolled_at": { - "type": "date" - }, - "last_checkin": { - "type": "date" - }, - "last_updated": { - "type": "date" - }, - "local_metadata": { - "type": "text" - }, - "shared_id": { - "type": "keyword" - }, - "type": { - "type": "keyword" - }, - "updated_at": { - "type": "date" - }, - "user_provided_metadata": { - "type": "text" - }, - "version": { - "type": "keyword" - } - } - }, - "alert": { - "properties": { - "actions": { - "properties": { - "actionRef": { - "type": "keyword" - }, - "actionTypeId": { - "type": "keyword" - }, - "group": { - "type": "keyword" - }, - "params": { - "enabled": false, - "type": "object" - } - }, - "type": "nested" - }, - "alertTypeId": { - "type": "keyword" - }, - "apiKey": { - "type": "binary" - }, - "apiKeyOwner": { - "type": "keyword" - }, - "consumer": { - "type": "keyword" - }, - "createdAt": { - "type": "date" - }, - "createdBy": { - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "muteAll": { - "type": "boolean" - }, - "mutedInstanceIds": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - }, - "params": { - "enabled": false, - "type": "object" - }, - "schedule": { - "properties": { - "interval": { - "type": "keyword" - } - } - }, - "scheduledTaskId": { - "type": "keyword" - }, - "tags": { - "type": "keyword" - }, - "throttle": { - "type": "keyword" - }, - "updatedBy": { - "type": "keyword" - } - } - }, - "apm-indices": { - "properties": { - "apm_oss": { - "properties": { - "errorIndices": { - "type": "keyword" - }, - "metricsIndices": { - "type": "keyword" - }, - "onboardingIndices": { - "type": "keyword" - }, - "sourcemapIndices": { - "type": "keyword" - }, - "spanIndices": { - "type": "keyword" - }, - "transactionIndices": { - "type": "keyword" - } - } - } - } - }, - "apm-telemetry": { - "properties": { - "agents": { - "properties": { - "dotnet": { - "properties": { - "agent": { - "properties": { - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "service": { - "properties": { - "framework": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "language": { - "properties": { - "name": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "runtime": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - } - } - } - } - }, - "go": { - "properties": { - "agent": { - "properties": { - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "service": { - "properties": { - "framework": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "language": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "runtime": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - } - } - } - } - }, - "java": { - "properties": { - "agent": { - "properties": { - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "service": { - "properties": { - "framework": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "language": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "runtime": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - } - } - } - } - }, - "js-base": { - "properties": { - "agent": { - "properties": { - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "service": { - "properties": { - "framework": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "language": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "runtime": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - } - } - } - } - }, - "nodejs": { - "properties": { - "agent": { - "properties": { - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "service": { - "properties": { - "framework": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "language": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "runtime": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - } - } - } - } - }, - "python": { - "properties": { - "agent": { - "properties": { - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "service": { - "properties": { - "framework": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "language": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "runtime": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - } - } - } - } - }, - "ruby": { - "properties": { - "agent": { - "properties": { - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "service": { - "properties": { - "framework": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "language": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "runtime": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - } - } - } - } - }, - "rum-js": { - "properties": { - "agent": { - "properties": { - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "service": { - "properties": { - "framework": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "language": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - }, - "runtime": { - "properties": { - "composite": { - "ignore_above": 256, - "type": "keyword" - }, - "name": { - "ignore_above": 256, - "type": "keyword" - }, - "version": { - "ignore_above": 256, - "type": "keyword" - } - } - } - } - } - } - } - } - }, - "cardinality": { - "properties": { - "transaction": { - "properties": { - "name": { - "properties": { - "all_agents": { - "properties": { - "1d": { - "type": "long" - } - } - }, - "rum": { - "properties": { - "1d": { - "type": "long" - } - } - } - } - } - } - }, - "user_agent": { - "properties": { - "original": { - "properties": { - "all_agents": { - "properties": { - "1d": { - "type": "long" - } - } - }, - "rum": { - "properties": { - "1d": { - "type": "long" - } - } - } - } - } - } - } - } - }, - "counts": { - "properties": { - "agent_configuration": { - "properties": { - "all": { - "type": "long" - } - } - }, - "error": { - "properties": { - "1d": { - "type": "long" - }, - "all": { - "type": "long" - } - } - }, - "max_error_groups_per_service": { - "properties": { - "1d": { - "type": "long" - } - } - }, - "max_transaction_groups_per_service": { - "properties": { - "1d": { - "type": "long" - } - } - }, - "metric": { - "properties": { - "1d": { - "type": "long" - }, - "all": { - "type": "long" - } - } - }, - "onboarding": { - "properties": { - "1d": { - "type": "long" - }, - "all": { - "type": "long" - } - } - }, - "services": { - "properties": { - "1d": { - "type": "long" - } - } - }, - "sourcemap": { - "properties": { - "1d": { - "type": "long" - }, - "all": { - "type": "long" - } - } - }, - "span": { - "properties": { - "1d": { - "type": "long" - }, - "all": { - "type": "long" - } - } - }, - "traces": { - "properties": { - "1d": { - "type": "long" - } - } - }, - "transaction": { - "properties": { - "1d": { - "type": "long" - }, - "all": { - "type": "long" - } - } - } - } - }, - "has_any_services": { - "type": "boolean" - }, - "indices": { - "properties": { - "all": { - "properties": { - "total": { - "properties": { - "docs": { - "properties": { - "count": { - "type": "long" - } - } - }, - "store": { - "properties": { - "size_in_bytes": { - "type": "long" - } - } - } - } - } - } - }, - "shards": { - "properties": { - "total": { - "type": "long" - } - } - } - } - }, - "integrations": { - "properties": { - "ml": { - "properties": { - "all_jobs_count": { - "type": "long" - } - } - } - } - }, - "retainment": { - "properties": { - "error": { - "properties": { - "ms": { - "type": "long" - } - } - }, - "metric": { - "properties": { - "ms": { - "type": "long" - } - } - }, - "onboarding": { - "properties": { - "ms": { - "type": "long" - } - } - }, - "span": { - "properties": { - "ms": { - "type": "long" - } - } - }, - "transaction": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - }, - "services_per_agent": { - "properties": { - "dotnet": { - "null_value": 0, - "type": "long" - }, - "go": { - "null_value": 0, - "type": "long" - }, - "java": { - "null_value": 0, - "type": "long" - }, - "js-base": { - "null_value": 0, - "type": "long" - }, - "nodejs": { - "null_value": 0, - "type": "long" - }, - "python": { - "null_value": 0, - "type": "long" - }, - "ruby": { - "null_value": 0, - "type": "long" - }, - "rum-js": { - "null_value": 0, - "type": "long" - } - } - }, - "tasks": { - "properties": { - "agent_configuration": { - "properties": { - "took": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - }, - "agents": { - "properties": { - "took": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - }, - "cardinality": { - "properties": { - "took": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - }, - "groupings": { - "properties": { - "took": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - }, - "indices_stats": { - "properties": { - "took": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - }, - "integrations": { - "properties": { - "took": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - }, - "processor_events": { - "properties": { - "took": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - }, - "services": { - "properties": { - "took": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - }, - "versions": { - "properties": { - "took": { - "properties": { - "ms": { - "type": "long" - } - } - } - } - } - } - }, - "version": { - "properties": { - "apm_server": { - "properties": { - "major": { - "type": "long" - }, - "minor": { - "type": "long" - }, - "patch": { - "type": "long" - } - } - } - } - } - } - }, - "application_usage_totals": { - "properties": { - "appId": { - "type": "keyword" - }, - "minutesOnScreen": { - "type": "float" - }, - "numberOfClicks": { - "type": "long" - } - } - }, - "application_usage_transactional": { - "properties": { - "appId": { - "type": "keyword" - }, - "minutesOnScreen": { - "type": "float" - }, - "numberOfClicks": { - "type": "long" - }, - "timestamp": { - "type": "date" - } - } - }, - "canvas-element": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "content": { - "type": "text" - }, - "help": { - "type": "text" - }, - "image": { - "type": "text" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "canvas-workpad": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "name": { - "fields": { - "keyword": { - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "cases": { - "properties": { - "closed_at": { - "type": "date" - }, - "closed_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - }, - "created_at": { - "type": "date" - }, - "created_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - }, - "description": { - "type": "text" - }, - "external_service": { - "properties": { - "connector_id": { - "type": "keyword" - }, - "connector_name": { - "type": "keyword" - }, - "external_id": { - "type": "keyword" - }, - "external_title": { - "type": "text" - }, - "external_url": { - "type": "text" - }, - "pushed_at": { - "type": "date" - }, - "pushed_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - } - } - }, - "status": { - "type": "keyword" - }, - "tags": { - "type": "keyword" - }, - "title": { - "type": "keyword" - }, - "updated_at": { - "type": "date" - }, - "updated_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - } - } - }, - "cases-comments": { - "properties": { - "comment": { - "type": "text" - }, - "created_at": { - "type": "date" - }, - "created_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - }, - "pushed_at": { - "type": "date" - }, - "pushed_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - }, - "updated_at": { - "type": "date" - }, - "updated_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - } - } - }, - "cases-configure": { - "properties": { - "closure_type": { - "type": "keyword" - }, - "connector_id": { - "type": "keyword" - }, - "connector_name": { - "type": "keyword" - }, - "created_at": { - "type": "date" - }, - "created_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - }, - "updated_at": { - "type": "date" - }, - "updated_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - } - } - }, - "cases-user-actions": { - "properties": { - "action": { - "type": "keyword" - }, - "action_at": { - "type": "date" - }, - "action_by": { - "properties": { - "email": { - "type": "keyword" - }, - "full_name": { - "type": "keyword" - }, - "username": { - "type": "keyword" - } - } - }, - "action_field": { - "type": "keyword" - }, - "new_value": { - "type": "text" - }, - "old_value": { - "type": "text" - } - } - }, - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - }, - "dateFormat:tz": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "defaultIndex": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "dashboard": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "datasources": { - "properties": { - "config_id": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "enabled": { - "type": "boolean" - }, - "inputs": { - "properties": { - "config": { - "type": "flattened" - }, - "enabled": { - "type": "boolean" - }, - "processors": { - "type": "keyword" - }, - "streams": { - "properties": { - "config": { - "type": "flattened" - }, - "dataset": { - "type": "keyword" - }, - "enabled": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "processors": { - "type": "keyword" - } - }, - "type": "nested" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "name": { - "type": "keyword" - }, - "namespace": { - "type": "keyword" - }, - "output_id": { - "type": "keyword" - }, - "package": { - "properties": { - "name": { - "type": "keyword" - }, - "title": { - "type": "keyword" - }, - "version": { - "type": "keyword" - } - } - }, - "revision": { - "type": "integer" - } - } - }, - "enrollment_api_keys": { - "properties": { - "active": { - "type": "boolean" - }, - "api_key": { - "type": "binary" - }, - "api_key_id": { - "type": "keyword" - }, - "config_id": { - "type": "keyword" - }, - "created_at": { - "type": "date" - }, - "expire_at": { - "type": "date" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - }, - "updated_at": { - "type": "date" - } - } - }, - "epm-package": { - "properties": { - "installed": { - "properties": { - "id": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "name": { - "type": "keyword" - }, - "version": { - "type": "keyword" - } - } - }, - "file-upload-telemetry": { - "properties": { - "filesUploadedTotalCount": { - "type": "long" - } - } - }, - "graph-workspace": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" - } - } - }, - "index-pattern": { - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "typeMeta": { - "type": "keyword" - } - } - }, - "infrastructure-ui-source": { - "properties": { - "description": { - "type": "text" - }, - "fields": { - "properties": { - "container": { - "type": "keyword" - }, - "host": { - "type": "keyword" - }, - "pod": { - "type": "keyword" - }, - "tiebreaker": { - "type": "keyword" - }, - "timestamp": { - "type": "keyword" - } - } - }, - "logAlias": { - "type": "keyword" - }, - "logColumns": { - "properties": { - "fieldColumn": { - "properties": { - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - } - } - }, - "messageColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - }, - "timestampColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - } - }, - "type": "nested" - }, - "metricAlias": { - "type": "keyword" - }, - "name": { - "type": "text" - } - } - }, - "inventory-view": { - "properties": { - "autoBounds": { - "type": "boolean" - }, - "autoReload": { - "type": "boolean" - }, - "boundsOverride": { - "properties": { - "max": { - "type": "integer" - }, - "min": { - "type": "integer" - } - } - }, - "customMetrics": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - }, - "label": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "customOptions": { - "properties": { - "field": { - "type": "keyword" - }, - "text": { - "type": "keyword" - } - }, - "type": "nested" - }, - "filterQuery": { - "properties": { - "expression": { - "type": "keyword" - }, - "kind": { - "type": "keyword" - } - } - }, - "groupBy": { - "properties": { - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - }, - "metric": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - }, - "label": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "nodeType": { - "type": "keyword" - }, - "time": { - "type": "integer" - }, - "view": { - "type": "keyword" - } - } - }, - "kql-telemetry": { - "properties": { - "optInCount": { - "type": "long" - }, - "optOutCount": { - "type": "long" - } - } - }, - "lens": { - "properties": { - "expression": { - "index": false, - "type": "keyword" - }, - "state": { - "type": "flattened" - }, - "title": { - "type": "text" - }, - "visualizationType": { - "type": "keyword" - } - } - }, - "lens-ui-telemetry": { - "properties": { - "count": { - "type": "integer" - }, - "date": { - "type": "date" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "map": { - "properties": { - "bounds": { - "type": "geo_shape" - }, - "description": { - "type": "text" - }, - "layerListJSON": { - "type": "text" - }, - "mapStateJSON": { - "type": "text" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "maps-telemetry": { - "properties": { - "attributesPerMap": { - "properties": { - "dataSourcesCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - }, - "emsVectorLayersCount": { - "dynamic": "true", - "type": "object" - }, - "layerTypesCount": { - "dynamic": "true", - "type": "object" - }, - "layersCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - } - } - }, - "indexPatternsWithGeoFieldCount": { - "type": "long" - }, - "mapsTotalCount": { - "type": "long" - }, - "settings": { - "properties": { - "showMapVisualizationTypes": { - "type": "boolean" - } - } - }, - "timeCaptured": { - "type": "date" - } - } - }, - "metrics-explorer-view": { - "properties": { - "chartOptions": { - "properties": { - "stack": { - "type": "boolean" - }, - "type": { - "type": "keyword" - }, - "yAxisMode": { - "type": "keyword" - } - } - }, - "currentTimerange": { - "properties": { - "from": { - "type": "keyword" - }, - "interval": { - "type": "keyword" - }, - "to": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "options": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "filterQuery": { - "type": "keyword" - }, - "groupBy": { - "type": "keyword" - }, - "limit": { - "type": "integer" - }, - "metrics": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "color": { - "type": "keyword" - }, - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - }, - "type": "nested" - } - } - } - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "canvas-workpad": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "dashboard": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "graph-workspace": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "index-pattern": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "map": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "space": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - }, - "visualization": { - "fields": { - "keyword": { - "ignore_above": 256, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "ml-telemetry": { - "properties": { - "file_data_visualizer": { - "properties": { - "index_creation_count": { - "type": "long" - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, - "outputs": { - "properties": { - "api_key": { - "type": "keyword" - }, - "ca_sha256": { - "type": "keyword" - }, - "config": { - "type": "flattened" - }, - "fleet_enroll_password": { - "type": "binary" - }, - "fleet_enroll_username": { - "type": "binary" - }, - "hosts": { - "type": "keyword" - }, - "is_default": { - "type": "boolean" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "query": { - "properties": { - "description": { - "type": "text" - }, - "filters": { - "enabled": false, - "type": "object" - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "index": false, - "type": "keyword" - } - } - }, - "timefilter": { - "enabled": false, - "type": "object" - }, - "title": { - "type": "text" - } - } - }, - "references": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - }, - "type": "nested" - }, - "sample-data-telemetry": { - "properties": { - "installCount": { - "type": "long" - }, - "unInstallCount": { - "type": "long" - } - } - }, - "search": { - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "siem-detection-engine-rule-status": { - "properties": { - "alertId": { - "type": "keyword" - }, - "bulkCreateTimeDurations": { - "type": "float" - }, - "gap": { - "type": "text" - }, - "lastFailureAt": { - "type": "date" - }, - "lastFailureMessage": { - "type": "text" - }, - "lastLookBackDate": { - "type": "date" - }, - "lastSuccessAt": { - "type": "date" - }, - "lastSuccessMessage": { - "type": "text" - }, - "searchAfterTimeDurations": { - "type": "float" - }, - "status": { - "type": "keyword" - }, - "statusDate": { - "type": "date" - } - } - }, - "siem-ui-timeline": { - "properties": { - "columns": { - "properties": { - "aggregatable": { - "type": "boolean" - }, - "category": { - "type": "keyword" - }, - "columnHeaderType": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "example": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "indexes": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "placeholder": { - "type": "text" - }, - "searchable": { - "type": "boolean" - }, - "type": { - "type": "keyword" - } - } - }, - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "dataProviders": { - "properties": { - "and": { - "properties": { - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "dateRange": { - "properties": { - "end": { - "type": "date" - }, - "start": { - "type": "date" - } - } - }, - "description": { - "type": "text" - }, - "eventType": { - "type": "keyword" - }, - "favorite": { - "properties": { - "favoriteDate": { - "type": "date" - }, - "fullName": { - "type": "text" - }, - "keySearch": { - "type": "text" - }, - "userName": { - "type": "text" - } - } - }, - "filters": { - "properties": { - "exists": { - "type": "text" - }, - "match_all": { - "type": "text" - }, - "meta": { - "properties": { - "alias": { - "type": "text" - }, - "controlledBy": { - "type": "text" - }, - "disabled": { - "type": "boolean" - }, - "field": { - "type": "text" - }, - "formattedValue": { - "type": "text" - }, - "index": { - "type": "keyword" - }, - "key": { - "type": "keyword" - }, - "negate": { - "type": "boolean" - }, - "params": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "value": { - "type": "text" - } - } - }, - "missing": { - "type": "text" - }, - "query": { - "type": "text" - }, - "range": { - "type": "text" - }, - "script": { - "type": "text" - } - } - }, - "kqlMode": { - "type": "keyword" - }, - "kqlQuery": { - "properties": { - "filterQuery": { - "properties": { - "kuery": { - "properties": { - "expression": { - "type": "text" - }, - "kind": { - "type": "keyword" - } - } - }, - "serializedQuery": { - "type": "text" - } - } - } - } - }, - "savedQueryId": { - "type": "keyword" - }, - "sort": { - "properties": { - "columnId": { - "type": "keyword" - }, - "sortDirection": { - "type": "keyword" - } - } - }, - "title": { - "type": "text" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-note": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "note": { - "type": "text" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-pinned-event": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "imageUrl": { - "index": false, - "type": "text" - }, - "initials": { - "type": "keyword" - }, - "name": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "telemetry": { - "properties": { - "allowChangingOptInStatus": { - "type": "boolean" - }, - "enabled": { - "type": "boolean" - }, - "lastReported": { - "type": "date" - }, - "lastVersionChecked": { - "type": "keyword" - }, - "reportFailureCount": { - "type": "integer" - }, - "reportFailureVersion": { - "type": "keyword" - }, - "sendUsageFrom": { - "type": "keyword" - }, - "userHasSeenNotice": { - "type": "boolean" - } - } - }, - "timelion-sheet": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "timelion_chart_height": { - "type": "integer" - }, - "timelion_columns": { - "type": "integer" - }, - "timelion_interval": { - "type": "keyword" - }, - "timelion_other_interval": { - "type": "keyword" - }, - "timelion_rows": { - "type": "integer" - }, - "timelion_sheet": { - "type": "text" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "tsvb-validation-telemetry": { - "properties": { - "failedRequests": { - "type": "long" - } - } - }, - "type": { - "type": "keyword" - }, - "ui-metric": { - "properties": { - "count": { - "type": "integer" - } - } - }, - "updated_at": { - "type": "date" - }, - "upgrade-assistant-reindex-operation": { - "dynamic": "true", - "properties": { - "indexName": { - "type": "keyword" - }, - "status": { - "type": "integer" - } - } - }, - "upgrade-assistant-telemetry": { - "properties": { - "features": { - "properties": { - "deprecation_logging": { - "properties": { - "enabled": { - "null_value": true, - "type": "boolean" - } - } - } - } - }, - "ui_open": { - "properties": { - "cluster": { - "null_value": 0, - "type": "long" - }, - "indices": { - "null_value": 0, - "type": "long" - }, - "overview": { - "null_value": 0, - "type": "long" - } - } - }, - "ui_reindex": { - "properties": { - "close": { - "null_value": 0, - "type": "long" - }, - "open": { - "null_value": 0, - "type": "long" - }, - "start": { - "null_value": 0, - "type": "long" - }, - "stop": { - "null_value": 0, - "type": "long" - } - } - } - } - }, - "uptime-dynamic-settings": { - "properties": { - "heartbeatIndices": { - "type": "keyword" - } - } - }, - "url": { - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "fields": { - "keyword": { - "ignore_above": 2048, - "type": "keyword" - } - }, - "type": "text" - } - } - }, - "visualization": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchRefName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "auto_expand_replicas": "0-1", - "number_of_replicas": "0", - "number_of_shards": "1" - } - } - } -} \ No newline at end of file diff --git a/x-pack/test/functional/es_archives/uptime/blank/mappings.json b/x-pack/test/functional/es_archives/uptime/blank/mappings.json index 7879c82612a96..fff4ef47bce0c 100644 --- a/x-pack/test/functional/es_archives/uptime/blank/mappings.json +++ b/x-pack/test/functional/es_archives/uptime/blank/mappings.json @@ -12,79 +12,115 @@ "beat": "heartbeat", "version": "8.0.0" }, - "date_detection": false, "dynamic_templates": [ { "labels": { + "path_match": "labels.*", + "match_mapping_type": "string", "mapping": { "type": "keyword" - }, - "match_mapping_type": "string", - "path_match": "labels.*" + } } }, { "container.labels": { + "path_match": "container.labels.*", + "match_mapping_type": "string", "mapping": { "type": "keyword" - }, - "match_mapping_type": "string", - "path_match": "container.labels.*" + } } }, { "dns.answers": { + "path_match": "dns.answers.*", + "match_mapping_type": "string", "mapping": { "type": "keyword" - }, + } + } + }, + { + "log.syslog": { + "path_match": "log.syslog.*", "match_mapping_type": "string", - "path_match": "dns.answers.*" + "mapping": { + "type": "keyword" + } } }, { - "fields": { + "network.inner": { + "path_match": "network.inner.*", + "match_mapping_type": "string", "mapping": { "type": "keyword" - }, + } + } + }, + { + "observer.egress": { + "path_match": "observer.egress.*", "match_mapping_type": "string", - "path_match": "fields.*" + "mapping": { + "type": "keyword" + } } }, { - "docker.container.labels": { + "observer.ingress": { + "path_match": "observer.ingress.*", + "match_mapping_type": "string", "mapping": { "type": "keyword" - }, + } + } + }, + { + "fields": { + "path_match": "fields.*", + "match_mapping_type": "string", + "mapping": { + "type": "keyword" + } + } + }, + { + "docker.container.labels": { + "path_match": "docker.container.labels.*", "match_mapping_type": "string", - "path_match": "docker.container.labels.*" + "mapping": { + "type": "keyword" + } } }, { "kubernetes.labels.*": { + "path_match": "kubernetes.labels.*", "mapping": { "type": "keyword" - }, - "path_match": "kubernetes.labels.*" + } } }, { "kubernetes.annotations.*": { + "path_match": "kubernetes.annotations.*", "mapping": { "type": "keyword" - }, - "path_match": "kubernetes.annotations.*" + } } }, { "strings_as_keyword": { + "match_mapping_type": "string", "mapping": { "ignore_above": 1024, "type": "keyword" - }, - "match_mapping_type": "string" + } } } ], + "date_detection": false, "properties": { "@timestamp": { "type": "date" @@ -92,28 +128,28 @@ "agent": { "properties": { "ephemeral_id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "hostname": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -125,8 +161,14 @@ "organization": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } } @@ -135,8 +177,8 @@ "client": { "properties": { "address": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "as": { "properties": { @@ -146,8 +188,14 @@ "organization": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } } @@ -157,41 +205,41 @@ "type": "long" }, "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "geo": { "properties": { "city_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "continent_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "location": { "type": "geo_point" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -199,8 +247,8 @@ "type": "ip" }, "mac": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "nat": { "properties": { @@ -218,43 +266,67 @@ "port": { "type": "long" }, + "registered_domain": { + "type": "keyword", + "ignore_above": 1024 + }, + "top_level_domain": { + "type": "keyword", + "ignore_above": 1024 + }, "user": { "properties": { "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "email": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "group": { "properties": { + "domain": { + "type": "keyword", + "ignore_above": 1024 + }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "hash": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } } @@ -265,76 +337,97 @@ "account": { "properties": { "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "availability_zone": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "image": { "properties": { "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "instance": { "properties": { "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "machine": { "properties": { "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "project": { "properties": { "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "provider": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "code_signature": { + "properties": { + "exists": { + "type": "boolean" + }, + "status": { + "type": "keyword", + "ignore_above": 1024 + }, + "subject_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "trusted": { + "type": "boolean" + }, + "valid": { + "type": "boolean" } } }, "container": { "properties": { "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "image": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "tag": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -342,20 +435,20 @@ "type": "object" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "runtime": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "destination": { "properties": { "address": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "as": { "properties": { @@ -365,8 +458,14 @@ "organization": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } } @@ -376,41 +475,41 @@ "type": "long" }, "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "geo": { "properties": { "city_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "continent_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "location": { "type": "geo_point" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -418,8 +517,8 @@ "type": "ip" }, "mac": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "nat": { "properties": { @@ -437,43 +536,144 @@ "port": { "type": "long" }, + "registered_domain": { + "type": "keyword", + "ignore_above": 1024 + }, + "top_level_domain": { + "type": "keyword", + "ignore_above": 1024 + }, "user": { "properties": { "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "email": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "group": { "properties": { + "domain": { + "type": "keyword", + "ignore_above": 1024 + }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "hash": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + } + } + } + } + }, + "dll": { + "properties": { + "code_signature": { + "properties": { + "exists": { + "type": "boolean" + }, + "status": { + "type": "keyword", + "ignore_above": 1024 + }, + "subject_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "trusted": { + "type": "boolean" + }, + "valid": { + "type": "boolean" + } + } + }, + "hash": { + "properties": { + "md5": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha1": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha256": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha512": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + }, + "path": { + "type": "keyword", + "ignore_above": 1024 + }, + "pe": { + "properties": { + "company": { + "type": "keyword", + "ignore_above": 1024 + }, + "description": { + "type": "keyword", + "ignore_above": 1024 + }, + "file_version": { + "type": "keyword", + "ignore_above": 1024 + }, + "original_file_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "product": { + "type": "keyword", + "ignore_above": 1024 } } } @@ -484,55 +684,63 @@ "answers": { "properties": { "class": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "data": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "ttl": { "type": "long" }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "header_flags": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "op_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "question": { "properties": { "class": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "registered_domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "subdomain": { + "type": "keyword", + "ignore_above": 1024 + }, + "top_level_domain": { + "type": "keyword", + "ignore_above": 1024 }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -540,12 +748,12 @@ "type": "ip" }, "response_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -563,51 +771,61 @@ "ecs": { "properties": { "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "error": { "properties": { "code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "message": { - "norms": false, - "type": "text" + "type": "text", + "norms": false + }, + "stack_trace": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "event": { "properties": { "action": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "category": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "created": { "type": "date" }, "dataset": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "duration": { "type": "long" @@ -616,32 +834,39 @@ "type": "date" }, "hash": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "ingested": { + "type": "date" }, "kind": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "module": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "original": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "outcome": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "provider": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "reference": { + "type": "keyword", + "ignore_above": 1024 }, "risk_score": { "type": "float" @@ -659,12 +884,16 @@ "type": "date" }, "timezone": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "url": { + "type": "keyword", + "ignore_above": 1024 } } }, @@ -676,6 +905,31 @@ "accessed": { "type": "date" }, + "attributes": { + "type": "keyword", + "ignore_above": 1024 + }, + "code_signature": { + "properties": { + "exists": { + "type": "boolean" + }, + "status": { + "type": "keyword", + "ignore_above": 1024 + }, + "subject_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "trusted": { + "type": "boolean" + }, + "valid": { + "type": "boolean" + } + } + }, "created": { "type": "date" }, @@ -683,254 +937,318 @@ "type": "date" }, "device": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "directory": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "drive_letter": { + "type": "keyword", + "ignore_above": 1 }, "extension": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "gid": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "group": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "hash": { "properties": { "md5": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "sha1": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "sha256": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "sha512": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "inode": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "mime_type": { + "type": "keyword", + "ignore_above": 1024 }, "mode": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "mtime": { "type": "date" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "owner": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "path": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "pe": { + "properties": { + "company": { + "type": "keyword", + "ignore_above": 1024 + }, + "description": { + "type": "keyword", + "ignore_above": 1024 + }, + "file_version": { + "type": "keyword", + "ignore_above": 1024 + }, + "original_file_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "product": { + "type": "keyword", + "ignore_above": 1024 + } + } }, "size": { "type": "long" }, "target_path": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "uid": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "geo": { "properties": { "city_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "continent_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "location": { "type": "geo_point" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "group": { "properties": { + "domain": { + "type": "keyword", + "ignore_above": 1024 + }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "hash": { "properties": { "md5": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "sha1": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "sha256": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "sha512": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "host": { "properties": { "architecture": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "containerized": { "type": "boolean" }, + "domain": { + "type": "keyword", + "ignore_above": 1024 + }, "geo": { "properties": { "city_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "continent_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "location": { "type": "geo_point" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "hostname": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "ip": { "type": "ip" }, "mac": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "os": { "properties": { "build": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "codename": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "family": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "kernel": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "platform": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "uptime": { "type": "long" @@ -938,40 +1256,56 @@ "user": { "properties": { "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "email": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "group": { "properties": { + "domain": { + "type": "keyword", + "ignore_above": 1024 + }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "hash": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } } @@ -987,8 +1321,14 @@ "type": "long" }, "content": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } }, @@ -996,12 +1336,12 @@ "type": "long" }, "method": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "referrer": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1013,18 +1353,28 @@ "type": "long" }, "content": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "hash": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "bytes": { "type": "long" }, + "redirects": { + "type": "keyword", + "ignore_above": 1024 + }, "status_code": { "type": "long" } @@ -1077,8 +1427,8 @@ } }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1096,17 +1446,33 @@ } } }, + "interface": { + "properties": { + "alias": { + "type": "keyword", + "ignore_above": 1024 + }, + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, "jolokia": { "properties": { "agent": { "properties": { "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1116,22 +1482,22 @@ "server": { "properties": { "product": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "vendor": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "url": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1147,20 +1513,20 @@ "container": { "properties": { "image": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "deployment": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1172,42 +1538,42 @@ } }, "namespace": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "node": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "pod": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "uid": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "replicaset": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "statefulset": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } } @@ -1219,28 +1585,76 @@ "log": { "properties": { "level": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "logger": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "origin": { + "properties": { + "file": { + "properties": { + "line": { + "type": "long" + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "function": { + "type": "keyword", + "ignore_above": 1024 + } + } }, "original": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "syslog": { + "properties": { + "facility": { + "properties": { + "code": { + "type": "long" + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "priority": { + "type": "long" + }, + "severity": { + "properties": { + "code": { + "type": "long" + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + } + } } } }, "message": { - "norms": false, - "type": "text" + "type": "text", + "norms": false }, "monitor": { "properties": { "check_group": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "duration": { "properties": { @@ -1250,282 +1664,766 @@ } }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "ip": { "type": "ip" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "status": { - "ignore_above": 1024, - "type": "keyword" - }, - "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "timespan": { "type": "date_range" + }, + "type": { + "type": "keyword", + "ignore_above": 1024 } } }, "network": { "properties": { "application": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "bytes": { "type": "long" }, "community_id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "direction": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "forwarded_ip": { "type": "ip" }, "iana_number": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "inner": { + "properties": { + "vlan": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + } + } }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "packets": { "type": "long" }, "protocol": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "transport": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "vlan": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } } } }, "observer": { "properties": { + "egress": { + "properties": { + "interface": { + "properties": { + "alias": { + "type": "keyword", + "ignore_above": 1024 + }, + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "vlan": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "zone": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, "geo": { "properties": { "city_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "continent_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "location": { "type": "geo_point" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "hostname": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "ingress": { + "properties": { + "interface": { + "properties": { + "alias": { + "type": "keyword", + "ignore_above": 1024 + }, + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "vlan": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "zone": { + "type": "keyword", + "ignore_above": 1024 + } + } }, "ip": { "type": "ip" }, "mac": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 }, "os": { "properties": { "family": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "kernel": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "platform": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, + "product": { + "type": "keyword", + "ignore_above": 1024 + }, "serial_number": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "vendor": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "organization": { "properties": { "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } }, "os": { "properties": { "family": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "kernel": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "platform": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, - "process": { + "package": { "properties": { - "args": { - "ignore_above": 1024, - "type": "keyword" + "architecture": { + "type": "keyword", + "ignore_above": 1024 }, - "executable": { - "ignore_above": 1024, - "type": "keyword" + "build_version": { + "type": "keyword", + "ignore_above": 1024 }, - "hash": { - "properties": { - "md5": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha1": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha256": { - "ignore_above": 1024, - "type": "keyword" - }, - "sha512": { - "ignore_above": 1024, - "type": "keyword" - } - } + "checksum": { + "type": "keyword", + "ignore_above": 1024 + }, + "description": { + "type": "keyword", + "ignore_above": 1024 + }, + "install_scope": { + "type": "keyword", + "ignore_above": 1024 + }, + "installed": { + "type": "date" + }, + "license": { + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, - "pgid": { - "type": "long" + "path": { + "type": "keyword", + "ignore_above": 1024 }, - "pid": { - "type": "long" + "reference": { + "type": "keyword", + "ignore_above": 1024 }, - "ppid": { + "size": { "type": "long" }, - "start": { - "type": "date" + "type": { + "type": "keyword", + "ignore_above": 1024 }, - "thread": { - "properties": { - "id": { - "type": "long" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - } + "version": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "pe": { + "properties": { + "company": { + "type": "keyword", + "ignore_above": 1024 + }, + "description": { + "type": "keyword", + "ignore_above": 1024 + }, + "file_version": { + "type": "keyword", + "ignore_above": 1024 + }, + "original_file_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "product": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "process": { + "properties": { + "args": { + "type": "keyword", + "ignore_above": 1024 + }, + "args_count": { + "type": "long" + }, + "code_signature": { + "properties": { + "exists": { + "type": "boolean" + }, + "status": { + "type": "keyword", + "ignore_above": 1024 + }, + "subject_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "trusted": { + "type": "boolean" + }, + "valid": { + "type": "boolean" + } + } + }, + "command_line": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "entity_id": { + "type": "keyword", + "ignore_above": 1024 + }, + "executable": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "exit_code": { + "type": "long" + }, + "hash": { + "properties": { + "md5": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha1": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha256": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha512": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "name": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "parent": { + "properties": { + "args": { + "type": "keyword", + "ignore_above": 1024 + }, + "args_count": { + "type": "long" + }, + "code_signature": { + "properties": { + "exists": { + "type": "boolean" + }, + "status": { + "type": "keyword", + "ignore_above": 1024 + }, + "subject_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "trusted": { + "type": "boolean" + }, + "valid": { + "type": "boolean" + } + } + }, + "command_line": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "entity_id": { + "type": "keyword", + "ignore_above": 1024 + }, + "executable": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "exit_code": { + "type": "long" + }, + "hash": { + "properties": { + "md5": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha1": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha256": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha512": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "name": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "pgid": { + "type": "long" + }, + "pid": { + "type": "long" + }, + "ppid": { + "type": "long" + }, + "start": { + "type": "date" + }, + "thread": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "title": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "uptime": { + "type": "long" + }, + "working_directory": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + } + } + }, + "pe": { + "properties": { + "company": { + "type": "keyword", + "ignore_above": 1024 + }, + "description": { + "type": "keyword", + "ignore_above": 1024 + }, + "file_version": { + "type": "keyword", + "ignore_above": 1024 + }, + "original_file_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "product": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "pgid": { + "type": "long" + }, + "pid": { + "type": "long" + }, + "ppid": { + "type": "long" + }, + "start": { + "type": "date" + }, + "thread": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } } }, "title": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "uptime": { "type": "long" }, "working_directory": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + } + } + }, + "registry": { + "properties": { + "data": { + "properties": { + "bytes": { + "type": "keyword", + "ignore_above": 1024 + }, + "strings": { + "type": "keyword", + "ignore_above": 1024 + }, + "type": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "hive": { + "type": "keyword", + "ignore_above": 1024 + }, + "key": { + "type": "keyword", + "ignore_above": 1024 + }, + "path": { + "type": "keyword", + "ignore_above": 1024 + }, + "value": { + "type": "keyword", + "ignore_above": 1024 } } }, "related": { "properties": { + "hash": { + "type": "keyword", + "ignore_above": 1024 + }, "ip": { "type": "ip" + }, + "user": { + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1543,11 +2441,55 @@ } } }, + "rule": { + "properties": { + "author": { + "type": "keyword", + "ignore_above": 1024 + }, + "category": { + "type": "keyword", + "ignore_above": 1024 + }, + "description": { + "type": "keyword", + "ignore_above": 1024 + }, + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "license": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + }, + "reference": { + "type": "keyword", + "ignore_above": 1024 + }, + "ruleset": { + "type": "keyword", + "ignore_above": 1024 + }, + "uuid": { + "type": "keyword", + "ignore_above": 1024 + }, + "version": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, "server": { "properties": { "address": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "as": { "properties": { @@ -1557,8 +2499,14 @@ "organization": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } } @@ -1568,41 +2516,41 @@ "type": "long" }, "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "geo": { "properties": { "city_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "continent_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "location": { "type": "geo_point" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1610,8 +2558,8 @@ "type": "ip" }, "mac": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "nat": { "properties": { @@ -1629,43 +2577,67 @@ "port": { "type": "long" }, + "registered_domain": { + "type": "keyword", + "ignore_above": 1024 + }, + "top_level_domain": { + "type": "keyword", + "ignore_above": 1024 + }, "user": { "properties": { "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "email": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "group": { "properties": { + "domain": { + "type": "keyword", + "ignore_above": 1024 + }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "hash": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } } @@ -1674,28 +2646,36 @@ "service": { "properties": { "ephemeral_id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "node": { + "properties": { + "name": { + "type": "keyword", + "ignore_above": 1024 + } + } }, "state": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "type": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1717,8 +2697,8 @@ "source": { "properties": { "address": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "as": { "properties": { @@ -1728,8 +2708,14 @@ "organization": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } } @@ -1739,41 +2725,41 @@ "type": "long" }, "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "geo": { "properties": { "city_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "continent_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "country_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "location": { "type": "geo_point" }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_iso_code": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "region_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1781,8 +2767,8 @@ "type": "ip" }, "mac": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "nat": { "properties": { @@ -1800,43 +2786,67 @@ "port": { "type": "long" }, + "registered_domain": { + "type": "keyword", + "ignore_above": 1024 + }, + "top_level_domain": { + "type": "keyword", + "ignore_above": 1024 + }, "user": { "properties": { "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "email": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "group": { "properties": { + "domain": { + "type": "keyword", + "ignore_above": 1024 + }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "hash": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } } @@ -1853,8 +2863,8 @@ } }, "tags": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "tcp": { "properties": { @@ -1878,11 +2888,57 @@ } } }, + "threat": { + "properties": { + "framework": { + "type": "keyword", + "ignore_above": 1024 + }, + "tactic": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + }, + "reference": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "technique": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "reference": { + "type": "keyword", + "ignore_above": 1024 + } + } + } + } + }, "timeseries": { "properties": { "instance": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1894,6 +2950,78 @@ "certificate_not_valid_before": { "type": "date" }, + "cipher": { + "type": "keyword", + "ignore_above": 1024 + }, + "client": { + "properties": { + "certificate": { + "type": "keyword", + "ignore_above": 1024 + }, + "certificate_chain": { + "type": "keyword", + "ignore_above": 1024 + }, + "hash": { + "properties": { + "md5": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha1": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha256": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "issuer": { + "type": "keyword", + "ignore_above": 1024 + }, + "ja3": { + "type": "keyword", + "ignore_above": 1024 + }, + "not_after": { + "type": "date" + }, + "not_before": { + "type": "date" + }, + "server_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "subject": { + "type": "keyword", + "ignore_above": 1024 + }, + "supported_ciphers": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "curve": { + "type": "keyword", + "ignore_above": 1024 + }, + "established": { + "type": "boolean" + }, + "next_protocol": { + "type": "keyword", + "ignore_above": 1024 + }, + "resumed": { + "type": "boolean" + }, "rtt": { "properties": { "handshake": { @@ -1904,6 +3032,114 @@ } } } + }, + "server": { + "properties": { + "certificate": { + "type": "keyword", + "ignore_above": 1024 + }, + "certificate_chain": { + "type": "keyword", + "ignore_above": 1024 + }, + "hash": { + "properties": { + "md5": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha1": { + "type": "keyword", + "ignore_above": 1024 + }, + "sha256": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "issuer": { + "type": "keyword", + "ignore_above": 1024 + }, + "ja3s": { + "type": "keyword", + "ignore_above": 1024 + }, + "not_after": { + "type": "date" + }, + "not_before": { + "type": "date" + }, + "subject": { + "type": "keyword", + "ignore_above": 1024 + }, + "x509": { + "properties": { + "issuer": { + "properties": { + "common_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "distinguished_name": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "not_after": { + "type": "keyword", + "ignore_above": 1024 + }, + "not_before": { + "type": "keyword", + "ignore_above": 1024 + }, + "public_key_algorithm": { + "type": "keyword", + "ignore_above": 1024 + }, + "public_key_exponent": { + "type": "long" + }, + "public_key_size": { + "type": "long" + }, + "serial_number": { + "type": "keyword", + "ignore_above": 1024 + }, + "signature_algorithm": { + "type": "keyword", + "ignore_above": 1024 + }, + "subject": { + "properties": { + "common_name": { + "type": "keyword", + "ignore_above": 1024 + }, + "distinguished_name": { + "type": "keyword", + "ignore_above": 1024 + } + } + } + } + } + } + }, + "version": { + "type": "keyword", + "ignore_above": 1024 + }, + "version_protocol": { + "type": "keyword", + "ignore_above": 1024 } } }, @@ -1912,16 +3148,16 @@ "trace": { "properties": { "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "transaction": { "properties": { "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } } @@ -1930,83 +3166,123 @@ "url": { "properties": { "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "extension": { + "type": "keyword", + "ignore_above": 1024 }, "fragment": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "original": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "password": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "path": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "port": { "type": "long" }, "query": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "registered_domain": { + "type": "keyword", + "ignore_above": 1024 }, "scheme": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 + }, + "top_level_domain": { + "type": "keyword", + "ignore_above": 1024 }, "username": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "user": { "properties": { "domain": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "email": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full_name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "group": { "properties": { + "domain": { + "type": "keyword", + "ignore_above": 1024 + }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "hash": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "id": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 } } }, @@ -2015,370 +3291,467 @@ "device": { "properties": { "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "original": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "os": { "properties": { "family": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "full": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "kernel": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "name": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 }, "platform": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } }, "version": { - "ignore_above": 1024, - "type": "keyword" + "type": "keyword", + "ignore_above": 1024 } } - } - } - }, - "settings": { - "index": { - "mapping": { - "total_fields": { - "limit": "10000" + }, + "vlan": { + "properties": { + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "name": { + "type": "keyword", + "ignore_above": 1024 + } } }, - "number_of_replicas": "1", - "number_of_shards": "1", - "query": { - "default_field": [ - "message", - "tags", - "agent.ephemeral_id", - "agent.id", - "agent.name", - "agent.type", - "agent.version", - "as.organization.name", - "client.address", - "client.as.organization.name", - "client.domain", - "client.geo.city_name", - "client.geo.continent_name", - "client.geo.country_iso_code", - "client.geo.country_name", - "client.geo.name", - "client.geo.region_iso_code", - "client.geo.region_name", - "client.mac", - "client.user.domain", - "client.user.email", - "client.user.full_name", - "client.user.group.id", - "client.user.group.name", - "client.user.hash", - "client.user.id", - "client.user.name", - "cloud.account.id", - "cloud.availability_zone", - "cloud.instance.id", - "cloud.instance.name", - "cloud.machine.type", - "cloud.provider", - "cloud.region", - "container.id", - "container.image.name", - "container.image.tag", - "container.name", - "container.runtime", - "destination.address", - "destination.as.organization.name", - "destination.domain", - "destination.geo.city_name", - "destination.geo.continent_name", - "destination.geo.country_iso_code", - "destination.geo.country_name", - "destination.geo.name", - "destination.geo.region_iso_code", - "destination.geo.region_name", - "destination.mac", - "destination.user.domain", - "destination.user.email", - "destination.user.full_name", - "destination.user.group.id", - "destination.user.group.name", - "destination.user.hash", - "destination.user.id", - "destination.user.name", - "dns.answers.class", - "dns.answers.data", - "dns.answers.name", - "dns.answers.type", - "dns.header_flags", - "dns.id", - "dns.op_code", - "dns.question.class", - "dns.question.name", - "dns.question.registered_domain", - "dns.question.type", - "dns.response_code", - "dns.type", - "ecs.version", - "error.code", - "error.id", - "error.message", - "event.action", - "event.category", - "event.code", - "event.dataset", - "event.hash", - "event.id", - "event.kind", - "event.module", - "event.original", - "event.outcome", - "event.provider", - "event.timezone", - "event.type", - "file.device", - "file.directory", - "file.extension", - "file.gid", - "file.group", - "file.hash.md5", - "file.hash.sha1", - "file.hash.sha256", - "file.hash.sha512", - "file.inode", - "file.mode", - "file.name", - "file.owner", - "file.path", - "file.target_path", - "file.type", - "file.uid", - "geo.city_name", - "geo.continent_name", - "geo.country_iso_code", - "geo.country_name", - "geo.name", - "geo.region_iso_code", - "geo.region_name", - "group.id", - "group.name", - "hash.md5", - "hash.sha1", - "hash.sha256", - "hash.sha512", - "host.architecture", - "host.geo.city_name", - "host.geo.continent_name", - "host.geo.country_iso_code", - "host.geo.country_name", - "host.geo.name", - "host.geo.region_iso_code", - "host.geo.region_name", - "host.hostname", - "host.id", - "host.mac", - "host.name", - "host.os.family", - "host.os.full", - "host.os.kernel", - "host.os.name", - "host.os.platform", - "host.os.version", - "host.type", - "host.user.domain", - "host.user.email", - "host.user.full_name", - "host.user.group.id", - "host.user.group.name", - "host.user.hash", - "host.user.id", - "host.user.name", - "http.request.body.content", - "http.request.method", - "http.request.referrer", - "http.response.body.content", - "http.version", - "log.level", - "log.logger", - "log.original", - "network.application", - "network.community_id", - "network.direction", - "network.iana_number", - "network.name", - "network.protocol", - "network.transport", - "network.type", - "observer.geo.city_name", - "observer.geo.continent_name", - "observer.geo.country_iso_code", - "observer.geo.country_name", - "observer.geo.name", - "observer.geo.region_iso_code", - "observer.geo.region_name", - "observer.hostname", - "observer.mac", - "observer.os.family", - "observer.os.full", - "observer.os.kernel", - "observer.os.name", - "observer.os.platform", - "observer.os.version", - "observer.serial_number", - "observer.type", - "observer.vendor", - "observer.version", - "organization.id", - "organization.name", - "os.family", - "os.full", - "os.kernel", - "os.name", - "os.platform", - "os.version", - "process.args", - "process.executable", - "process.hash.md5", - "process.hash.sha1", - "process.hash.sha256", - "process.hash.sha512", - "process.name", - "process.thread.name", - "process.title", - "process.working_directory", - "server.address", - "server.as.organization.name", - "server.domain", - "server.geo.city_name", - "server.geo.continent_name", - "server.geo.country_iso_code", - "server.geo.country_name", - "server.geo.name", - "server.geo.region_iso_code", - "server.geo.region_name", - "server.mac", - "server.user.domain", - "server.user.email", - "server.user.full_name", - "server.user.group.id", - "server.user.group.name", - "server.user.hash", - "server.user.id", - "server.user.name", - "service.ephemeral_id", - "service.id", - "service.name", - "service.state", - "service.type", - "service.version", - "source.address", - "source.as.organization.name", - "source.domain", - "source.geo.city_name", - "source.geo.continent_name", - "source.geo.country_iso_code", - "source.geo.country_name", - "source.geo.name", - "source.geo.region_iso_code", - "source.geo.region_name", - "source.mac", - "source.user.domain", - "source.user.email", - "source.user.full_name", - "source.user.group.id", - "source.user.group.name", - "source.user.hash", - "source.user.id", - "source.user.name", - "tracing.trace.id", - "tracing.transaction.id", - "url.domain", - "url.fragment", - "url.full", - "url.original", - "url.password", - "url.path", - "url.query", - "url.scheme", - "url.username", - "user.domain", - "user.email", - "user.full_name", - "user.group.id", - "user.group.name", - "user.hash", - "user.id", - "user.name", - "user_agent.device.name", - "user_agent.name", - "user_agent.original", - "user_agent.os.family", - "user_agent.os.full", - "user_agent.os.kernel", - "user_agent.os.name", - "user_agent.os.platform", - "user_agent.os.version", - "user_agent.version", - "agent.hostname", - "error.type", - "timeseries.instance", - "cloud.project.id", - "cloud.image.id", - "host.os.build", - "host.os.codename", - "kubernetes.pod.name", - "kubernetes.pod.uid", - "kubernetes.namespace", - "kubernetes.node.name", - "kubernetes.replicaset.name", - "kubernetes.deployment.name", - "kubernetes.statefulset.name", - "kubernetes.container.name", - "kubernetes.container.image", - "jolokia.agent.version", - "jolokia.agent.id", - "jolokia.server.product", - "jolokia.server.version", - "jolokia.server.vendor", - "jolokia.url", - "monitor.type", - "monitor.name", - "monitor.id", - "monitor.status", - "monitor.check_group", - "http.response.body.hash", - "fields.*" - ] - }, - "refresh_interval": "5s" + "vulnerability": { + "properties": { + "category": { + "type": "keyword", + "ignore_above": 1024 + }, + "classification": { + "type": "keyword", + "ignore_above": 1024 + }, + "description": { + "type": "keyword", + "fields": { + "text": { + "type": "text", + "norms": false + } + }, + "ignore_above": 1024 + }, + "enumeration": { + "type": "keyword", + "ignore_above": 1024 + }, + "id": { + "type": "keyword", + "ignore_above": 1024 + }, + "reference": { + "type": "keyword", + "ignore_above": 1024 + }, + "report_id": { + "type": "keyword", + "ignore_above": 1024 + }, + "scanner": { + "properties": { + "vendor": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "score": { + "properties": { + "base": { + "type": "float" + }, + "environmental": { + "type": "float" + }, + "temporal": { + "type": "float" + }, + "version": { + "type": "keyword", + "ignore_above": 1024 + } + } + }, + "severity": { + "type": "keyword", + "ignore_above": 1024 + } + } + } } } + }, + "settings": { + "index": { + "mapping": { + "total_fields": { + "limit": "10000" + } + }, + "number_of_replicas": "1", + "number_of_shards": "1", + "query": { + "default_field": [ + "message", + "tags", + "agent.ephemeral_id", + "agent.id", + "agent.name", + "agent.type", + "agent.version", + "as.organization.name", + "client.address", + "client.as.organization.name", + "client.domain", + "client.geo.city_name", + "client.geo.continent_name", + "client.geo.country_iso_code", + "client.geo.country_name", + "client.geo.name", + "client.geo.region_iso_code", + "client.geo.region_name", + "client.mac", + "client.user.domain", + "client.user.email", + "client.user.full_name", + "client.user.group.id", + "client.user.group.name", + "client.user.hash", + "client.user.id", + "client.user.name", + "cloud.account.id", + "cloud.availability_zone", + "cloud.instance.id", + "cloud.instance.name", + "cloud.machine.type", + "cloud.provider", + "cloud.region", + "container.id", + "container.image.name", + "container.image.tag", + "container.name", + "container.runtime", + "destination.address", + "destination.as.organization.name", + "destination.domain", + "destination.geo.city_name", + "destination.geo.continent_name", + "destination.geo.country_iso_code", + "destination.geo.country_name", + "destination.geo.name", + "destination.geo.region_iso_code", + "destination.geo.region_name", + "destination.mac", + "destination.user.domain", + "destination.user.email", + "destination.user.full_name", + "destination.user.group.id", + "destination.user.group.name", + "destination.user.hash", + "destination.user.id", + "destination.user.name", + "dns.answers.class", + "dns.answers.data", + "dns.answers.name", + "dns.answers.type", + "dns.header_flags", + "dns.id", + "dns.op_code", + "dns.question.class", + "dns.question.name", + "dns.question.registered_domain", + "dns.question.type", + "dns.response_code", + "dns.type", + "ecs.version", + "error.code", + "error.id", + "error.message", + "event.action", + "event.category", + "event.code", + "event.dataset", + "event.hash", + "event.id", + "event.kind", + "event.module", + "event.original", + "event.outcome", + "event.provider", + "event.timezone", + "event.type", + "file.device", + "file.directory", + "file.extension", + "file.gid", + "file.group", + "file.hash.md5", + "file.hash.sha1", + "file.hash.sha256", + "file.hash.sha512", + "file.inode", + "file.mode", + "file.name", + "file.owner", + "file.path", + "file.target_path", + "file.type", + "file.uid", + "geo.city_name", + "geo.continent_name", + "geo.country_iso_code", + "geo.country_name", + "geo.name", + "geo.region_iso_code", + "geo.region_name", + "group.id", + "group.name", + "hash.md5", + "hash.sha1", + "hash.sha256", + "hash.sha512", + "host.architecture", + "host.geo.city_name", + "host.geo.continent_name", + "host.geo.country_iso_code", + "host.geo.country_name", + "host.geo.name", + "host.geo.region_iso_code", + "host.geo.region_name", + "host.hostname", + "host.id", + "host.mac", + "host.name", + "host.os.family", + "host.os.full", + "host.os.kernel", + "host.os.name", + "host.os.platform", + "host.os.version", + "host.type", + "host.user.domain", + "host.user.email", + "host.user.full_name", + "host.user.group.id", + "host.user.group.name", + "host.user.hash", + "host.user.id", + "host.user.name", + "http.request.body.content", + "http.request.method", + "http.request.referrer", + "http.response.body.content", + "http.version", + "log.level", + "log.logger", + "log.original", + "network.application", + "network.community_id", + "network.direction", + "network.iana_number", + "network.name", + "network.protocol", + "network.transport", + "network.type", + "observer.geo.city_name", + "observer.geo.continent_name", + "observer.geo.country_iso_code", + "observer.geo.country_name", + "observer.geo.name", + "observer.geo.region_iso_code", + "observer.geo.region_name", + "observer.hostname", + "observer.mac", + "observer.os.family", + "observer.os.full", + "observer.os.kernel", + "observer.os.name", + "observer.os.platform", + "observer.os.version", + "observer.serial_number", + "observer.type", + "observer.vendor", + "observer.version", + "organization.id", + "organization.name", + "os.family", + "os.full", + "os.kernel", + "os.name", + "os.platform", + "os.version", + "process.args", + "process.executable", + "process.hash.md5", + "process.hash.sha1", + "process.hash.sha256", + "process.hash.sha512", + "process.name", + "process.thread.name", + "process.title", + "process.working_directory", + "server.address", + "server.as.organization.name", + "server.domain", + "server.geo.city_name", + "server.geo.continent_name", + "server.geo.country_iso_code", + "server.geo.country_name", + "server.geo.name", + "server.geo.region_iso_code", + "server.geo.region_name", + "server.mac", + "server.user.domain", + "server.user.email", + "server.user.full_name", + "server.user.group.id", + "server.user.group.name", + "server.user.hash", + "server.user.id", + "server.user.name", + "service.ephemeral_id", + "service.id", + "service.name", + "service.state", + "service.type", + "service.version", + "source.address", + "source.as.organization.name", + "source.domain", + "source.geo.city_name", + "source.geo.continent_name", + "source.geo.country_iso_code", + "source.geo.country_name", + "source.geo.name", + "source.geo.region_iso_code", + "source.geo.region_name", + "source.mac", + "source.user.domain", + "source.user.email", + "source.user.full_name", + "source.user.group.id", + "source.user.group.name", + "source.user.hash", + "source.user.id", + "source.user.name", + "tracing.trace.id", + "tracing.transaction.id", + "url.domain", + "url.fragment", + "url.full", + "url.original", + "url.password", + "url.path", + "url.query", + "url.scheme", + "url.username", + "user.domain", + "user.email", + "user.full_name", + "user.group.id", + "user.group.name", + "user.hash", + "user.id", + "user.name", + "user_agent.device.name", + "user_agent.name", + "user_agent.original", + "user_agent.os.family", + "user_agent.os.full", + "user_agent.os.kernel", + "user_agent.os.name", + "user_agent.os.platform", + "user_agent.os.version", + "user_agent.version", + "agent.hostname", + "error.type", + "timeseries.instance", + "cloud.project.id", + "cloud.image.id", + "host.os.build", + "host.os.codename", + "kubernetes.pod.name", + "kubernetes.pod.uid", + "kubernetes.namespace", + "kubernetes.node.name", + "kubernetes.replicaset.name", + "kubernetes.deployment.name", + "kubernetes.statefulset.name", + "kubernetes.container.name", + "kubernetes.container.image", + "jolokia.agent.version", + "jolokia.agent.id", + "jolokia.server.product", + "jolokia.server.version", + "jolokia.server.vendor", + "jolokia.url", + "monitor.type", + "monitor.name", + "monitor.id", + "monitor.status", + "monitor.check_group", + "http.response.body.hash", + "fields.*" + ] + }, + "refresh_interval": "5s" + } } } diff --git a/x-pack/test/functional/services/machine_learning/index.ts b/x-pack/test/functional/services/machine_learning/index.ts index f5adf63825163..b792f17efcbca 100644 --- a/x-pack/test/functional/services/machine_learning/index.ts +++ b/x-pack/test/functional/services/machine_learning/index.ts @@ -30,3 +30,4 @@ export { MachineLearningSecurityCommonProvider } from './security_common'; export { MachineLearningSecurityUIProvider } from './security_ui'; export { MachineLearningSettingsProvider } from './settings'; export { MachineLearningSingleMetricViewerProvider } from './single_metric_viewer'; +export { MachineLearningTestResourcesProvider } from './test_resources'; diff --git a/x-pack/test/functional/services/machine_learning/test_resources.ts b/x-pack/test/functional/services/machine_learning/test_resources.ts new file mode 100644 index 0000000000000..0d61c1413b988 --- /dev/null +++ b/x-pack/test/functional/services/machine_learning/test_resources.ts @@ -0,0 +1,219 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ProvidedType } from '@kbn/test/types/ftr'; + +import { savedSearches } from './test_resources_data'; + +import { FtrProviderContext } from '../../ftr_provider_context'; + +const COMMON_HEADERS = { + 'kbn-xsrf': 'some-xsrf-token', +}; + +export enum SavedObjectType { + CONFIG = 'config', + DASHBOARD = 'dashboard', + INDEX_PATTERN = 'index-pattern', + SEARCH = 'search', + VISUALIZATION = 'visualization', +} + +export type MlTestResourcesi = ProvidedType; + +export function MachineLearningTestResourcesProvider({ getService }: FtrProviderContext) { + const kibanaServer = getService('kibanaServer'); + const log = getService('log'); + const supertest = getService('supertest'); + + return { + async setKibanaTimeZoneToUTC() { + await kibanaServer.uiSettings.update({ + 'dateFormat:tz': 'UTC', + }); + }, + + async resetKibanaTimeZone() { + await kibanaServer.uiSettings.unset('dateFormat:tz'); + }, + + async savedObjectExists(id: string, objectType: SavedObjectType): Promise { + const response = await supertest.get(`/api/saved_objects/${objectType}/${id}`); + return response.status === 200; + }, + + async getSavedObjectIdByTitle( + title: string, + objectType: SavedObjectType + ): Promise { + log.debug(`Searching for '${objectType}' with title '${title}'...`); + const findResponse = await supertest + .get(`/api/saved_objects/_find?type=${objectType}`) + .set(COMMON_HEADERS) + .expect(200) + .then((res: any) => res.body); + + for (const savedObject of findResponse.saved_objects) { + const objectTitle = savedObject.attributes.title; + if (objectTitle === title) { + log.debug(` > Found '${savedObject.id}'`); + return savedObject.id; + } + } + log.debug(` > Not found`); + }, + + async getIndexPatternId(title: string): Promise { + return this.getSavedObjectIdByTitle(title, SavedObjectType.INDEX_PATTERN); + }, + + async getSavedSearchId(title: string): Promise { + return this.getSavedObjectIdByTitle(title, SavedObjectType.SEARCH); + }, + + async createIndexPattern(title: string, timeFieldName?: string): Promise { + log.debug( + `Creating index pattern with title '${title}'${ + timeFieldName !== undefined ? ` and time field '${timeFieldName}'` : '' + }` + ); + + const createResponse = await supertest + .post(`/api/saved_objects/${SavedObjectType.INDEX_PATTERN}`) + .set(COMMON_HEADERS) + .send({ attributes: { title, timeFieldName } }) + .expect(200) + .then((res: any) => res.body); + + log.debug(` > Created with id '${createResponse.id}'`); + return createResponse.id; + }, + + async createIndexPatternIfNeeded(title: string, timeFieldName?: string): Promise { + const indexPatternId = await this.getIndexPatternId(title); + if (indexPatternId !== undefined) { + log.debug(`Index pattern with title '${title}' already exists. Nothing to create.`); + return indexPatternId; + } else { + return await this.createIndexPattern(title, timeFieldName); + } + }, + + async createSavedSearch(title: string, body: object): Promise { + log.debug(`Creating saved search with title '${title}'`); + + const createResponse = await supertest + .post(`/api/saved_objects/${SavedObjectType.SEARCH}`) + .set(COMMON_HEADERS) + .send(body) + .expect(200) + .then((res: any) => res.body); + + log.debug(` > Created with id '${createResponse.id}'`); + return createResponse.id; + }, + + async createSavedSearchIfNeeded(savedSearch: any): Promise { + const title = savedSearch.requestBody.attributes.title; + const savedSearchId = await this.getSavedSearchId(title); + if (savedSearchId !== undefined) { + log.debug(`Saved search with title '${title}' already exists. Nothing to create.`); + return savedSearchId; + } else { + const body = await this.updateSavedSearchRequestBody( + savedSearch.requestBody, + savedSearch.indexPatternTitle + ); + return await this.createSavedSearch(title, body); + } + }, + + async updateSavedSearchRequestBody(body: object, indexPatternTitle: string): Promise { + const indexPatternId = await this.getIndexPatternId(indexPatternTitle); + if (indexPatternId === undefined) { + throw new Error( + `Index pattern '${indexPatternTitle}' to base saved search on does not exist. ` + ); + } + + // inject index pattern id + const updatedBody = JSON.parse(JSON.stringify(body), (_key, value) => { + if (value === 'INDEX_PATTERN_ID_PLACEHOLDER') { + return indexPatternId; + } else { + return value; + } + }); + + // make searchSourceJSON node a string + const searchSourceJsonNode = updatedBody.attributes.kibanaSavedObjectMeta.searchSourceJSON; + const searchSourceJsonString = JSON.stringify(searchSourceJsonNode); + updatedBody.attributes.kibanaSavedObjectMeta.searchSourceJSON = searchSourceJsonString; + + return updatedBody; + }, + + async createSavedSearchFarequoteFilterIfNeeded() { + await this.createSavedSearchIfNeeded(savedSearches.farequoteFilter); + }, + + async createSavedSearchFarequoteLuceneIfNeeded() { + await this.createSavedSearchIfNeeded(savedSearches.farequoteLucene); + }, + + async createSavedSearchFarequoteKueryIfNeeded() { + await this.createSavedSearchIfNeeded(savedSearches.farequoteKuery); + }, + + async createSavedSearchFarequoteFilterAndLuceneIfNeeded() { + await this.createSavedSearchIfNeeded(savedSearches.farequoteFilterAndLucene); + }, + + async createSavedSearchFarequoteFilterAndKueryIfNeeded() { + await this.createSavedSearchIfNeeded(savedSearches.farequoteFilterAndKuery); + }, + + async deleteIndexPattern(title: string) { + log.debug(`Deleting index pattern with title '${title}'...`); + + const indexPatternId = await this.getIndexPatternId(title); + if (indexPatternId === undefined) { + log.debug(`Index pattern with title '${title}' does not exists. Nothing to delete.`); + return; + } else { + await supertest + .delete(`/api/saved_objects/${SavedObjectType.INDEX_PATTERN}/${indexPatternId}`) + .set(COMMON_HEADERS) + .expect(200); + + log.debug(` > Deleted index pattern with id '${indexPatternId}'`); + } + }, + + async deleteSavedSearch(title: string) { + log.debug(`Deleting saved search with title '${title}'...`); + + const savedSearchId = await this.getSavedSearchId(title); + if (savedSearchId === undefined) { + log.debug(`Saved search with title '${title}' does not exists. Nothing to delete.`); + return; + } else { + await supertest + .delete(`/api/saved_objects/${SavedObjectType.SEARCH}/${savedSearchId}`) + .set(COMMON_HEADERS) + .expect(200); + + log.debug(` > Deleted saved searchwith id '${savedSearchId}'`); + } + }, + + async deleteSavedSearches() { + for (const search of Object.values(savedSearches)) { + await this.deleteSavedSearch(search.requestBody.attributes.title); + } + }, + }; +} diff --git a/x-pack/test/functional/services/machine_learning/test_resources_data.ts b/x-pack/test/functional/services/machine_learning/test_resources_data.ts new file mode 100644 index 0000000000000..dd600077182f9 --- /dev/null +++ b/x-pack/test/functional/services/machine_learning/test_resources_data.ts @@ -0,0 +1,249 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const savedSearches = { + farequoteFilter: { + indexPatternTitle: 'ft_farequote', + requestBody: { + attributes: { + title: 'ft_farequote_filter', + description: '', + hits: 0, + columns: ['_source'], + sort: ['@timestamp', 'desc'], + version: 1, + kibanaSavedObjectMeta: { + searchSourceJSON: { + highlightAll: true, + version: true, + query: { + query: '', + language: 'lucene', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrase', + key: 'airline', + value: 'ASA', + params: { + query: 'ASA', + type: 'phrase', + }, + }, + query: { + match: { + airline: { + query: 'ASA', + type: 'phrase', + }, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }, + }, + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: 'INDEX_PATTERN_ID_PLACEHOLDER', + }, + ], + }, + }, + farequoteLucene: { + indexPatternTitle: 'ft_farequote', + requestBody: { + attributes: { + title: 'ft_farequote_lucene', + description: '', + hits: 0, + columns: ['_source'], + sort: ['@timestamp', 'desc'], + version: 1, + kibanaSavedObjectMeta: { + searchSourceJSON: { + highlightAll: true, + version: true, + query: { + query: 'airline:A*', + language: 'lucene', + }, + filter: [], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }, + }, + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: 'INDEX_PATTERN_ID_PLACEHOLDER', + }, + ], + }, + }, + farequoteKuery: { + indexPatternTitle: 'ft_farequote', + requestBody: { + attributes: { + title: 'ft_farequote_kuery', + description: '', + hits: 0, + columns: ['_source'], + sort: ['@timestamp', 'desc'], + version: 1, + kibanaSavedObjectMeta: { + searchSourceJSON: { + highlightAll: true, + version: true, + query: { + query: 'airline: A* and responsetime > 5', + language: 'kuery', + }, + filter: [], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }, + }, + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: 'INDEX_PATTERN_ID_PLACEHOLDER', + }, + ], + }, + }, + farequoteFilterAndLucene: { + indexPatternTitle: 'ft_farequote', + requestBody: { + attributes: { + title: 'ft_farequote_filter_and_lucene', + description: '', + hits: 0, + columns: ['_source'], + sort: ['@timestamp', 'desc'], + version: 1, + kibanaSavedObjectMeta: { + searchSourceJSON: { + highlightAll: true, + version: true, + query: { + query: 'responsetime:>50', + language: 'lucene', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrase', + key: 'airline', + value: 'ASA', + params: { + query: 'ASA', + type: 'phrase', + }, + }, + query: { + match: { + airline: { + query: 'ASA', + type: 'phrase', + }, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }, + }, + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: 'INDEX_PATTERN_ID_PLACEHOLDER', + }, + ], + }, + }, + farequoteFilterAndKuery: { + indexPatternTitle: 'ft_farequote', + requestBody: { + attributes: { + title: 'ft_farequote_filter_and_kuery', + description: '', + hits: 0, + columns: ['_source'], + sort: ['@timestamp', 'desc'], + version: 1, + kibanaSavedObjectMeta: { + searchSourceJSON: { + highlightAll: true, + version: true, + query: { + query: 'responsetime > 49', + language: 'kuery', + }, + filter: [ + { + meta: { + index: 'INDEX_PATTERN_ID_PLACEHOLDER', + negate: false, + disabled: false, + alias: null, + type: 'phrase', + key: 'airline', + value: 'ASA', + params: { + query: 'ASA', + type: 'phrase', + }, + }, + query: { + match: { + airline: { + query: 'ASA', + type: 'phrase', + }, + }, + }, + $state: { + store: 'appState', + }, + }, + ], + indexRefName: 'kibanaSavedObjectMeta.searchSourceJSON.index', + }, + }, + }, + references: [ + { + name: 'kibanaSavedObjectMeta.searchSourceJSON.index', + type: 'index-pattern', + id: 'INDEX_PATTERN_ID_PLACEHOLDER', + }, + ], + }, + }, +}; diff --git a/x-pack/test/functional/services/ml.ts b/x-pack/test/functional/services/ml.ts index af7cb51f4e3f0..be3d3e0c96016 100644 --- a/x-pack/test/functional/services/ml.ts +++ b/x-pack/test/functional/services/ml.ts @@ -33,6 +33,7 @@ import { MachineLearningSecurityUIProvider, MachineLearningSettingsProvider, MachineLearningSingleMetricViewerProvider, + MachineLearningTestResourcesProvider, } from './machine_learning'; export function MachineLearningProvider(context: FtrProviderContext) { @@ -67,6 +68,7 @@ export function MachineLearningProvider(context: FtrProviderContext) { const securityUI = MachineLearningSecurityUIProvider(context, securityCommon); const settings = MachineLearningSettingsProvider(context); const singleMetricViewer = MachineLearningSingleMetricViewerProvider(context); + const testResources = MachineLearningTestResourcesProvider(context); return { anomaliesTable, @@ -95,5 +97,6 @@ export function MachineLearningProvider(context: FtrProviderContext) { securityUI, settings, singleMetricViewer, + testResources, }; } diff --git a/x-pack/test/functional/services/transform.ts b/x-pack/test/functional/services/transform.ts index 74416ea070882..f0ca5f81bd5ec 100644 --- a/x-pack/test/functional/services/transform.ts +++ b/x-pack/test/functional/services/transform.ts @@ -17,6 +17,8 @@ import { TransformWizardProvider, } from './transform_ui'; +import { MachineLearningTestResourcesProvider } from './machine_learning'; + export function TransformProvider(context: FtrProviderContext) { const api = TransformAPIProvider(context); const management = TransformManagementProvider(context); @@ -25,6 +27,7 @@ export function TransformProvider(context: FtrProviderContext) { const securityUI = TransformSecurityUIProvider(context, securityCommon); const sourceSelection = TransformSourceSelectionProvider(context); const table = TransformTableProvider(context); + const testResources = MachineLearningTestResourcesProvider(context); const wizard = TransformWizardProvider(context); return { @@ -35,6 +38,7 @@ export function TransformProvider(context: FtrProviderContext) { securityUI, sourceSelection, table, + testResources, wizard, }; } diff --git a/x-pack/test/functional/services/uptime/settings.ts b/x-pack/test/functional/services/uptime/settings.ts index a64d39cd62a6d..14cab368b766a 100644 --- a/x-pack/test/functional/services/uptime/settings.ts +++ b/x-pack/test/functional/services/uptime/settings.ts @@ -10,20 +10,41 @@ export function UptimeSettingsProvider({ getService }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); + const changeInputField = async (text: string, field: string) => { + const input = await testSubjects.find(field, 5000); + await input.clearValueWithKeyboard(); + await input.type(text); + }; + return { go: async () => { await testSubjects.click('settings-page-link', 5000); }, + changeHeartbeatIndicesInput: async (text: string) => { - const input = await testSubjects.find('heartbeat-indices-input-loaded', 5000); - await input.clearValueWithKeyboard(); - await input.type(text); + await changeInputField(text, 'heartbeat-indices-input-loaded'); + }, + changeErrorThresholdInput: async (text: string) => { + await changeInputField(text, 'error-state-threshold-input-loaded'); + }, + changeWarningThresholdInput: async (text: string) => { + await changeInputField(text, 'warning-state-threshold-input-loaded'); }, loadFields: async () => { - const input = await testSubjects.find('heartbeat-indices-input-loaded', 5000); - const heartbeatIndices = await input.getAttribute('value'); + const indInput = await testSubjects.find('heartbeat-indices-input-loaded', 5000); + const errorInput = await testSubjects.find('error-state-threshold-input-loaded', 5000); + const warningInput = await testSubjects.find('warning-state-threshold-input-loaded', 5000); + const heartbeatIndices = await indInput.getAttribute('value'); + const errorThreshold = await errorInput.getAttribute('value'); + const warningThreshold = await warningInput.getAttribute('value'); - return { heartbeatIndices }; + return { + heartbeatIndices, + certificatesThresholds: { + errorState: errorThreshold, + warningState: warningThreshold, + }, + }; }, applyButtonIsDisabled: async () => { return !!(await (await testSubjects.find('apply-settings-button')).getAttribute('disabled')); diff --git a/x-pack/test/functional_endpoint/apps/endpoint/host_list.ts b/x-pack/test/functional_endpoint/apps/endpoint/host_list.ts index 2e204775808c9..35843dc6a76db 100644 --- a/x-pack/test/functional_endpoint/apps/endpoint/host_list.ts +++ b/x-pack/test/functional_endpoint/apps/endpoint/host_list.ts @@ -12,7 +12,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const esArchiver = getService('esArchiver'); const testSubjects = getService('testSubjects'); - describe('host list', function() { + // FLAKY: https://github.com/elastic/kibana/issues/63621 + describe.skip('host list', function() { this.tags('ciGroup7'); const sleep = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms)); before(async () => { @@ -167,7 +168,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { '', '0', '00000000-0000-0000-0000-000000000000', - 'active', + 'Successful', '10.101.149.262606:a000:ffc0:39:11ef:37b9:3371:578c', 'rezzani-7.example.com', '6.8.0', diff --git a/x-pack/test/functional_endpoint/config.ts b/x-pack/test/functional_endpoint/config.ts index 37bf57b67b47e..6ae78ab9d48ac 100644 --- a/x-pack/test/functional_endpoint/config.ts +++ b/x-pack/test/functional_endpoint/config.ts @@ -30,6 +30,7 @@ export default async function({ readConfigFile }: FtrConfigProviderContext) { ...xpackFunctionalConfig.get('kbnTestServer.serverArgs'), '--xpack.endpoint.enabled=true', '--xpack.ingestManager.enabled=true', + '--xpack.ingestManager.epm.enabled=true', '--xpack.ingestManager.fleet.enabled=true', ], }, diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts index bce8e08cd16d3..bbf8881f0c62a 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts @@ -343,15 +343,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('collapsedItemActions'); - await pageObjects.triggersActionsUI.toggleSwitch('enableSwitch'); + await pageObjects.triggersActionsUI.toggleSwitch('disableSwitch'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click('collapsedItemActions'); - const enableSwitchAfterDisable = await testSubjects.find('enableSwitch'); - const isChecked = await enableSwitchAfterDisable.getAttribute('aria-checked'); - expect(isChecked).to.eql('false'); + const disableSwitchAfterDisable = await testSubjects.find('disableSwitch'); + const isChecked = await disableSwitchAfterDisable.getAttribute('aria-checked'); + expect(isChecked).to.eql('true'); }); it('should re-enable single alert', async () => { @@ -361,21 +361,21 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('collapsedItemActions'); - await pageObjects.triggersActionsUI.toggleSwitch('enableSwitch'); + await pageObjects.triggersActionsUI.toggleSwitch('disableSwitch'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click('collapsedItemActions'); - await pageObjects.triggersActionsUI.toggleSwitch('enableSwitch'); + await pageObjects.triggersActionsUI.toggleSwitch('disableSwitch'); await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name); await testSubjects.click('collapsedItemActions'); - const enableSwitchAfterReEnable = await testSubjects.find('enableSwitch'); - const isChecked = await enableSwitchAfterReEnable.getAttribute('aria-checked'); - expect(isChecked).to.eql('true'); + const disableSwitchAfterReEnable = await testSubjects.find('disableSwitch'); + const isChecked = await disableSwitchAfterReEnable.getAttribute('aria-checked'); + expect(isChecked).to.eql('false'); }); it('should mute single alert', async () => { @@ -507,9 +507,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('collapsedItemActions'); - const enableSwitch = await testSubjects.find('enableSwitch'); - const isChecked = await enableSwitch.getAttribute('aria-checked'); - expect(isChecked).to.eql('false'); + const disableSwitch = await testSubjects.find('disableSwitch'); + const isChecked = await disableSwitch.getAttribute('aria-checked'); + expect(isChecked).to.eql('true'); }); it('should enable all selection', async () => { @@ -532,9 +532,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await testSubjects.click('collapsedItemActions'); - const enableSwitch = await testSubjects.find('enableSwitch'); - const isChecked = await enableSwitch.getAttribute('aria-checked'); - expect(isChecked).to.eql('true'); + const disableSwitch = await testSubjects.find('disableSwitch'); + const isChecked = await disableSwitch.getAttribute('aria-checked'); + expect(isChecked).to.eql('false'); }); it('should delete all selection', async () => { diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts index 0e6f991be24d0..562f64656319e 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/connectors.ts @@ -185,7 +185,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expect(searchResultsAfterDelete.length).to.eql(0); }); - it('should not be able to delete a pre-configured connector', async () => { + it('should not be able to delete a preconfigured connector', async () => { const preconfiguredConnectorName = 'xyz'; await pageObjects.triggersActionsUI.searchConnectors(preconfiguredConnectorName); @@ -196,7 +196,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expect(await testSubjects.exists('preConfiguredTitleMessage')).to.be(true); }); - it('should not be able to edit a pre-configured connector', async () => { + it('should not be able to edit a preconfigured connector', async () => { const preconfiguredConnectorName = 'xyz'; await pageObjects.triggersActionsUI.searchConnectors(preconfiguredConnectorName); diff --git a/x-pack/test/licensing_plugin/legacy/updates.ts b/x-pack/test/licensing_plugin/legacy/updates.ts index 5fa1299d1f285..03b61b9db87f8 100644 --- a/x-pack/test/licensing_plugin/legacy/updates.ts +++ b/x-pack/test/licensing_plugin/legacy/updates.ts @@ -50,14 +50,9 @@ export default function(ftrContext: FtrProviderContext) { await scenario.startBasic(); await scenario.waitForPluginToDetectLicenseUpdate(); - const { body: legacyBasicLicense, header: legacyBasicLicenseHeaders } = await supertest - .get('/api/xpack/v1/info') - .expect(200); + const { body: legacyBasicLicense } = await supertest.get('/api/xpack/v1/info').expect(200); expect(legacyBasicLicense.license?.type).to.be('basic'); expect(legacyBasicLicense.features).to.have.property('security'); - expect(legacyBasicLicenseHeaders['kbn-xpack-sig']).to.not.be( - legacyInitialLicenseHeaders['kbn-xpack-sig'] - ); // banner shown only when license expired not just deleted await testSubjects.missingOrFail('licenseExpiredBanner'); diff --git a/x-pack/test/plugin_api_integration/plugins/event_log/server/init_routes.ts b/x-pack/test/plugin_api_integration/plugins/event_log/server/init_routes.ts new file mode 100644 index 0000000000000..c5f3e65581df9 --- /dev/null +++ b/x-pack/test/plugin_api_integration/plugins/event_log/server/init_routes.ts @@ -0,0 +1,228 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { + RequestHandlerContext, + KibanaRequest, + KibanaResponseFactory, + IKibanaResponse, + IRouter, + Logger, + RouteValidationResultFactory, +} from 'kibana/server'; +import { IEventLogService, IEventLogger } from '../../../../../plugins/event_log/server'; +import { IValidatedEvent } from '../../../../../plugins/event_log/server/types'; + +export const logEventRoute = (router: IRouter, eventLogger: IEventLogger, logger: Logger) => { + router.post( + { + path: `/api/log_event_fixture/{id}/_log`, + validate: { + // removed validation as schema is currently broken in tests + // blocked by: https://github.com/elastic/kibana/issues/61652 + params: (value: any, { ok }: RouteValidationResultFactory) => ok(value), + body: (value: any, { ok }: RouteValidationResultFactory) => ok(value), + }, + }, + async function( + context: RequestHandlerContext, + req: KibanaRequest, + res: KibanaResponseFactory + ): Promise> { + const { id } = req.params as { id: string }; + const event: IValidatedEvent = req.body; + logger.info(`test fixture: log event: ${id} ${JSON.stringify(event)}`); + try { + await context.core.savedObjects.client.get('event_log_test', id); + logger.info(`found existing saved object`); + } catch (ex) { + logger.info(`log event error: ${ex}`); + await context.core.savedObjects.client.create('event_log_test', {}, { id }); + logger.info(`created saved object`); + } + eventLogger.logEvent(event); + logger.info(`logged`); + return res.ok({}); + } + ); +}; + +export const registerProviderActionsRoute = ( + router: IRouter, + eventLogService: IEventLogService, + logger: Logger +) => { + router.post( + { + path: '/api/log_event_fixture/{provider}/_registerProviderActions', + validate: { + body: value => ({ value }), + params: (value: any, { ok }: RouteValidationResultFactory) => ok(value), + }, + options: { authRequired: false }, + }, + (context, request, response) => { + const { provider } = request.params as { provider: string }; + const actions = request.body; + try { + logger.info( + `test register provider actions: ${provider}, actions: ${JSON.stringify(actions)}` + ); + + eventLogService.registerProviderActions(provider, actions); + logger.info(`registered`); + } catch (e) { + return response.badRequest({ body: e }); + } + return response.ok({ body: {} }); + } + ); +}; + +export const isProviderActionRegisteredRoute = ( + router: IRouter, + eventLogService: IEventLogService, + logger: Logger +) => { + router.get( + { + path: `/api/log_event_fixture/{provider}/{action}/_isProviderActionRegistered`, + validate: { + params: (value: any, { ok }: RouteValidationResultFactory) => ok(value), + }, + }, + async function( + context: RequestHandlerContext, + req: KibanaRequest, + res: KibanaResponseFactory + ): Promise> { + const { provider, action } = req.params as { provider: string; action: string }; + logger.info(`test provider actions is registered: ${provider} for action: ${action}`); + + return res.ok({ + body: { + isProviderActionRegistered: eventLogService.isProviderActionRegistered(provider, action), + }, + }); + } + ); +}; + +export const getProviderActionsRoute = ( + router: IRouter, + eventLogService: IEventLogService, + logger: Logger +) => { + router.get( + { + path: `/api/log_event_fixture/{provider}/getProviderActions`, + validate: { + params: (value: any, { ok }: RouteValidationResultFactory) => ok(value), + }, + }, + async function( + context: RequestHandlerContext, + req: KibanaRequest, + res: KibanaResponseFactory + ): Promise> { + const { provider } = req.params as { provider: string }; + + logger.info(`test if get all provider actions is registered`); + return res.ok({ + body: { actions: [...(eventLogService.getProviderActions().get(provider) ?? [])] }, + }); + } + ); +}; + +export const getLoggerRoute = ( + router: IRouter, + eventLogService: IEventLogService, + logger: Logger +) => { + router.get( + { + path: `/api/log_event_fixture/getEventLogger/{event}`, + validate: { + params: (value: any, { ok }: RouteValidationResultFactory) => ok(value), + }, + }, + async function( + context: RequestHandlerContext, + req: KibanaRequest, + res: KibanaResponseFactory + ): Promise> { + const { event } = req.params as { event: string }; + logger.info(`test get event logger for event: ${event}`); + + return res.ok({ + body: { eventLogger: eventLogService.getLogger({ event: { provider: event } }) }, + }); + } + ); +}; + +export const isIndexingEntriesRoute = ( + router: IRouter, + eventLogService: IEventLogService, + logger: Logger +) => { + router.get( + { + path: `/api/log_event_fixture/isIndexingEntries`, + validate: {}, + }, + async function( + context: RequestHandlerContext, + req: KibanaRequest, + res: KibanaResponseFactory + ): Promise> { + logger.info(`test if event logger is indexing entries`); + return res.ok({ body: { isIndexingEntries: eventLogService.isIndexingEntries() } }); + } + ); +}; + +export const isEventLogServiceEnabledRoute = ( + router: IRouter, + eventLogService: IEventLogService, + logger: Logger +) => { + router.get( + { + path: `/api/log_event_fixture/isEventLogServiceEnabled`, + validate: {}, + }, + async function( + context: RequestHandlerContext, + req: KibanaRequest, + res: KibanaResponseFactory + ): Promise> { + logger.info(`test if event logger is enabled`); + return res.ok({ body: { isEnabled: eventLogService.isEnabled() } }); + } + ); +}; + +export const isEventLogServiceLoggingEntriesRoute = ( + router: IRouter, + eventLogService: IEventLogService, + logger: Logger +) => { + router.get( + { + path: `/api/log_event_fixture/isEventLogServiceLoggingEntries`, + validate: {}, + }, + async function( + context: RequestHandlerContext, + req: KibanaRequest, + res: KibanaResponseFactory + ): Promise> { + logger.info(`test if event logger is logging entries`); + return res.ok({ body: { isLoggingEntries: eventLogService.isLoggingEntries() } }); + } + ); +}; diff --git a/x-pack/test/plugin_api_integration/plugins/event_log/server/plugin.ts b/x-pack/test/plugin_api_integration/plugins/event_log/server/plugin.ts index eccbd4fb7f90b..2ef932d19e9ee 100644 --- a/x-pack/test/plugin_api_integration/plugins/event_log/server/plugin.ts +++ b/x-pack/test/plugin_api_integration/plugins/event_log/server/plugin.ts @@ -4,24 +4,18 @@ * you may not use this file except in compliance with the Elastic License. */ +import { Plugin, CoreSetup, Logger, PluginInitializerContext } from 'kibana/server'; +import { IEventLogService, IEventLogClientService } from '../../../../../plugins/event_log/server'; import { - Plugin, - CoreSetup, - RequestHandlerContext, - KibanaRequest, - KibanaResponseFactory, - IKibanaResponse, - IRouter, - Logger, - PluginInitializerContext, - RouteValidationResultFactory, -} from 'kibana/server'; -import { - IEventLogService, - IEventLogClientService, - IEventLogger, -} from '../../../../../plugins/event_log/server'; -import { IValidatedEvent } from '../../../../../plugins/event_log/server/types'; + logEventRoute, + registerProviderActionsRoute, + isProviderActionRegisteredRoute, + getProviderActionsRoute, + getLoggerRoute, + isIndexingEntriesRoute, + isEventLogServiceLoggingEntriesRoute, + isEventLogServiceEnabledRoute, +} from './init_routes'; // this plugin's dependendencies export interface EventLogFixtureSetupDeps { @@ -50,49 +44,24 @@ export class EventLogFixturePlugin core.savedObjects.registerType({ name: 'event_log_test', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: {}, }, }); logEventRoute(router, eventLogger, this.logger); + + // event log service api routes + registerProviderActionsRoute(router, eventLog, this.logger); + isProviderActionRegisteredRoute(router, eventLog, this.logger); + getProviderActionsRoute(router, eventLog, this.logger); + getLoggerRoute(router, eventLog, this.logger); + isIndexingEntriesRoute(router, eventLog, this.logger); + isEventLogServiceLoggingEntriesRoute(router, eventLog, this.logger); + isEventLogServiceEnabledRoute(router, eventLog, this.logger); } public start() {} public stop() {} } - -const logEventRoute = (router: IRouter, eventLogger: IEventLogger, logger: Logger) => { - router.post( - { - path: `/api/log_event_fixture/{id}/_log`, - validate: { - // removed validation as schema is currently broken in tests - // blocked by: https://github.com/elastic/kibana/issues/61652 - params: (value: any, { ok }: RouteValidationResultFactory) => ok(value), - body: (value: any, { ok }: RouteValidationResultFactory) => ok(value), - }, - }, - async function( - context: RequestHandlerContext, - req: KibanaRequest, - res: KibanaResponseFactory - ): Promise> { - const { id } = req.params as { id: string }; - const event: IValidatedEvent = req.body; - logger.info(`test fixture: log event: ${id} ${JSON.stringify(event)}`); - try { - await context.core.savedObjects.client.get('event_log_test', id); - logger.info(`found existing saved object`); - } catch (ex) { - logger.info(`log event error: ${ex}`); - await context.core.savedObjects.client.create('event_log_test', {}, { id }); - logger.info(`created saved object`); - } - eventLogger.logEvent(event); - logger.info(`logged`); - return res.ok({}); - } - ); -}; diff --git a/x-pack/test/plugin_api_integration/test_suites/event_log/service_api_integration.ts b/x-pack/test/plugin_api_integration/test_suites/event_log/service_api_integration.ts index b055b22879bf9..2de395308ce74 100644 --- a/x-pack/test/plugin_api_integration/test_suites/event_log/service_api_integration.ts +++ b/x-pack/test/plugin_api_integration/test_suites/event_log/service_api_integration.ts @@ -3,9 +3,181 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +import expect from '@kbn/expect/expect.js'; +import { IEvent } from '../../../../plugins/event_log/server'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function({ getService }: FtrProviderContext) { + const es = getService('legacyEs'); + const supertest = getService('supertest'); + const log = getService('log'); + const config = getService('config'); + const retry = getService('retry'); -export default function() { describe('Event Log service API', () => { - it('should allow logging an event', async () => {}); + it('should check if it is enabled', async () => { + const configValue = config + .get('kbnTestServer.serverArgs') + .find((val: string) => val === '--xpack.eventLog.enabled=true'); + const result = await isEventLogServiceEnabled(); + expect(configValue).to.be.eql(`--xpack.eventLog.enabled=${result.body.isEnabled}`); + }); + + it('should check if logging entries is enabled', async () => { + const configValue = config + .get('kbnTestServer.serverArgs') + .find((val: string) => val === '--xpack.eventLog.logEntries=true'); + const result = await isEventLogServiceLoggingEntries(); + expect(configValue).to.be.eql(`--xpack.eventLog.logEntries=${result.body.isLoggingEntries}`); + }); + + it('should check if indexing entries is enabled', async () => { + const configValue = config + .get('kbnTestServer.serverArgs') + .find((val: string) => val === '--xpack.eventLog.indexEntries=true'); + const result = await isIndexingEntries(); + const exists = await es.indices.exists({ index: '.kibana-event-log-*' }); + expect(exists).to.be.eql(true); + expect(configValue).to.be.eql( + `--xpack.eventLog.indexEntries=${result.body.isIndexingEntries}` + ); + }); + + it('should be able to check if provider actions is registered', async () => { + const initResult = await isProviderActionRegistered('provider3', 'action1'); + + if (!initResult.body.isProviderActionRegistered) { + await registerProviderActions('provider3', ['action1']); + } + const result1 = await isProviderActionRegistered('provider3', 'action1'); + expect(result1.body.isProviderActionRegistered).to.be.eql(true); + + const result = await isProviderActionRegistered('provider3', 'action2'); + expect(result.body.isProviderActionRegistered).to.be.eql(false); + }); + + it('should return error message if provider is registered', async () => { + const initResult = await isProviderActionRegistered('duplication', 'action1'); + + if (!initResult.body.isProviderActionRegistered) { + await registerProviderActions('duplication', ['action1', 'action2']); + } + + const result = await registerProviderActions('duplication', ['action1', 'action2']); + expect(result.badRequest).to.be.eql(true); + }); + + it('should allow to register provider actions and return all provider actions', async () => { + const initResult = await isProviderActionRegistered('provider1', 'action1'); + + if (!initResult.body.isProviderActionRegistered) { + await registerProviderActions('provider1', ['action1', 'action2']); + } + + const providerActions = await getProviderActions('provider1'); + expect(providerActions.body.actions).to.be.eql(['action1', 'action2']); + }); + + it('should allow to get event logger event log service', async () => { + const initResult = await isProviderActionRegistered('provider2', 'action1'); + + if (!initResult.body.isProviderActionRegistered) { + await registerProviderActions('provider2', ['action1', 'action2']); + } + const eventLogger = await getEventLogger('provider2'); + expect(eventLogger.body.eventLogger.initialProperties).to.be.eql({ + event: { provider: 'provider2' }, + }); + }); + + it('should allow write an event to index document if indexing entries is enabled', async () => { + const initResult = await isProviderActionRegistered('provider4', 'action1'); + + if (!initResult.body.isProviderActionRegistered) { + await registerProviderActions('provider4', ['action1', 'action2']); + } + + const eventId = '1'; + const event: IEvent = { + event: { action: 'action1', provider: 'provider4' }, + kibana: { saved_objects: [{ type: 'event_log_test', id: eventId }] }, + }; + await logTestEvent(eventId, event); + + await retry.try(async () => { + const uri = `/api/event_log/event_log_test/${eventId}/_find`; + log.debug(`calling ${uri}`); + const result = await supertest + .get(uri) + .set('kbn-xsrf', 'foo') + .expect(200); + expect(result.body.data.length).to.be.eql(1); + }); + }); }); + + async function registerProviderActions(provider: string, actions: string[]) { + log.debug(`registerProviderActions ${provider}`); + return await supertest + .post(`/api/log_event_fixture/${provider}/_registerProviderActions`) + .set('kbn-xsrf', 'xxx') + .send(actions); + } + + async function isProviderActionRegistered(provider: string, action: string) { + log.debug(`isProviderActionRegistered ${provider} for action ${action}`); + return await supertest + .get(`/api/log_event_fixture/${provider}/${action}/_isProviderActionRegistered`) + .set('kbn-xsrf', 'foo') + .expect(200); + } + + async function getProviderActions(provider: string) { + log.debug(`getProviderActions ${provider}`); + return await supertest + .get(`/api/log_event_fixture/${provider}/getProviderActions`) + .set('kbn-xsrf', 'xxx') + .expect(200); + } + + async function getEventLogger(event: string) { + log.debug(`isProviderActionRegistered for event ${event}`); + return await supertest + .get(`/api/log_event_fixture/getEventLogger/${event}`) + .set('kbn-xsrf', 'foo') + .expect(200); + } + + async function isIndexingEntries() { + log.debug(`isIndexingEntries`); + return await supertest + .get(`/api/log_event_fixture/isIndexingEntries`) + .set('kbn-xsrf', 'foo') + .expect(200); + } + + async function isEventLogServiceEnabled() { + log.debug(`isEventLogServiceEnabled`); + return await supertest + .get(`/api/log_event_fixture/isEventLogServiceEnabled`) + .set('kbn-xsrf', 'foo') + .expect(200); + } + + async function isEventLogServiceLoggingEntries() { + log.debug(`isEventLogServiceLoggingEntries`); + return await supertest + .get(`/api/log_event_fixture/isEventLogServiceLoggingEntries`) + .set('kbn-xsrf', 'foo') + .expect(200); + } + + async function logTestEvent(id: string, event: IEvent) { + log.debug(`Logging Event for Saved Object ${id}`); + return await supertest + .post(`/api/log_event_fixture/${id}/_log`) + .set('kbn-xsrf', 'foo') + .send(event) + .expect(200); + } } diff --git a/x-pack/test/reporting/functional/reporting.js b/x-pack/test/reporting/functional/reporting.js index 6107363986a40..c1a2ae634662c 100644 --- a/x-pack/test/reporting/functional/reporting.js +++ b/x-pack/test/reporting/functional/reporting.js @@ -24,6 +24,7 @@ export default function({ getService, getPageObjects }) { const browser = getService('browser'); const log = getService('log'); const config = getService('config'); + const filterBar = getService('filterBar'); const PageObjects = getPageObjects([ 'reporting', 'common', @@ -161,7 +162,27 @@ export default function({ getService, getPageObjects }) { expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); + it('becomes available/not available when a saved search is created, changed and saved again', async () => { + // create new search, csv export is not available + await PageObjects.discover.clickNewSearchButton(); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + // save search, csv export is available + await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + // add filter, csv export is not available + await filterBar.addFilter('currency', 'is', 'EUR'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + // save search again, csv export is available + await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + }); + it('generates a report with data', async () => { + await PageObjects.discover.clickNewSearchButton(); await PageObjects.reporting.setTimepickerInDataRange(); await PageObjects.discover.saveSearch('my search - with data - expectReportCanBeCreated'); await PageObjects.reporting.openCsvReportingPanel(); diff --git a/x-pack/test/siem_cypress/runner.ts b/x-pack/test/siem_cypress/runner.ts index 2462f75d4d0a4..b84e2953cc142 100644 --- a/x-pack/test/siem_cypress/runner.ts +++ b/x-pack/test/siem_cypress/runner.ts @@ -23,7 +23,7 @@ export async function SiemCypressTestRunner({ getService }: FtrProviderContext) await procs.run('cypress', { cmd: 'yarn', args: ['cypress:run'], - cwd: resolve(__dirname, '../../legacy/plugins/siem'), + cwd: resolve(__dirname, '../../plugins/siem'), env: { FORCE_COLOR: '1', CYPRESS_baseUrl: Url.format(config.get('servers.kibana')), diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index e9aab9b47535f..df1d7e789507b 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "types": [ "mocha", - "node" + "node", + "flot" ] }, "include": [ diff --git a/x-pack/tsconfig.json b/x-pack/tsconfig.json index a6c94ff74620e..a540c7e3c9786 100644 --- a/x-pack/tsconfig.json +++ b/x-pack/tsconfig.json @@ -11,7 +11,7 @@ ], "exclude": [ "test/**/*", - "legacy/plugins/siem/cypress/**/*", + "plugins/siem/cypress/**/*", "legacy/plugins/apm/e2e/cypress/**/*", "**/typespec_tests.ts" ], @@ -40,7 +40,8 @@ }, "types": [ "node", - "jest" + "jest", + "flot" ] } } diff --git a/yarn.lock b/yarn.lock index 9b319ef437037..b47befbf9057b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1220,35 +1220,34 @@ debug "^3.1.0" lodash.once "^4.1.1" -"@elastic/apm-rum-core@^4.7.0": - version "4.7.0" - resolved "https://registry.yarnpkg.com/@elastic/apm-rum-core/-/apm-rum-core-4.7.0.tgz#b00b58bf7380f2e36652e5333e3ca97608986e40" - integrity sha512-/lTZWfA3ces3qoKCx72Sc+w43lZkyktaQlbYoYO86h3tNX7tScc/7YBBHI9oxKMcXweqkKOcpnwNZFy71bb86w== +"@elastic/apm-rum-core@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@elastic/apm-rum-core/-/apm-rum-core-5.2.0.tgz#2ed30dc226c9b5779532ab2e6065a155587bcea4" + integrity sha512-3ti2dhrqfxjHFXgArQI/sVAG2AgZH0kB1nx+2WjLpuAh8gGS4R772M5VXcWcGQb8UW9jrANwwbW2hT2GKv+uOA== dependencies: error-stack-parser "^1.3.5" - es6-promise "^4.2.8" opentracing "^0.14.3" - uuid "^3.1.0" + promise-polyfill "^8.1.3" -"@elastic/apm-rum-react@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@elastic/apm-rum-react/-/apm-rum-react-0.3.2.tgz#134634643e15ebcf97b6f17b2c74a50afdbe1c64" - integrity sha512-hU1srW9noygppyrLmipulu30c+LWEie8V/dQjEqLYMx2mRZRwNIue3midYgWa6qrWqgYZhwpAtWrWcXc+AWk2Q== +"@elastic/apm-rum-react@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@elastic/apm-rum-react/-/apm-rum-react-1.1.1.tgz#3a2ba91efc9260da55ef6c31cce642a476eba828" + integrity sha512-ZMixw+82VbZIDBnz0dj5Fo4PZ7pnXlLjAA7XTi3AtSIEjpsZa7YIuCFzJdrgb/nOq7MOFkODkFPTiIYAM/yCqg== dependencies: - "@elastic/apm-rum" "^4.6.0" + "@elastic/apm-rum" "^5.1.1" hoist-non-react-statics "^3.3.0" -"@elastic/apm-rum@^4.6.0": - version "4.6.0" - resolved "https://registry.yarnpkg.com/@elastic/apm-rum/-/apm-rum-4.6.0.tgz#e2ac560dd4a4761c0e9b08c301418b1d4063bdd2" - integrity sha512-hsqvyTm5rT6lKgV06wvm8ID9aMsuJyw8wIOPjRwKmvzlTjayabxKTcr50lJJV8jY9OWfDkqymIqpHyCEChQAHQ== +"@elastic/apm-rum@^5.1.1": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@elastic/apm-rum/-/apm-rum-5.1.1.tgz#02d29fa606e66f9a3a88f629d468b02457b1b183" + integrity sha512-A0O/0ZffcHm1taLuXyFoUmV2+aARr+9+xbmsEDIExLV0yKaNlaLl3UaZrodSOZ1ijlCEsRRS+y2i0md93YKQTA== dependencies: - "@elastic/apm-rum-core" "^4.7.0" + "@elastic/apm-rum-core" "^5.2.0" -"@elastic/charts@18.2.2": - version "18.2.2" - resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-18.2.2.tgz#f59d6ee597d553d193314d8598561c65da787e8d" - integrity sha512-ss8AqLj9wHa2C+9ULUKbXw8ZCQmEjLuaVU5AkqE2j3hOVtAN75HO2p7nMIsxcSldfmqy+4jSptybJLNAfizegQ== +"@elastic/charts@18.3.0": + version "18.3.0" + resolved "https://registry.yarnpkg.com/@elastic/charts/-/charts-18.3.0.tgz#cbdeec1860af274edc7a5f5b9dd26ec48c64bb64" + integrity sha512-4kSlSwdDRsVKVX8vRUkwxOu1IT6WIepgLnP0OZT7cFjgrC1SV/16c3YLw2NZDaVe0M/H4rpeNWW30VyrzZVhyw== dependencies: classnames "^2.2.6" d3-array "^1.2.4" @@ -4478,10 +4477,10 @@ dependencies: "@types/node" "*" -"@types/papaparse@^4.5.11": - version "4.5.11" - resolved "https://registry.yarnpkg.com/@types/papaparse/-/papaparse-4.5.11.tgz#dcd4f64da55f768c2e2cf92ccac1973c67a73890" - integrity sha512-zOw6K7YyA/NuZ2yZ8lzZFe2U3fn+vFfcRfiQp4ZJHG6y8WYWy2SYFbq6mp4yUgpIruJHBjKZtgyE0vvCoWEq+A== +"@types/papaparse@^5.0.3": + version "5.0.3" + resolved "https://registry.yarnpkg.com/@types/papaparse/-/papaparse-5.0.3.tgz#7cedc1ebc9484819af8306a8b42f9f08ca9bdb44" + integrity sha512-SgWGWnBGxl6XgjKDM2eoDg163ZFQtH6m6C2aOuaAf1T2gUB3rjaiPDDARbY9WlacRgZqieRG9imAfJaJ+5ouDA== dependencies: "@types/node" "*" @@ -12279,11 +12278,6 @@ es6-promise@^4.2.5: resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.6.tgz#b685edd8258886365ea62b57d30de28fadcd974f" integrity sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q== -es6-promise@^4.2.8: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - es6-promisify@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" @@ -22591,10 +22585,10 @@ pako@~1.0.5: resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258" integrity sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg== -papaparse@^4.6.3: - version "4.6.3" - resolved "https://registry.yarnpkg.com/papaparse/-/papaparse-4.6.3.tgz#742e5eaaa97fa6c7e1358d2934d8f18f44aee781" - integrity sha512-LRq7BrHC2kHPBYSD50aKuw/B/dGcg29omyJbKWY3KsYUZU69RKwaBHu13jGmCYBtOc4odsLCrFyk6imfyNubJQ== +papaparse@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/papaparse/-/papaparse-5.2.0.tgz#97976a1b135c46612773029153dc64995caa3b7b" + integrity sha512-ylq1wgUSnagU+MKQtNeVqrPhZuMYBvOSL00DHycFTCxownF95gpLAk1HiHdUW77N8yxRq1qHXLdlIPyBSG9NSA== parallel-transform@^1.1.0: version "1.1.0" @@ -23577,6 +23571,11 @@ promise-inflight@^1.0.1: resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= +promise-polyfill@^8.1.3: + version "8.1.3" + resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-8.1.3.tgz#8c99b3cf53f3a91c68226ffde7bde81d7f904116" + integrity sha512-MG5r82wBzh7pSKDRa9y+vllNHz3e3d4CNj1PQE4BQYxLme0gKYYBm9YENq+UkEikyZ0XbiGWxYlVw3Rl9O/U8g== + promise.prototype.finally@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/promise.prototype.finally/-/promise.prototype.finally-3.1.0.tgz#66f161b1643636e50e7cf201dc1b84a857f3864e" @@ -30861,7 +30860,7 @@ utils-regex-from-string@^1.0.0: regex-regex "^1.0.0" validate.io-string-primitive "^1.0.0" -uuid@3.3.2, uuid@^3.0.1, uuid@^3.1.0, uuid@^3.3.2: +uuid@3.3.2, uuid@^3.0.1, uuid@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== @@ -30876,7 +30875,7 @@ uuid@^3.0.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" integrity sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g== -uuid@^3.3.3: +uuid@^3.1.0, uuid@^3.3.3: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==