From f9a002e3830600d4c17b7a7a8902615475848233 Mon Sep 17 00:00:00 2001 From: Chris Roberson Date: Tue, 2 Oct 2018 09:49:54 -0400 Subject: [PATCH] Backport #22998 --- .../lib/get_space_id_for_beats_tutorial.js | 32 +++++++++++++++++++ .../common/tutorials/filebeat_instructions.js | 11 +++++-- .../tutorials/metricbeat_instructions.js | 11 +++++-- .../tutorials/aerospike_metrics/index.js | 4 +-- .../server/tutorials/apache_logs/index.js | 4 +-- .../server/tutorials/apache_metrics/index.js | 4 +-- .../server/tutorials/ceph_metrics/index.js | 4 +-- .../tutorials/couchbase_metrics/index.js | 4 +-- .../server/tutorials/docker_metrics/index.js | 4 +-- .../tutorials/dropwizard_metrics/index.js | 4 +-- .../tutorials/elasticsearch_metrics/index.js | 4 +-- .../server/tutorials/etcd_metrics/index.js | 4 +-- .../server/tutorials/golang_metrics/index.js | 4 +-- .../server/tutorials/haproxy_metrics/index.js | 4 +-- .../server/tutorials/kafka_logs/index.js | 4 +-- .../server/tutorials/kafka_metrics/index.js | 4 +-- .../server/tutorials/kibana_metrics/index.js | 4 +-- .../tutorials/kubernetes_metrics/index.js | 4 +-- .../tutorials/logstash_metrics/index.js | 4 +-- .../tutorials/memcached_metrics/index.js | 4 +-- .../server/tutorials/mongodb_metrics/index.js | 4 +-- .../server/tutorials/munin_metrics/index.js | 4 +-- .../server/tutorials/mysql_logs/index.js | 4 +-- .../server/tutorials/mysql_metrics/index.js | 4 +-- .../server/tutorials/nginx_logs/index.js | 4 +-- .../server/tutorials/nginx_metrics/index.js | 4 +-- .../server/tutorials/osquery_logs/index.js | 4 +-- .../server/tutorials/php_fpm_metrics/index.js | 4 +-- .../tutorials/postgresql_metrics/index.js | 4 +-- .../tutorials/prometheus_metrics/index.js | 4 +-- .../tutorials/rabbitmq_metrics/index.js | 4 +-- .../server/tutorials/redis_logs/index.js | 4 +-- .../server/tutorials/redis_metrics/index.js | 4 +-- .../server/tutorials/system_logs/index.js | 4 +-- .../server/tutorials/system_metrics/index.js | 4 +-- .../server/tutorials/uwsgi_metrics/index.js | 4 +-- .../server/tutorials/vsphere_metrics/index.js | 4 +-- .../server/tutorials/windows_metrics/index.js | 4 +-- .../tutorials/zookeeper_metrics/index.js | 4 +-- .../server/lib/create_spaces_service.test.ts | 20 ++++++++++++ .../server/lib/create_spaces_service.ts | 12 +++++++ .../spaces_tutorial_context_factory.test.ts | 2 ++ .../lib/spaces_tutorial_context_factory.ts | 1 + 43 files changed, 155 insertions(+), 78 deletions(-) create mode 100644 src/core_plugins/kibana/common/lib/get_space_id_for_beats_tutorial.js diff --git a/src/core_plugins/kibana/common/lib/get_space_id_for_beats_tutorial.js b/src/core_plugins/kibana/common/lib/get_space_id_for_beats_tutorial.js new file mode 100644 index 0000000000000..f7da589526003 --- /dev/null +++ b/src/core_plugins/kibana/common/lib/get_space_id_for_beats_tutorial.js @@ -0,0 +1,32 @@ +/* + * 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. + */ + +/** + * Returns valid configuration for a beat.yml file for adding the space id + * if there is an active space and that space is not the default one. + * + * @param {object} context - Context object generated from tutorial factory (see #22760) + */ +export function getSpaceIdForBeatsTutorial(context) { + if (!context || !context.spaceId || context.isInDefaultSpace) { + return ''; + } + + return ` space.id: "${context.spaceId}"`; +} diff --git a/src/core_plugins/kibana/common/tutorials/filebeat_instructions.js b/src/core_plugins/kibana/common/tutorials/filebeat_instructions.js index b96f1f6b1b7d0..05c3c25626f25 100644 --- a/src/core_plugins/kibana/common/tutorials/filebeat_instructions.js +++ b/src/core_plugins/kibana/common/tutorials/filebeat_instructions.js @@ -20,8 +20,9 @@ import { i18n } from '@kbn/i18n'; import { INSTRUCTION_VARIANT } from './instruction_variant'; import { createTrycloudOption1, createTrycloudOption2 } from './onprem_cloud_instructions'; +import { getSpaceIdForBeatsTutorial } from '../lib/get_space_id_for_beats_tutorial'; -export const createFilebeatInstructions = () => ({ +export const createFilebeatInstructions = context => ({ INSTALL: { OSX: { title: i18n.translate('kbn.common.tutorials.filebeatInstructions.install.osxTitle', { @@ -181,6 +182,7 @@ export const createFilebeatInstructions = () => ({ ' password: ""', 'setup.kibana:', ' host: ""', + getSpaceIdForBeatsTutorial(context) ], textPost: i18n.translate('kbn.common.tutorials.filebeatInstructions.config.osxTextPost', { defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \ @@ -209,6 +211,7 @@ and {kibanaUrlTemplate} is the URL of Kibana.', ' password: ""', 'setup.kibana:', ' host: ""', + getSpaceIdForBeatsTutorial(context) ], textPost: i18n.translate('kbn.common.tutorials.filebeatInstructions.config.debTextPost', { defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \ @@ -237,6 +240,7 @@ and {kibanaUrlTemplate} is the URL of Kibana.', ' password: ""', 'setup.kibana:', ' host: ""', + getSpaceIdForBeatsTutorial(context) ], textPost: i18n.translate('kbn.common.tutorials.filebeatInstructions.config.rpmTextPost', { defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \ @@ -265,6 +269,7 @@ and {kibanaUrlTemplate} is the URL of Kibana.', ' password: ""', 'setup.kibana:', ' host: ""', + getSpaceIdForBeatsTutorial(context) ], textPost: i18n.translate('kbn.common.tutorials.filebeatInstructions.config.windowsTextPost', { defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \ @@ -484,8 +489,8 @@ export function filebeatStatusCheck(moduleName) { }; } -export function onPremInstructions(moduleName, platforms, geoipRequired, uaRequired) { - const FILEBEAT_INSTRUCTIONS = createFilebeatInstructions(); +export function onPremInstructions(moduleName, platforms, geoipRequired, uaRequired, context) { + const FILEBEAT_INSTRUCTIONS = createFilebeatInstructions(context); const variants = []; for (let i = 0; i < platforms.length; i++) { diff --git a/src/core_plugins/kibana/common/tutorials/metricbeat_instructions.js b/src/core_plugins/kibana/common/tutorials/metricbeat_instructions.js index b15d3aaab1e7e..db3890f343e89 100644 --- a/src/core_plugins/kibana/common/tutorials/metricbeat_instructions.js +++ b/src/core_plugins/kibana/common/tutorials/metricbeat_instructions.js @@ -20,8 +20,9 @@ import { i18n } from '@kbn/i18n'; import { INSTRUCTION_VARIANT } from './instruction_variant'; import { createTrycloudOption1, createTrycloudOption2 } from './onprem_cloud_instructions'; +import { getSpaceIdForBeatsTutorial } from '../lib/get_space_id_for_beats_tutorial'; -export const createMetricbeatInstructions = () => ({ +export const createMetricbeatInstructions = context => ({ INSTALL: { OSX: { title: i18n.translate('kbn.common.tutorials.metricbeatInstructions.install.osxTitle', { @@ -168,6 +169,7 @@ export const createMetricbeatInstructions = () => ({ ' password: ""', 'setup.kibana:', ' host: ""', + getSpaceIdForBeatsTutorial(context) ], textPost: i18n.translate('kbn.common.tutorials.metricbeatInstructions.config.osxTextPost', { defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \ @@ -196,6 +198,7 @@ and {kibanaUrlTemplate} is the URL of Kibana.', ' password: ""', 'setup.kibana:', ' host: ""', + getSpaceIdForBeatsTutorial(context) ], textPost: i18n.translate('kbn.common.tutorials.metricbeatInstructions.config.debTextPost', { defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \ @@ -224,6 +227,7 @@ and {kibanaUrlTemplate} is the URL of Kibana.', ' password: ""', 'setup.kibana:', ' host: ""', + getSpaceIdForBeatsTutorial(context) ], textPost: i18n.translate('kbn.common.tutorials.metricbeatInstructions.config.rpmTextPost', { defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \ @@ -252,6 +256,7 @@ and {kibanaUrlTemplate} is the URL of Kibana.', ' password: ""', 'setup.kibana:', ' host: ""', + getSpaceIdForBeatsTutorial(context) ], textPost: i18n.translate('kbn.common.tutorials.metricbeatInstructions.config.windowsTextPost', { defaultMessage: 'Where {passwordTemplate} is the password of the `elastic` user, {esUrlTemplate} is the URL of Elasticsearch, \ @@ -444,8 +449,8 @@ export function metricbeatStatusCheck(moduleName) { }; } -export function onPremInstructions(moduleName) { - const METRICBEAT_INSTRUCTIONS = createMetricbeatInstructions(); +export function onPremInstructions(moduleName, platforms, geoipRequired, uaRequired, context) { + const METRICBEAT_INSTRUCTIONS = createMetricbeatInstructions(context); return { instructionSets: [ diff --git a/src/core_plugins/kibana/server/tutorials/aerospike_metrics/index.js b/src/core_plugins/kibana/server/tutorials/aerospike_metrics/index.js index f9b656a888e1c..e5eef704ab77d 100644 --- a/src/core_plugins/kibana/server/tutorials/aerospike_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/aerospike_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function aerospikeMetricsSpecProvider() { +export function aerospikeMetricsSpecProvider(server, context) { const moduleName = 'aerospike'; return { id: 'aerospikeMetrics', @@ -53,7 +53,7 @@ export function aerospikeMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/apache_logs/index.js b/src/core_plugins/kibana/server/tutorials/apache_logs/index.js index f9c90abc54bf1..cce2343500d02 100644 --- a/src/core_plugins/kibana/server/tutorials/apache_logs/index.js +++ b/src/core_plugins/kibana/server/tutorials/apache_logs/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions'; -export function apacheLogsSpecProvider() { +export function apacheLogsSpecProvider(server, context) { const moduleName = 'apache2'; const geoipRequired = true; const uaRequired = true; @@ -59,7 +59,7 @@ export function apacheLogsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/apache_logs/screenshot.png', - onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired), + onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired, context), elasticCloud: cloudInstructions(moduleName, platforms), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms) }; diff --git a/src/core_plugins/kibana/server/tutorials/apache_metrics/index.js b/src/core_plugins/kibana/server/tutorials/apache_metrics/index.js index 9ea9c894d8977..d7d04589843bf 100644 --- a/src/core_plugins/kibana/server/tutorials/apache_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/apache_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function apacheMetricsSpecProvider() { +export function apacheMetricsSpecProvider(server, context) { const moduleName = 'apache'; return { id: 'apacheMetrics', @@ -56,7 +56,7 @@ export function apacheMetricsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/apache_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/ceph_metrics/index.js b/src/core_plugins/kibana/server/tutorials/ceph_metrics/index.js index aebcc62fc3211..6cf411aeb8619 100644 --- a/src/core_plugins/kibana/server/tutorials/ceph_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/ceph_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function cephMetricsSpecProvider() { +export function cephMetricsSpecProvider(server, context) { const moduleName = 'ceph'; return { id: 'cephMetrics', @@ -53,7 +53,7 @@ export function cephMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/couchbase_metrics/index.js b/src/core_plugins/kibana/server/tutorials/couchbase_metrics/index.js index c9cc9610e0860..729e40b97ab55 100644 --- a/src/core_plugins/kibana/server/tutorials/couchbase_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/couchbase_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function couchbaseMetricsSpecProvider() { +export function couchbaseMetricsSpecProvider(server, context) { const moduleName = 'couchbase'; return { id: 'couchbaseMetrics', @@ -53,7 +53,7 @@ export function couchbaseMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/docker_metrics/index.js b/src/core_plugins/kibana/server/tutorials/docker_metrics/index.js index 6429390a48e55..289f8d2324155 100644 --- a/src/core_plugins/kibana/server/tutorials/docker_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/docker_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function dockerMetricsSpecProvider() { +export function dockerMetricsSpecProvider(server, context) { const moduleName = 'docker'; return { id: 'dockerMetrics', @@ -56,7 +56,7 @@ export function dockerMetricsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/docker_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/dropwizard_metrics/index.js b/src/core_plugins/kibana/server/tutorials/dropwizard_metrics/index.js index 2222d9468808d..bb8a15894a3de 100644 --- a/src/core_plugins/kibana/server/tutorials/dropwizard_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/dropwizard_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function dropwizardMetricsSpecProvider() { +export function dropwizardMetricsSpecProvider(server, context) { const moduleName = 'dropwizard'; return { id: 'dropwizardMetrics', @@ -53,7 +53,7 @@ export function dropwizardMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/elasticsearch_metrics/index.js b/src/core_plugins/kibana/server/tutorials/elasticsearch_metrics/index.js index abbbe3f1429c9..8982eedce7069 100644 --- a/src/core_plugins/kibana/server/tutorials/elasticsearch_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/elasticsearch_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function elasticsearchMetricsSpecProvider() { +export function elasticsearchMetricsSpecProvider(server, context) { const moduleName = 'elasticsearch'; return { id: 'elasticsearchMetrics', @@ -54,7 +54,7 @@ export function elasticsearchMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/etcd_metrics/index.js b/src/core_plugins/kibana/server/tutorials/etcd_metrics/index.js index 2b704f57ab208..a357c31d94215 100644 --- a/src/core_plugins/kibana/server/tutorials/etcd_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/etcd_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function etcdMetricsSpecProvider() { +export function etcdMetricsSpecProvider(server, context) { const moduleName = 'etcd'; return { id: 'etcdMetrics', @@ -53,7 +53,7 @@ export function etcdMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/golang_metrics/index.js b/src/core_plugins/kibana/server/tutorials/golang_metrics/index.js index 2714de14f494d..f56d146dbedec 100644 --- a/src/core_plugins/kibana/server/tutorials/golang_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/golang_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function golangMetricsSpecProvider() { +export function golangMetricsSpecProvider(server, context) { const moduleName = 'golang'; return { id: moduleName + 'Metrics', @@ -56,7 +56,7 @@ export function golangMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/haproxy_metrics/index.js b/src/core_plugins/kibana/server/tutorials/haproxy_metrics/index.js index f2d119b75e916..bb1a4319617b4 100644 --- a/src/core_plugins/kibana/server/tutorials/haproxy_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/haproxy_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function haproxyMetricsSpecProvider() { +export function haproxyMetricsSpecProvider(server, context) { const moduleName = 'haproxy'; return { id: 'haproxyMetrics', @@ -53,7 +53,7 @@ export function haproxyMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/kafka_logs/index.js b/src/core_plugins/kibana/server/tutorials/kafka_logs/index.js index 4ac90a5e85e4a..269265ce933eb 100644 --- a/src/core_plugins/kibana/server/tutorials/kafka_logs/index.js +++ b/src/core_plugins/kibana/server/tutorials/kafka_logs/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions'; -export function kafkaLogsSpecProvider() { +export function kafkaLogsSpecProvider(server, context) { const moduleName = 'kafka'; const geoipRequired = false; const uaRequired = false; @@ -59,7 +59,7 @@ export function kafkaLogsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/kafka_logs/screenshot.png', - onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired), + onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired, context), elasticCloud: cloudInstructions(moduleName, platforms), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms) }; diff --git a/src/core_plugins/kibana/server/tutorials/kafka_metrics/index.js b/src/core_plugins/kibana/server/tutorials/kafka_metrics/index.js index c5f0403a93773..6e3288695e0c6 100644 --- a/src/core_plugins/kibana/server/tutorials/kafka_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/kafka_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function kafkaMetricsSpecProvider() { +export function kafkaMetricsSpecProvider(server, context) { const moduleName = 'kafka'; return { id: 'kafkaMetrics', @@ -53,7 +53,7 @@ export function kafkaMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/kibana_metrics/index.js b/src/core_plugins/kibana/server/tutorials/kibana_metrics/index.js index 5e2a734372f1c..83953af8589ed 100644 --- a/src/core_plugins/kibana/server/tutorials/kibana_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/kibana_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function kibanaMetricsSpecProvider() { +export function kibanaMetricsSpecProvider(server, context) { const moduleName = 'kibana'; return { id: 'kibanaMetrics', @@ -54,7 +54,7 @@ export function kibanaMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/kubernetes_metrics/index.js b/src/core_plugins/kibana/server/tutorials/kubernetes_metrics/index.js index c4b483be10ec7..255f5821f0e66 100644 --- a/src/core_plugins/kibana/server/tutorials/kubernetes_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/kubernetes_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function kubernetesMetricsSpecProvider() { +export function kubernetesMetricsSpecProvider(server, context) { const moduleName = 'kubernetes'; return { id: 'kubernetesMetrics', @@ -56,7 +56,7 @@ export function kubernetesMetricsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/kubernetes_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/logstash_metrics/index.js b/src/core_plugins/kibana/server/tutorials/logstash_metrics/index.js index 8689cad2fc966..b18bbede0c70b 100644 --- a/src/core_plugins/kibana/server/tutorials/logstash_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/logstash_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function logstashMetricsSpecProvider() { +export function logstashMetricsSpecProvider(server, context) { const moduleName = 'logstash'; return { id: moduleName + 'Metrics', @@ -55,7 +55,7 @@ export function logstashMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/memcached_metrics/index.js b/src/core_plugins/kibana/server/tutorials/memcached_metrics/index.js index 28021ffebdbf7..f9b09ce12ed3b 100644 --- a/src/core_plugins/kibana/server/tutorials/memcached_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/memcached_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function memcachedMetricsSpecProvider() { +export function memcachedMetricsSpecProvider(server, context) { const moduleName = 'memcached'; return { id: 'memcachedMetrics', @@ -53,7 +53,7 @@ export function memcachedMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/mongodb_metrics/index.js b/src/core_plugins/kibana/server/tutorials/mongodb_metrics/index.js index e3db5dd55a4f2..b02fbac0d9590 100644 --- a/src/core_plugins/kibana/server/tutorials/mongodb_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/mongodb_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function mongodbMetricsSpecProvider() { +export function mongodbMetricsSpecProvider(server, context) { const moduleName = 'mongodb'; return { id: 'mongodbMetrics', @@ -56,7 +56,7 @@ export function mongodbMetricsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/mongodb_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/munin_metrics/index.js b/src/core_plugins/kibana/server/tutorials/munin_metrics/index.js index ab21dc2b03bd4..e6e6489dc6fca 100644 --- a/src/core_plugins/kibana/server/tutorials/munin_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/munin_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function muninMetricsSpecProvider() { +export function muninMetricsSpecProvider(server, context) { const moduleName = 'munin'; return { id: 'muninMetrics', @@ -53,7 +53,7 @@ export function muninMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/mysql_logs/index.js b/src/core_plugins/kibana/server/tutorials/mysql_logs/index.js index bddc0d9659f49..9b06e4a1fafc4 100644 --- a/src/core_plugins/kibana/server/tutorials/mysql_logs/index.js +++ b/src/core_plugins/kibana/server/tutorials/mysql_logs/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions'; -export function mysqlLogsSpecProvider() { +export function mysqlLogsSpecProvider(server, context) { const moduleName = 'mysql'; const geoipRequired = false; const uaRequired = false; @@ -59,7 +59,7 @@ export function mysqlLogsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/mysql_logs/screenshot.png', - onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired), + onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired, context), elasticCloud: cloudInstructions(moduleName, platforms), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms) }; diff --git a/src/core_plugins/kibana/server/tutorials/mysql_metrics/index.js b/src/core_plugins/kibana/server/tutorials/mysql_metrics/index.js index 37bd452a7fad8..24614ab353e83 100644 --- a/src/core_plugins/kibana/server/tutorials/mysql_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/mysql_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function mysqlMetricsSpecProvider() { +export function mysqlMetricsSpecProvider(server, context) { const moduleName = 'mysql'; return { id: 'mysqlMetrics', @@ -56,7 +56,7 @@ export function mysqlMetricsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/mysql_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/nginx_logs/index.js b/src/core_plugins/kibana/server/tutorials/nginx_logs/index.js index d540a3f9f2daa..03e7454b60b8c 100644 --- a/src/core_plugins/kibana/server/tutorials/nginx_logs/index.js +++ b/src/core_plugins/kibana/server/tutorials/nginx_logs/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions'; -export function nginxLogsSpecProvider() { +export function nginxLogsSpecProvider(server, context) { const moduleName = 'nginx'; const geoipRequired = true; const uaRequired = true; @@ -59,7 +59,7 @@ export function nginxLogsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/nginx_logs/screenshot.png', - onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired), + onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired, context), elasticCloud: cloudInstructions(moduleName, platforms), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms) }; diff --git a/src/core_plugins/kibana/server/tutorials/nginx_metrics/index.js b/src/core_plugins/kibana/server/tutorials/nginx_metrics/index.js index 38c54bf8ae2d6..1eb34a5413cc3 100644 --- a/src/core_plugins/kibana/server/tutorials/nginx_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/nginx_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function nginxMetricsSpecProvider() { +export function nginxMetricsSpecProvider(server, context) { const moduleName = 'nginx'; return { id: 'nginxMetrics', @@ -60,7 +60,7 @@ which must be enabled in your Nginx installation. \ }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/nginx_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/osquery_logs/index.js b/src/core_plugins/kibana/server/tutorials/osquery_logs/index.js index fab1fb78285ac..f394291e62f75 100644 --- a/src/core_plugins/kibana/server/tutorials/osquery_logs/index.js +++ b/src/core_plugins/kibana/server/tutorials/osquery_logs/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions'; -export function osqueryLogsSpecProvider() { +export function osqueryLogsSpecProvider(server, context) { const moduleName = 'osquery'; const geoipRequired = false; const uaRequired = false; @@ -59,7 +59,7 @@ export function osqueryLogsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/osquery_logs/screenshot.png', - onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired), + onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired, context), elasticCloud: cloudInstructions(moduleName, platforms), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms) }; diff --git a/src/core_plugins/kibana/server/tutorials/php_fpm_metrics/index.js b/src/core_plugins/kibana/server/tutorials/php_fpm_metrics/index.js index f024bcb62f852..45a8e919d65a9 100644 --- a/src/core_plugins/kibana/server/tutorials/php_fpm_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/php_fpm_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function phpfpmMetricsSpecProvider() { +export function phpfpmMetricsSpecProvider(server, context) { const moduleName = 'php_fpm'; return { id: 'phpfpmMetrics', @@ -55,7 +55,7 @@ export function phpfpmMetricsSpecProvider() { }, completionTimeMinutes: 10, //previewImagePath: '/plugins/kibana/home/tutorial_resources/php_fpm_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/postgresql_metrics/index.js b/src/core_plugins/kibana/server/tutorials/postgresql_metrics/index.js index c646700c3d011..fb40d4d638801 100644 --- a/src/core_plugins/kibana/server/tutorials/postgresql_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/postgresql_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function postgresqlMetricsSpecProvider() { +export function postgresqlMetricsSpecProvider(server, context) { const moduleName = 'postgresql'; return { id: 'postgresqlMetrics', @@ -57,7 +57,7 @@ export function postgresqlMetricsSpecProvider() { }, completionTimeMinutes: 10, //previewImagePath: '/plugins/kibana/home/tutorial_resources/postgresql_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/prometheus_metrics/index.js b/src/core_plugins/kibana/server/tutorials/prometheus_metrics/index.js index 5bfad2d708706..987374e1389a5 100644 --- a/src/core_plugins/kibana/server/tutorials/prometheus_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/prometheus_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function prometheusMetricsSpecProvider() { +export function prometheusMetricsSpecProvider(server, context) { const moduleName = 'prometheus'; return { id: moduleName + 'Metrics', @@ -54,7 +54,7 @@ export function prometheusMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/rabbitmq_metrics/index.js b/src/core_plugins/kibana/server/tutorials/rabbitmq_metrics/index.js index 0b343d3dd4abc..642f002807510 100644 --- a/src/core_plugins/kibana/server/tutorials/rabbitmq_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/rabbitmq_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function rabbitmqMetricsSpecProvider() { +export function rabbitmqMetricsSpecProvider(server, context) { const moduleName = 'rabbitmq'; return { id: 'rabbitmqMetrics', @@ -57,7 +57,7 @@ export function rabbitmqMetricsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/rabbitmq_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/redis_logs/index.js b/src/core_plugins/kibana/server/tutorials/redis_logs/index.js index 397181820d060..c142f62a8ea5c 100644 --- a/src/core_plugins/kibana/server/tutorials/redis_logs/index.js +++ b/src/core_plugins/kibana/server/tutorials/redis_logs/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions'; -export function redisLogsSpecProvider() { +export function redisLogsSpecProvider(server, context) { const moduleName = 'redis'; const geoipRequired = false; const uaRequired = false; @@ -65,7 +65,7 @@ Note that the `slowlog` fileset is experimental. \ }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/redis_logs/screenshot.png', - onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired), + onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired, context), elasticCloud: cloudInstructions(moduleName, platforms), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms) }; diff --git a/src/core_plugins/kibana/server/tutorials/redis_metrics/index.js b/src/core_plugins/kibana/server/tutorials/redis_metrics/index.js index e1d451a17fb32..928ced07ade26 100644 --- a/src/core_plugins/kibana/server/tutorials/redis_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/redis_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function redisMetricsSpecProvider() { +export function redisMetricsSpecProvider(server, context) { const moduleName = 'redis'; return { id: 'redisMetrics', @@ -56,7 +56,7 @@ export function redisMetricsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/redis_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/system_logs/index.js b/src/core_plugins/kibana/server/tutorials/system_logs/index.js index 74117526ac77c..54f295ecb44f8 100644 --- a/src/core_plugins/kibana/server/tutorials/system_logs/index.js +++ b/src/core_plugins/kibana/server/tutorials/system_logs/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/filebeat_instructions'; -export function systemLogsSpecProvider() { +export function systemLogsSpecProvider(server, context) { const moduleName = 'system'; const geoipRequired = true; const uaRequired = false; @@ -59,7 +59,7 @@ Unix/Linux based distributions. This module is not available on Windows. \ }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/system_logs/screenshot.png', - onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired), + onPrem: onPremInstructions(moduleName, platforms, geoipRequired, uaRequired, context), elasticCloud: cloudInstructions(moduleName, platforms), onPremElasticCloud: onPremCloudInstructions(moduleName, platforms) }; diff --git a/src/core_plugins/kibana/server/tutorials/system_metrics/index.js b/src/core_plugins/kibana/server/tutorials/system_metrics/index.js index 61669025d2f1f..a5fc1d7fd6333 100644 --- a/src/core_plugins/kibana/server/tutorials/system_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/system_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function systemMetricsSpecProvider() { +export function systemMetricsSpecProvider(server, context) { const moduleName = 'system'; return { id: 'systemMetrics', @@ -56,7 +56,7 @@ It collects system wide statistics and statistics per process and filesystem. \ }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/system_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/uwsgi_metrics/index.js b/src/core_plugins/kibana/server/tutorials/uwsgi_metrics/index.js index 3769c3fa6f014..a55d7c237d987 100644 --- a/src/core_plugins/kibana/server/tutorials/uwsgi_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/uwsgi_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function uwsgiMetricsSpecProvider() { +export function uwsgiMetricsSpecProvider(server, context) { const moduleName = 'uwsgi'; return { id: 'uwsgiMetrics', @@ -57,7 +57,7 @@ export function uwsgiMetricsSpecProvider() { }, completionTimeMinutes: 10, previewImagePath: '/plugins/kibana/home/tutorial_resources/uwsgi_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/vsphere_metrics/index.js b/src/core_plugins/kibana/server/tutorials/vsphere_metrics/index.js index 7ef4e68768b22..035e4ef5983ff 100644 --- a/src/core_plugins/kibana/server/tutorials/vsphere_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/vsphere_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function vSphereMetricsSpecProvider() { +export function vSphereMetricsSpecProvider(server, context) { const moduleName = 'vsphere'; return { id: 'vsphereMetrics', @@ -54,7 +54,7 @@ export function vSphereMetricsSpecProvider() { }, completionTimeMinutes: 10, //previewImagePath: '/plugins/kibana/home/tutorial_resources/vsphere_metrics/screenshot.png', - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/windows_metrics/index.js b/src/core_plugins/kibana/server/tutorials/windows_metrics/index.js index 16543ef745b92..380cca3264f22 100644 --- a/src/core_plugins/kibana/server/tutorials/windows_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/windows_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function windowsMetricsSpecProvider() { +export function windowsMetricsSpecProvider(server, context) { const moduleName = 'windows'; return { id: 'windowsMetrics', @@ -53,7 +53,7 @@ export function windowsMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/src/core_plugins/kibana/server/tutorials/zookeeper_metrics/index.js b/src/core_plugins/kibana/server/tutorials/zookeeper_metrics/index.js index 1a5b78df196bf..93b57b18d0409 100644 --- a/src/core_plugins/kibana/server/tutorials/zookeeper_metrics/index.js +++ b/src/core_plugins/kibana/server/tutorials/zookeeper_metrics/index.js @@ -21,7 +21,7 @@ import { i18n } from '@kbn/i18n'; import { TUTORIAL_CATEGORY } from '../../../common/tutorials/tutorial_category'; import { onPremInstructions, cloudInstructions, onPremCloudInstructions } from '../../../common/tutorials/metricbeat_instructions'; -export function zookeeperMetricsSpecProvider() { +export function zookeeperMetricsSpecProvider(server, context) { const moduleName = 'zookeeper'; return { id: moduleName + 'Metrics', @@ -54,7 +54,7 @@ export function zookeeperMetricsSpecProvider() { } }, completionTimeMinutes: 10, - onPrem: onPremInstructions(moduleName), + onPrem: onPremInstructions(moduleName, null, null, null, context), elasticCloud: cloudInstructions(moduleName), onPremElasticCloud: onPremCloudInstructions(moduleName) }; diff --git a/x-pack/plugins/spaces/server/lib/create_spaces_service.test.ts b/x-pack/plugins/spaces/server/lib/create_spaces_service.test.ts index 3eec453554702..23e4a3dd8c214 100644 --- a/x-pack/plugins/spaces/server/lib/create_spaces_service.test.ts +++ b/x-pack/plugins/spaces/server/lib/create_spaces_service.test.ts @@ -52,3 +52,23 @@ test(`returns the id for the current space when a server basepath is defined`, ( const service = createSpacesService(server); expect(service.getSpaceId(request)).toEqual('my-space-context'); }); + +test(`returns true if the current space is the default one`, () => { + const request = createRequest(DEFAULT_SPACE_ID, '/foo'); + const server = createMockServer({ + 'server.basePath': '/foo', + }); + + const service = createSpacesService(server); + expect(service.isInDefaultSpace(request)).toEqual(true); +}); + +test(`returns false if the current space is not the default one`, () => { + const request = createRequest('my-space-context', '/foo'); + const server = createMockServer({ + 'server.basePath': '/foo', + }); + + const service = createSpacesService(server); + expect(service.isInDefaultSpace(request)).toEqual(false); +}); diff --git a/x-pack/plugins/spaces/server/lib/create_spaces_service.ts b/x-pack/plugins/spaces/server/lib/create_spaces_service.ts index 3269142a9cf17..2e45d57639fd8 100644 --- a/x-pack/plugins/spaces/server/lib/create_spaces_service.ts +++ b/x-pack/plugins/spaces/server/lib/create_spaces_service.ts @@ -4,9 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ +import { DEFAULT_SPACE_ID } from '../../common/constants'; import { getSpaceIdFromPath } from './spaces_url_parser'; export interface SpacesService { + isInDefaultSpace: (req: any) => boolean; getSpaceId: (req: any) => string; } @@ -24,15 +26,25 @@ export function createSpacesService(server: any): SpacesService { return spaceId; } + function isInDefaultSpace(request: any) { + if (!contextCache.has(request)) { + populateCache(request); + } + + return contextCache.get(request).isInDefaultSpace; + } + function populateCache(request: any) { const spaceId = getSpaceIdFromPath(request.getBasePath(), serverBasePath); contextCache.set(request, { spaceId, + isInDefaultSpace: spaceId === DEFAULT_SPACE_ID, }); } return { getSpaceId, + isInDefaultSpace, }; } diff --git a/x-pack/plugins/spaces/server/lib/spaces_tutorial_context_factory.test.ts b/x-pack/plugins/spaces/server/lib/spaces_tutorial_context_factory.test.ts index 4ed548d64b574..fc97fc8d3cb48 100644 --- a/x-pack/plugins/spaces/server/lib/spaces_tutorial_context_factory.test.ts +++ b/x-pack/plugins/spaces/server/lib/spaces_tutorial_context_factory.test.ts @@ -37,6 +37,7 @@ describe('createSpacesTutorialContextFactory', () => { expect(contextFactory(request)).toEqual({ spaceId: 'my-space-id', + isInDefaultSpace: false, }); }); @@ -50,6 +51,7 @@ describe('createSpacesTutorialContextFactory', () => { expect(contextFactory(request)).toEqual({ spaceId: DEFAULT_SPACE_ID, + isInDefaultSpace: true, }); }); }); diff --git a/x-pack/plugins/spaces/server/lib/spaces_tutorial_context_factory.ts b/x-pack/plugins/spaces/server/lib/spaces_tutorial_context_factory.ts index b3254fd3b3c07..0681c5437b919 100644 --- a/x-pack/plugins/spaces/server/lib/spaces_tutorial_context_factory.ts +++ b/x-pack/plugins/spaces/server/lib/spaces_tutorial_context_factory.ts @@ -10,6 +10,7 @@ export function createSpacesTutorialContextFactory(spacesService: SpacesService) return function spacesTutorialContextFactory(request: any) { return { spaceId: spacesService.getSpaceId(request), + isInDefaultSpace: spacesService.isInDefaultSpace(request), }; }; }