From bc6161d904356ddb8bc45d3019409dd17681663e Mon Sep 17 00:00:00 2001 From: "Christiane (Tina) Heiligers" Date: Mon, 18 Nov 2019 11:47:27 -0700 Subject: [PATCH] [NP Kibana Migrations ] kibana plugin home (#50444) * [NP:Kibana:homeAPI] initializes a new plugin (WIP) * Typing * New plugin tutorials not needing server working * Retains legacy tutorial registration and adds new route for new platform tutorial plugin registrations * Adds comment on where to pre-register general non-plugin specific tutorials * Converts TutorialsPlugin to TutorialsRegistry service in new Home plugin * Changes call to location of registerTutorial in registerTutorials * Adds console log for the home plugin that's returning an empty object * Removes async from setup and start methods in the home plugin and the tutorials service * Starts writing tests and creating mocks * Adds basic tests for TutorialRegistry service * Adds basic tests for TutorialRegistry service * Adds test for route * Adds mocks and tests for the home plugin * Adds home plugin to security plugin and registers scoped tutorials service * Removes incorrect addition to src core server * Fixes type errors * Deletes unused code * Deletes duplicate golangMetricsSpecProvider registration * Nests tutorials service in a tutorials key in the home plugin, changes api http routes for legacy platform and NP * Changes url variable names --- .../kibana/public/home/load_tutorials.js | 23 ++- .../routes/api/home/register_tutorials.js | 2 +- .../tutorials/aerospike_metrics/index.js | 2 +- .../server/tutorials/apache_logs/index.js | 2 +- .../server/tutorials/apache_metrics/index.js | 2 +- .../server/tutorials/auditbeat/index.js | 2 +- .../server/tutorials/aws_metrics/index.js | 2 +- .../server/tutorials/ceph_metrics/index.js | 2 +- .../server/tutorials/cisco_logs/index.js | 2 +- .../server/tutorials/cloudwatch_logs/index.js | 2 +- .../server/tutorials/consul_metrics/index.js | 2 +- .../server/tutorials/coredns_metrics/index.js | 2 +- .../tutorials/couchbase_metrics/index.js | 2 +- .../server/tutorials/couchdb_metrics/index.js | 2 +- .../server/tutorials/docker_metrics/index.js | 2 +- .../tutorials/dropwizard_metrics/index.js | 2 +- .../tutorials/elasticsearch_logs/index.js | 2 +- .../tutorials/elasticsearch_metrics/index.js | 2 +- .../server/tutorials/envoyproxy_logs/index.js | 2 +- .../server/tutorials/etcd_metrics/index.js | 2 +- .../server/tutorials/golang_metrics/index.js | 2 +- .../server/tutorials/haproxy_metrics/index.js | 2 +- .../kibana/server/tutorials/iis_logs/index.js | 2 +- .../server/tutorials/iptables_logs/index.js | 2 +- .../server/tutorials/kafka_logs/index.js | 2 +- .../server/tutorials/kafka_metrics/index.js | 2 +- .../server/tutorials/kibana_metrics/index.js | 2 +- .../tutorials/kubernetes_metrics/index.js | 2 +- .../server/tutorials/logstash_logs/index.js | 2 +- .../tutorials/logstash_metrics/index.js | 2 +- .../tutorials/memcached_metrics/index.js | 2 +- .../server/tutorials/mongodb_metrics/index.js | 2 +- .../server/tutorials/mssql_metrics/index.js | 2 +- .../server/tutorials/munin_metrics/index.js | 2 +- .../server/tutorials/mysql_logs/index.js | 2 +- .../server/tutorials/mysql_metrics/index.js | 2 +- .../server/tutorials/nats_logs/index.js | 2 +- .../server/tutorials/nats_metrics/index.js | 2 +- .../server/tutorials/nginx_logs/index.js | 2 +- .../server/tutorials/nginx_metrics/index.js | 2 +- .../server/tutorials/osquery_logs/index.js | 2 +- .../server/tutorials/php_fpm_metrics/index.js | 2 +- .../server/tutorials/postgresql_logs/index.js | 2 +- .../tutorials/postgresql_metrics/index.js | 2 +- .../tutorials/prometheus_metrics/index.js | 2 +- .../tutorials/rabbitmq_metrics/index.js | 2 +- .../server/tutorials/redis_logs/index.js | 2 +- .../server/tutorials/redis_metrics/index.js | 2 +- .../kibana/server/tutorials/register.js | 119 +++++++------- .../server/tutorials/suricata_logs/index.js | 2 +- .../server/tutorials/system_logs/index.js | 2 +- .../server/tutorials/system_metrics/index.js | 2 +- .../server/tutorials/traefik_logs/index.js | 2 +- .../server/tutorials/uptime_monitors/index.js | 2 +- .../server/tutorials/uwsgi_metrics/index.js | 2 +- .../server/tutorials/vsphere_metrics/index.js | 2 +- .../tutorials/windows_event_logs/index.js | 2 +- .../server/tutorials/windows_metrics/index.js | 2 +- .../server/tutorials/zeek_logs/index.js | 2 +- .../tutorials/zookeeper_metrics/index.js | 2 +- src/legacy/ui/tutorials_mixin.js | 2 + src/plugins/home/kibana.json | 6 + src/plugins/home/server/index.ts | 24 +++ .../home/server/lib/tutorial_schema.ts | 149 ++++++++++++++++++ .../server/lib/tutorials_registry_types.ts | 110 +++++++++++++ src/plugins/home/server/plugin.test.mocks.ts | 24 +++ src/plugins/home/server/plugin.test.ts | 51 ++++++ src/plugins/home/server/plugin.ts | 46 ++++++ src/plugins/home/server/services/index.ts | 27 ++++ .../services/tutorials_registry.mock.ts | 53 +++++++ .../services/tutorials_registry.test.ts | 139 ++++++++++++++++ .../server/services/tutorials_registry.ts | 88 +++++++++++ x-pack/plugins/spaces/kibana.json | 2 +- x-pack/plugins/spaces/server/plugin.ts | 9 +- 74 files changed, 865 insertions(+), 123 deletions(-) create mode 100644 src/plugins/home/kibana.json create mode 100644 src/plugins/home/server/index.ts create mode 100644 src/plugins/home/server/lib/tutorial_schema.ts create mode 100644 src/plugins/home/server/lib/tutorials_registry_types.ts create mode 100644 src/plugins/home/server/plugin.test.mocks.ts create mode 100644 src/plugins/home/server/plugin.test.ts create mode 100644 src/plugins/home/server/plugin.ts create mode 100644 src/plugins/home/server/services/index.ts create mode 100644 src/plugins/home/server/services/tutorials_registry.mock.ts create mode 100644 src/plugins/home/server/services/tutorials_registry.test.ts create mode 100644 src/plugins/home/server/services/tutorials_registry.ts diff --git a/src/legacy/core_plugins/kibana/public/home/load_tutorials.js b/src/legacy/core_plugins/kibana/public/home/load_tutorials.js index a6f19bc166dc7..f597bd732c221 100644 --- a/src/legacy/core_plugins/kibana/public/home/load_tutorials.js +++ b/src/legacy/core_plugins/kibana/public/home/load_tutorials.js @@ -21,6 +21,7 @@ import _ from 'lodash'; import { getServices } from './kibana_services'; import { i18n } from '@kbn/i18n'; +const baseUrlLP = getServices().addBasePath('/api/kibana/home/tutorials_LP'); const baseUrl = getServices().addBasePath('/api/kibana/home/tutorials'); const headers = new Headers(); headers.append('Accept', 'application/json'); @@ -28,22 +29,36 @@ headers.append('Content-Type', 'application/json'); headers.append('kbn-xsrf', 'kibana'); let tutorials = []; +let tutorialsLegacyPlatform = []; +let tutorialsNewPlatform = []; let tutorialsLoaded = false; async function loadTutorials() { try { - const response = await fetch(baseUrl, { + const responseLegacyPlatform = await fetch(baseUrlLP, { method: 'get', credentials: 'include', headers: headers, }); - if (response.status >= 300) { + if (responseLegacyPlatform.status >= 300) { throw new Error(i18n.translate('kbn.home.loadTutorials.requestFailedErrorMessage', { - defaultMessage: 'Request failed with status code: {status}', values: { status: response.status } } + defaultMessage: 'Request failed with status code: {status}', values: { status: responseLegacyPlatform.status } } + )); + } + const responseNewPlatform = await fetch(baseUrl, { + method: 'get', + credentials: 'include', + headers: headers, + }); + if (responseNewPlatform.status >= 300) { + throw new Error(i18n.translate('kbn.home.loadTutorials.requestFailedErrorMessage', { + defaultMessage: 'Request failed with status code: {status}', values: { status: responseNewPlatform.status } } )); } - tutorials = await response.json(); + tutorialsLegacyPlatform = await responseLegacyPlatform.json(); + tutorialsNewPlatform = await responseNewPlatform.json(); + tutorials = tutorialsLegacyPlatform.concat(tutorialsNewPlatform); tutorialsLoaded = true; } catch(err) { getServices().toastNotifications.addDanger({ diff --git a/src/legacy/core_plugins/kibana/server/routes/api/home/register_tutorials.js b/src/legacy/core_plugins/kibana/server/routes/api/home/register_tutorials.js index 861ed1c244d13..fdf2e080c890c 100644 --- a/src/legacy/core_plugins/kibana/server/routes/api/home/register_tutorials.js +++ b/src/legacy/core_plugins/kibana/server/routes/api/home/register_tutorials.js @@ -20,7 +20,7 @@ export function registerTutorials(server) { server.route({ - path: '/api/kibana/home/tutorials', + path: '/api/kibana/home/tutorials_LP', method: ['GET'], handler: function (req) { return server.getTutorials(req); diff --git a/src/legacy/core_plugins/kibana/server/tutorials/aerospike_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/aerospike_metrics/index.js index 77f6df09b244b..28b1dbe6226dc 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/aerospike_metrics/index.js +++ b/src/legacy/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(server, context) { +export function aerospikeMetricsSpecProvider(context) { const moduleName = 'aerospike'; return { id: 'aerospikeMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/apache_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/apache_logs/index.js index c73f4389aa2fe..221fc8f5263c1 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/apache_logs/index.js +++ b/src/legacy/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(server, context) { +export function apacheLogsSpecProvider(context) { const moduleName = 'apache'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/apache_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/apache_metrics/index.js index c53c85f6a08e5..436af8b352590 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/apache_metrics/index.js +++ b/src/legacy/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(server, context) { +export function apacheMetricsSpecProvider(context) { const moduleName = 'apache'; return { id: 'apacheMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/auditbeat/index.js b/src/legacy/core_plugins/kibana/server/tutorials/auditbeat/index.js index 19994aefdb930..b67a872dcc0aa 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/auditbeat/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/auditbeat/index.js @@ -25,7 +25,7 @@ import { onPremCloudInstructions, } from '../../../common/tutorials/auditbeat_instructions'; -export function auditbeatSpecProvider(server, context) { +export function auditbeatSpecProvider(context) { const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { id: 'auditbeat', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/aws_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/aws_metrics/index.js index 56b6689f359f3..32ff79930a877 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/aws_metrics/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/aws_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 awsMetricsSpecProvider(server, context) { +export function awsMetricsSpecProvider(context) { const moduleName = 'aws'; return { id: 'awsMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/ceph_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/ceph_metrics/index.js index f2b2749a79268..1f0001dbaaf94 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/ceph_metrics/index.js +++ b/src/legacy/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(server, context) { +export function cephMetricsSpecProvider(context) { const moduleName = 'ceph'; return { id: 'cephMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/cisco_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/cisco_logs/index.js index 83123afde3882..90190bd0d6877 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/cisco_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/cisco_logs/index.js @@ -25,7 +25,7 @@ import { onPremCloudInstructions, } from '../../../common/tutorials/filebeat_instructions'; -export function ciscoLogsSpecProvider(server, context) { +export function ciscoLogsSpecProvider(context) { const moduleName = 'cisco'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/cloudwatch_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/cloudwatch_logs/index.js index b5b053e329d1a..7617f313b2436 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/cloudwatch_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/cloudwatch_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/functionbeat_instructions'; -export function cloudwatchLogsSpecProvider(server, context) { +export function cloudwatchLogsSpecProvider(context) { return { id: 'cloudwatchLogs', name: i18n.translate('kbn.server.tutorials.cloudwatchLogs.nameTitle', { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/consul_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/consul_metrics/index.js index 8823fe5ee5067..7d2668c60fe18 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/consul_metrics/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/consul_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 consulMetricsSpecProvider(server, context) { +export function consulMetricsSpecProvider(context) { const moduleName = 'consul'; return { id: 'consulMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/coredns_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/coredns_metrics/index.js index 9536cab0886d5..a62613e9c2f13 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/coredns_metrics/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/coredns_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 corednsMetricsSpecProvider(server, context) { +export function corednsMetricsSpecProvider(context) { const moduleName = 'coredns'; return { id: 'corednsMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/couchbase_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/couchbase_metrics/index.js index 9dc8a7337f434..8a6452703cca7 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/couchbase_metrics/index.js +++ b/src/legacy/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(server, context) { +export function couchbaseMetricsSpecProvider(context) { const moduleName = 'couchbase'; return { id: 'couchbaseMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/couchdb_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/couchdb_metrics/index.js index 437ed7132d617..24f29c1a263ab 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/couchdb_metrics/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/couchdb_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 couchdbMetricsSpecProvider(server, context) { +export function couchdbMetricsSpecProvider(context) { const moduleName = 'couchdb'; return { id: 'couchdbMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/docker_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/docker_metrics/index.js index bc1cda7d52385..8268851d67697 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/docker_metrics/index.js +++ b/src/legacy/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(server, context) { +export function dockerMetricsSpecProvider(context) { const moduleName = 'docker'; return { id: 'dockerMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/dropwizard_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/dropwizard_metrics/index.js index c76743f84c0ac..9576518d7b095 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/dropwizard_metrics/index.js +++ b/src/legacy/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(server, context) { +export function dropwizardMetricsSpecProvider(context) { const moduleName = 'dropwizard'; return { id: 'dropwizardMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/elasticsearch_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/elasticsearch_logs/index.js index 9f88895917e5d..5778af07d8836 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/elasticsearch_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/elasticsearch_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 elasticsearchLogsSpecProvider(server, context) { +export function elasticsearchLogsSpecProvider(context) { const moduleName = 'elasticsearch'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/elasticsearch_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/elasticsearch_metrics/index.js index e31343a4ec48e..35ac8b74c9a1f 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/elasticsearch_metrics/index.js +++ b/src/legacy/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(server, context) { +export function elasticsearchMetricsSpecProvider(context) { const moduleName = 'elasticsearch'; return { id: 'elasticsearchMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/envoyproxy_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/envoyproxy_logs/index.js index 8e8d27b5ba43d..977decd413f08 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/envoyproxy_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/envoyproxy_logs/index.js @@ -25,7 +25,7 @@ import { onPremCloudInstructions, } from '../../../common/tutorials/filebeat_instructions'; -export function envoyproxyLogsSpecProvider(server, context) { +export function envoyproxyLogsSpecProvider(context) { const moduleName = 'envoyproxy'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/etcd_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/etcd_metrics/index.js index 18463e8e91104..27c9259ad080b 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/etcd_metrics/index.js +++ b/src/legacy/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(server, context) { +export function etcdMetricsSpecProvider(context) { const moduleName = 'etcd'; return { id: 'etcdMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/golang_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/golang_metrics/index.js index 594c0bf72edd8..e6823b6a51c64 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/golang_metrics/index.js +++ b/src/legacy/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(server, context) { +export function golangMetricsSpecProvider(context) { const moduleName = 'golang'; return { id: moduleName + 'Metrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/haproxy_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/haproxy_metrics/index.js index 4eea8c1a3be59..ccb7e01e0481e 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/haproxy_metrics/index.js +++ b/src/legacy/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(server, context) { +export function haproxyMetricsSpecProvider(context) { const moduleName = 'haproxy'; return { id: 'haproxyMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/iis_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/iis_logs/index.js index 8a937dddfa509..14f96c1e851c6 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/iis_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/iis_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 iisLogsSpecProvider(server, context) { +export function iisLogsSpecProvider(context) { const moduleName = 'iis'; const platforms = ['WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/iptables_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/iptables_logs/index.js index b5522a825fc11..63246e44d2d0d 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/iptables_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/iptables_logs/index.js @@ -25,7 +25,7 @@ import { onPremCloudInstructions, } from '../../../common/tutorials/filebeat_instructions'; -export function iptablesLogsSpecProvider(server, context) { +export function iptablesLogsSpecProvider(context) { const moduleName = 'iptables'; const platforms = ['DEB', 'RPM']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/kafka_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/kafka_logs/index.js index 4b9ba85157a49..ab1d9af6286cd 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/kafka_logs/index.js +++ b/src/legacy/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(server, context) { +export function kafkaLogsSpecProvider(context) { const moduleName = 'kafka'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/kafka_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/kafka_metrics/index.js index 5dfc786fc2ecd..68651e6833804 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/kafka_metrics/index.js +++ b/src/legacy/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(server, context) { +export function kafkaMetricsSpecProvider(context) { const moduleName = 'kafka'; return { id: 'kafkaMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/kibana_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/kibana_metrics/index.js index bce5eb2169f1c..c85f1399c25f5 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/kibana_metrics/index.js +++ b/src/legacy/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(server, context) { +export function kibanaMetricsSpecProvider(context) { const moduleName = 'kibana'; return { id: 'kibanaMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/kubernetes_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/kubernetes_metrics/index.js index c89c5764b9108..2ff1460563928 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/kubernetes_metrics/index.js +++ b/src/legacy/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(server, context) { +export function kubernetesMetricsSpecProvider(context) { const moduleName = 'kubernetes'; return { id: 'kubernetesMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/logstash_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/logstash_logs/index.js index 463043a66b70f..47ae15dff4d3e 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/logstash_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/logstash_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 logstashLogsSpecProvider(server, context) { +export function logstashLogsSpecProvider(context) { const moduleName = 'logstash'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/logstash_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/logstash_metrics/index.js index 06b24cc0ee706..838316655db6c 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/logstash_metrics/index.js +++ b/src/legacy/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(server, context) { +export function logstashMetricsSpecProvider(context) { const moduleName = 'logstash'; return { id: moduleName + 'Metrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/memcached_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/memcached_metrics/index.js index f1fbd9998c62b..ce31b4fba351f 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/memcached_metrics/index.js +++ b/src/legacy/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(server, context) { +export function memcachedMetricsSpecProvider(context) { const moduleName = 'memcached'; return { id: 'memcachedMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/mongodb_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/mongodb_metrics/index.js index fa54055c813a7..e9bf02585c766 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/mongodb_metrics/index.js +++ b/src/legacy/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(server, context) { +export function mongodbMetricsSpecProvider(context) { const moduleName = 'mongodb'; return { id: 'mongodbMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/mssql_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/mssql_metrics/index.js index 58c5acca6f1b1..201f1de69daa6 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/mssql_metrics/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/mssql_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 mssqlMetricsSpecProvider(server, context) { +export function mssqlMetricsSpecProvider(context) { const moduleName = 'mssql'; return { id: 'mssqlMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/munin_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/munin_metrics/index.js index e6e6489dc6fca..8bf1c2a171524 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/munin_metrics/index.js +++ b/src/legacy/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(server, context) { +export function muninMetricsSpecProvider(context) { const moduleName = 'munin'; return { id: 'muninMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/mysql_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/mysql_logs/index.js index e3425d4531b42..56607b421864d 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/mysql_logs/index.js +++ b/src/legacy/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(server, context) { +export function mysqlLogsSpecProvider(context) { const moduleName = 'mysql'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/mysql_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/mysql_metrics/index.js index c7c60406106ea..c7cc4688efa02 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/mysql_metrics/index.js +++ b/src/legacy/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(server, context) { +export function mysqlMetricsSpecProvider(context) { const moduleName = 'mysql'; return { id: 'mysqlMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/nats_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/nats_logs/index.js index 7608a93a48782..6a2fc609a9934 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/nats_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/nats_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 natsLogsSpecProvider(server, context) { +export function natsLogsSpecProvider(context) { const moduleName = 'nats'; const geoipRequired = false; const uaRequired = false; diff --git a/src/legacy/core_plugins/kibana/server/tutorials/nats_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/nats_metrics/index.js index 86f2497e303ff..9e795c51209c2 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/nats_metrics/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/nats_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 natsMetricsSpecProvider(server, context) { +export function natsMetricsSpecProvider(context) { const moduleName = 'nats'; return { id: 'natsMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/nginx_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/nginx_logs/index.js index b08fa2729c1af..18bd3f649313f 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/nginx_logs/index.js +++ b/src/legacy/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(server, context) { +export function nginxLogsSpecProvider(context) { const moduleName = 'nginx'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/nginx_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/nginx_metrics/index.js index 99bee7c3a5510..f0ebe92295119 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/nginx_metrics/index.js +++ b/src/legacy/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(server, context) { +export function nginxMetricsSpecProvider(context) { const moduleName = 'nginx'; return { id: 'nginxMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/osquery_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/osquery_logs/index.js index c435e95db2acb..eddb81a9762e3 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/osquery_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/osquery_logs/index.js @@ -25,7 +25,7 @@ import { onPremCloudInstructions, } from '../../../common/tutorials/filebeat_instructions'; -export function osqueryLogsSpecProvider(server, context) { +export function osqueryLogsSpecProvider(context) { const moduleName = 'osquery'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/php_fpm_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/php_fpm_metrics/index.js index 077574d70615d..1e55be37e4c52 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/php_fpm_metrics/index.js +++ b/src/legacy/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(server, context) { +export function phpfpmMetricsSpecProvider(context) { const moduleName = 'php_fpm'; return { id: 'phpfpmMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/postgresql_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/postgresql_logs/index.js index 2f7ea4558476c..a79394fa75fe7 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/postgresql_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/postgresql_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 postgresqlLogsSpecProvider(server, context) { +export function postgresqlLogsSpecProvider(context) { const moduleName = 'postgresql'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/postgresql_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/postgresql_metrics/index.js index 6690979d55cc7..74bf88da864b6 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/postgresql_metrics/index.js +++ b/src/legacy/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(server, context) { +export function postgresqlMetricsSpecProvider(context) { const moduleName = 'postgresql'; return { id: 'postgresqlMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/prometheus_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/prometheus_metrics/index.js index ccede68549f31..8e21833afb5a5 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/prometheus_metrics/index.js +++ b/src/legacy/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(server, context) { +export function prometheusMetricsSpecProvider(context) { const moduleName = 'prometheus'; return { id: moduleName + 'Metrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/rabbitmq_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/rabbitmq_metrics/index.js index f40fe41124382..9a8a040ce8b86 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/rabbitmq_metrics/index.js +++ b/src/legacy/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(server, context) { +export function rabbitmqMetricsSpecProvider(context) { const moduleName = 'rabbitmq'; return { id: 'rabbitmqMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/redis_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/redis_logs/index.js index d37e6d66bdd3a..dc31203ff928c 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/redis_logs/index.js +++ b/src/legacy/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(server, context) { +export function redisLogsSpecProvider(context) { const moduleName = 'redis'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/redis_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/redis_metrics/index.js index e92dd15bfc962..a6177b0c551a0 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/redis_metrics/index.js +++ b/src/legacy/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(server, context) { +export function redisMetricsSpecProvider(context) { const moduleName = 'redis'; return { id: 'redisMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/register.js b/src/legacy/core_plugins/kibana/server/tutorials/register.js index f5e178acadef3..54b700e8af628 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/register.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/register.js @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - import { systemLogsSpecProvider } from './system_logs'; import { systemMetricsSpecProvider } from './system_metrics'; import { apacheLogsSpecProvider } from './apache_logs'; @@ -79,64 +78,66 @@ import { emsBoundariesSpecProvider } from './ems'; import { consulMetricsSpecProvider } from './consul_metrics'; export function registerTutorials(server) { - server.registerTutorial(systemLogsSpecProvider); - server.registerTutorial(systemMetricsSpecProvider); - server.registerTutorial(apacheLogsSpecProvider); - server.registerTutorial(apacheMetricsSpecProvider); - server.registerTutorial(elasticsearchLogsSpecProvider); - server.registerTutorial(iisLogsSpecProvider); - server.registerTutorial(kafkaLogsSpecProvider); - server.registerTutorial(logstashLogsSpecProvider); - server.registerTutorial(nginxLogsSpecProvider); - server.registerTutorial(nginxMetricsSpecProvider); - server.registerTutorial(mysqlLogsSpecProvider); - server.registerTutorial(mysqlMetricsSpecProvider); - server.registerTutorial(mongodbMetricsSpecProvider); - server.registerTutorial(osqueryLogsSpecProvider); - server.registerTutorial(phpfpmMetricsSpecProvider); - server.registerTutorial(postgresqlMetricsSpecProvider); - server.registerTutorial(postgresqlLogsSpecProvider); - server.registerTutorial(rabbitmqMetricsSpecProvider); - server.registerTutorial(redisLogsSpecProvider); - server.registerTutorial(redisMetricsSpecProvider); - server.registerTutorial(suricataLogsSpecProvider); - server.registerTutorial(dockerMetricsSpecProvider); - server.registerTutorial(kubernetesMetricsSpecProvider); - server.registerTutorial(uwsgiMetricsSpecProvider); - server.registerTutorial(netflowSpecProvider); - server.registerTutorial(traefikLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(systemLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(systemMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(apacheLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(apacheMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(elasticsearchLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(iisLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(kafkaLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(logstashLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(nginxLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(nginxMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(mysqlLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(mysqlMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(mongodbMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(osqueryLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(phpfpmMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(postgresqlMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(postgresqlLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(rabbitmqMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(redisLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(redisMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(suricataLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(dockerMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(kubernetesMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(uwsgiMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(netflowSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(traefikLogsSpecProvider); server.registerTutorial(apmSpecProvider); - server.registerTutorial(cephMetricsSpecProvider); - server.registerTutorial(aerospikeMetricsSpecProvider); - server.registerTutorial(couchbaseMetricsSpecProvider); - server.registerTutorial(dropwizardMetricsSpecProvider); - server.registerTutorial(elasticsearchMetricsSpecProvider); - server.registerTutorial(etcdMetricsSpecProvider); - server.registerTutorial(haproxyMetricsSpecProvider); - server.registerTutorial(kafkaMetricsSpecProvider); - server.registerTutorial(kibanaMetricsSpecProvider); - server.registerTutorial(memcachedMetricsSpecProvider); - server.registerTutorial(muninMetricsSpecProvider); - server.registerTutorial(vSphereMetricsSpecProvider); - server.registerTutorial(windowsMetricsSpecProvider); - server.registerTutorial(windowsEventLogsSpecProvider); - server.registerTutorial(golangMetricsSpecProvider); - server.registerTutorial(logstashMetricsSpecProvider); - server.registerTutorial(prometheusMetricsSpecProvider); - server.registerTutorial(zookeeperMetricsSpecProvider); - server.registerTutorial(uptimeMonitorsSpecProvider); - server.registerTutorial(cloudwatchLogsSpecProvider); - server.registerTutorial(awsMetricsSpecProvider); - server.registerTutorial(mssqlMetricsSpecProvider); - server.registerTutorial(zeekLogsSpecProvider); - server.registerTutorial(natsLogsSpecProvider); - server.registerTutorial(corednsMetricsSpecProvider); - server.registerTutorial(corednsLogsSpecProvider); - server.registerTutorial(auditbeatSpecProvider); - server.registerTutorial(iptablesLogsSpecProvider); - server.registerTutorial(ciscoLogsSpecProvider); - server.registerTutorial(envoyproxyLogsSpecProvider); - server.registerTutorial(couchdbMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(cephMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(aerospikeMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(couchbaseMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(dropwizardMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(elasticsearchMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(etcdMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(haproxyMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(kafkaMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(kibanaMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(memcachedMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(muninMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(vSphereMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(windowsMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(windowsEventLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(golangMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(logstashMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(prometheusMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(zookeeperMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(uptimeMonitorsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(cloudwatchLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(awsMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(mssqlMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(natsMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(natsLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(zeekLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(corednsMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(corednsLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(auditbeatSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(iptablesLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(ciscoLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(envoyproxyLogsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(couchdbMetricsSpecProvider); server.registerTutorial(emsBoundariesSpecProvider); - server.registerTutorial(consulMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(consulMetricsSpecProvider); + server.newPlatform.setup.plugins.home.tutorials.registerTutorial(cockroachdbMetricsSpecProvider); } diff --git a/src/legacy/core_plugins/kibana/server/tutorials/suricata_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/suricata_logs/index.js index e4e9d5b7e0fd8..3f2ecfa78d3b2 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/suricata_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/suricata_logs/index.js @@ -25,7 +25,7 @@ import { onPremCloudInstructions, } from '../../../common/tutorials/filebeat_instructions'; -export function suricataLogsSpecProvider(server, context) { +export function suricataLogsSpecProvider(context) { const moduleName = 'suricata'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/system_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/system_logs/index.js index a9b8018762c85..efba0c00cbbc3 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/system_logs/index.js +++ b/src/legacy/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(server, context) { +export function systemLogsSpecProvider(context) { const moduleName = 'system'; const platforms = ['OSX', 'DEB', 'RPM']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/system_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/system_metrics/index.js index 563c065a41a8f..4c6fd20aa56c4 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/system_metrics/index.js +++ b/src/legacy/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(server, context) { +export function systemMetricsSpecProvider(context) { const moduleName = 'system'; return { id: 'systemMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/traefik_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/traefik_logs/index.js index 2b05b2669737e..b9b2d4d7e3e5b 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/traefik_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/traefik_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 traefikLogsSpecProvider(server, context) { +export function traefikLogsSpecProvider(context) { const moduleName = 'traefik'; const platforms = ['OSX', 'DEB', 'RPM', 'WINDOWS']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/uptime_monitors/index.js b/src/legacy/core_plugins/kibana/server/tutorials/uptime_monitors/index.js index 8ba0ba1ecc910..7cc90c740eb69 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/uptime_monitors/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/uptime_monitors/index.js @@ -25,7 +25,7 @@ import { onPremCloudInstructions, } from '../../../common/tutorials/heartbeat_instructions'; -export function uptimeMonitorsSpecProvider(server, context) { +export function uptimeMonitorsSpecProvider(context) { return { id: 'uptimeMonitors', name: i18n.translate('kbn.server.tutorials.uptimeMonitors.nameTitle', { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/uwsgi_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/uwsgi_metrics/index.js index a0dd93524f43f..7c5f8e88b50dc 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/uwsgi_metrics/index.js +++ b/src/legacy/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(server, context) { +export function uwsgiMetricsSpecProvider(context) { const moduleName = 'uwsgi'; return { id: 'uwsgiMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/vsphere_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/vsphere_metrics/index.js index 0ba6430c5cfd6..7de8fd8fc445b 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/vsphere_metrics/index.js +++ b/src/legacy/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(server, context) { +export function vSphereMetricsSpecProvider(context) { const moduleName = 'vsphere'; return { id: 'vsphereMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/windows_event_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/windows_event_logs/index.js index cd2ee09c09f74..272535ad3e4e1 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/windows_event_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/windows_event_logs/index.js @@ -25,7 +25,7 @@ import { onPremCloudInstructions, } from '../../../common/tutorials/winlogbeat_instructions'; -export function windowsEventLogsSpecProvider(server, context) { +export function windowsEventLogsSpecProvider(context) { return { id: 'windowsEventLogs', name: i18n.translate('kbn.server.tutorials.windowsEventLogs.nameTitle', { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/windows_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/windows_metrics/index.js index 8f9e04103cc0a..eb2f2aeec7e5e 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/windows_metrics/index.js +++ b/src/legacy/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(server, context) { +export function windowsMetricsSpecProvider(context) { const moduleName = 'windows'; return { id: 'windowsMetrics', diff --git a/src/legacy/core_plugins/kibana/server/tutorials/zeek_logs/index.js b/src/legacy/core_plugins/kibana/server/tutorials/zeek_logs/index.js index 839a9c81f948e..07d46c9c6ae84 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/zeek_logs/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/zeek_logs/index.js @@ -25,7 +25,7 @@ import { onPremCloudInstructions, } from '../../../common/tutorials/filebeat_instructions'; -export function zeekLogsSpecProvider(server, context) { +export function zeekLogsSpecProvider(context) { const moduleName = 'zeek'; const platforms = ['OSX', 'DEB', 'RPM']; return { diff --git a/src/legacy/core_plugins/kibana/server/tutorials/zookeeper_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/zookeeper_metrics/index.js index 22527073b1680..9be44a257a8b4 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/zookeeper_metrics/index.js +++ b/src/legacy/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(server, context) { +export function zookeeperMetricsSpecProvider(context) { const moduleName = 'zookeeper'; return { id: moduleName + 'Metrics', diff --git a/src/legacy/ui/tutorials_mixin.js b/src/legacy/ui/tutorials_mixin.js index af3663a83b812..5238e82e8f14f 100644 --- a/src/legacy/ui/tutorials_mixin.js +++ b/src/legacy/ui/tutorials_mixin.js @@ -36,6 +36,7 @@ export function tutorialsMixin(kbnServer, server) { }); server.decorate('server', 'registerTutorial', (specProvider) => { + // registration during setup const emptyContext = {}; const { error } = Joi.validate(specProvider(server, emptyContext), tutorialSchema); @@ -47,6 +48,7 @@ export function tutorialsMixin(kbnServer, server) { }); server.decorate('server', 'addScopedTutorialContextFactory', (scopedTutorialContextFactory) => { + // returned by the setup method of the new plugin, they will do the same thing as now if (typeof scopedTutorialContextFactory !== 'function') { throw new Error(`Unable to add scoped(request) context factory because you did not provide a function`); } diff --git a/src/plugins/home/kibana.json b/src/plugins/home/kibana.json new file mode 100644 index 0000000000000..8d2d79560f854 --- /dev/null +++ b/src/plugins/home/kibana.json @@ -0,0 +1,6 @@ +{ + "id": "home", + "version": "kibana", + "server": true, + "ui": false +} diff --git a/src/plugins/home/server/index.ts b/src/plugins/home/server/index.ts new file mode 100644 index 0000000000000..178a77dc85ca9 --- /dev/null +++ b/src/plugins/home/server/index.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. + */ + +export { HomePluginSetup, HomePluginStart } from './plugin'; +export { TutorialProvider } from './services'; +import { HomePlugin } from './plugin'; + +export const plugin = () => new HomePlugin(); diff --git a/src/plugins/home/server/lib/tutorial_schema.ts b/src/plugins/home/server/lib/tutorial_schema.ts new file mode 100644 index 0000000000000..eb001ac96cceb --- /dev/null +++ b/src/plugins/home/server/lib/tutorial_schema.ts @@ -0,0 +1,149 @@ +/* + * 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 Joi from 'joi'; + +const PARAM_TYPES = { + NUMBER: 'number', + STRING: 'string', +}; + +const TUTORIAL_CATEGORY = { + LOGGING: 'logging', + SIEM: 'siem', + METRICS: 'metrics', + OTHER: 'other', +}; + +const dashboardSchema = Joi.object({ + id: Joi.string().required(), // Dashboard saved object id + linkLabel: Joi.string().when('isOverview', { + is: true, + then: Joi.required(), + }), + // Is this an Overview / Entry Point dashboard? + isOverview: Joi.boolean().required(), +}); + +const artifactsSchema = Joi.object({ + // Fields present in Elasticsearch documents created by this product. + exportedFields: Joi.object({ + documentationUrl: Joi.string().required(), + }), + // Kibana dashboards created by this product. + dashboards: Joi.array() + .items(dashboardSchema) + .required(), + application: Joi.object({ + path: Joi.string().required(), + label: Joi.string().required(), + }), +}); + +const statusCheckSchema = Joi.object({ + title: Joi.string(), + text: Joi.string(), + btnLabel: Joi.string(), + success: Joi.string(), + error: Joi.string(), + esHitsCheck: Joi.object({ + index: Joi.alternatives() + .try(Joi.string(), Joi.array().items(Joi.string())) + .required(), + query: Joi.object().required(), + }).required(), +}); + +const instructionSchema = Joi.object({ + title: Joi.string(), + textPre: Joi.string(), + commands: Joi.array().items(Joi.string().allow('')), + textPost: Joi.string(), +}); + +const instructionVariantSchema = Joi.object({ + id: Joi.string().required(), + instructions: Joi.array() + .items(instructionSchema) + .required(), +}); + +const instructionSetSchema = Joi.object({ + title: Joi.string(), + callOut: Joi.object({ + title: Joi.string().required(), + message: Joi.string(), + iconType: Joi.string(), + }), + // Variants (OSes, languages, etc.) for which tutorial instructions are specified. + instructionVariants: Joi.array() + .items(instructionVariantSchema) + .required(), + statusCheck: statusCheckSchema, +}); + +const paramSchema = Joi.object({ + defaultValue: Joi.required(), + id: Joi.string() + .regex(/^[a-zA-Z_]+$/) + .required(), + label: Joi.string().required(), + type: Joi.string() + .valid(Object.values(PARAM_TYPES)) + .required(), +}); + +const instructionsSchema = Joi.object({ + instructionSets: Joi.array() + .items(instructionSetSchema) + .required(), + params: Joi.array().items(paramSchema), +}); + +export const tutorialSchema = { + id: Joi.string() + .regex(/^[a-zA-Z0-9-]+$/) + .required(), + category: Joi.string() + .valid(Object.values(TUTORIAL_CATEGORY)) + .required(), + name: Joi.string().required(), + isBeta: Joi.boolean().default(false), + shortDescription: Joi.string().required(), + euiIconType: Joi.string(), // EUI icon type string, one of https://elastic.github.io/eui/#/icons + longDescription: Joi.string().required(), + completionTimeMinutes: Joi.number().integer(), + previewImagePath: Joi.string(), + + // kibana and elastic cluster running on prem + onPrem: instructionsSchema.required(), + + // kibana and elastic cluster running in elastic's cloud + elasticCloud: instructionsSchema, + + // kibana running on prem and elastic cluster running in elastic's cloud + onPremElasticCloud: instructionsSchema, + + // Elastic stack artifacts produced by product when it is setup and run. + artifacts: artifactsSchema, + + // saved objects used by data module. + savedObjects: Joi.array().items(), + savedObjectsInstallMsg: Joi.string(), +}; diff --git a/src/plugins/home/server/lib/tutorials_registry_types.ts b/src/plugins/home/server/lib/tutorials_registry_types.ts new file mode 100644 index 0000000000000..d081639e5c7e2 --- /dev/null +++ b/src/plugins/home/server/lib/tutorials_registry_types.ts @@ -0,0 +1,110 @@ +/* + * 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 { IconType } from '@elastic/eui'; +import { KibanaRequest } from 'src/core/server'; + +/** @public */ +export enum TutorialsCategory { + LOGGING = 'logging', + SIEM = 'siem', + METRICS = 'metrics', + OTHER = 'other', +} +export interface ParamTypes { + NUMBER: string; + STRING: string; +} +export interface InstructionSetSchema { + readonly title: string; + readonly callOut: { + title: string; + message: string; + iconType: IconType; + }; +} +export interface ParamsSchema { + defaultValue: any; + id: string; + label: string; + type: ParamTypes; +} +export interface InstructionsSchema { + readonly instructionSets: InstructionSetSchema[]; + readonly params: ParamsSchema[]; +} +export interface DashboardSchema { + id: string; + linkLabel?: { + is: boolean; + then: any; + }; + isOverview: boolean; +} +export interface ArtifactsSchema { + readonly exportedFields: { + documentationUrl: string; + }; + readonly dashboards: DashboardSchema[]; + readonly application: { + path: string; + label: string; + }; +} +export interface TutorialSchema { + id: string; + category: TutorialsCategory; + name: string; + isBeta: boolean; + shortDescription: string; + euiIconType: IconType; // EUI icon type string, one of https://elastic.github.io/eui/#/icon; + longDescription: string; + completionTimeMinutes: number; + previewImagePath: string; + + // kibana and elastic cluster running on prem + onPrem: InstructionsSchema; + + // kibana and elastic cluster running in elastic's cloud + elasticCloud: InstructionsSchema; + + // kibana running on prem and elastic cluster running in elastic's cloud + onPremElasticCloud: InstructionsSchema; + + // Elastic stack artifacts produced by product when it is setup and run. + artifacts: ArtifactsSchema; + + // saved objects used by data module. + savedObjects: any[]; + savedObjectsInstallMsg: string; +} +export type TutorialProvider = (context: { [key: string]: unknown }) => TutorialSchema; +export type TutorialContextFactory = ( + req: KibanaRequest< + Readonly<{ + [x: string]: any; + }>, + Readonly<{ + [x: string]: any; + }>, + Readonly<{ + [x: string]: any; + }> + > +) => { [key: string]: unknown }; +export type ScopedTutorialContextFactory = (...args: any[]) => any; diff --git a/src/plugins/home/server/plugin.test.mocks.ts b/src/plugins/home/server/plugin.test.mocks.ts new file mode 100644 index 0000000000000..df63b467d8656 --- /dev/null +++ b/src/plugins/home/server/plugin.test.mocks.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 { tutorialsRegistryMock } from './services/tutorials_registry.mock'; + +export const registryMock = tutorialsRegistryMock.create(); +jest.doMock('./services', () => ({ + TutorialsRegistry: jest.fn(() => registryMock), +})); diff --git a/src/plugins/home/server/plugin.test.ts b/src/plugins/home/server/plugin.test.ts new file mode 100644 index 0000000000000..e86a2d807109f --- /dev/null +++ b/src/plugins/home/server/plugin.test.ts @@ -0,0 +1,51 @@ +/* + * 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 { registryMock } from './plugin.test.mocks'; +import { HomePlugin } from './plugin'; +import { coreMock } from '../../../core/server/mocks'; +import { CoreSetup } from '../../../core/server'; + +type MockedKeys = { [P in keyof T]: jest.Mocked }; + +describe('HomePlugin', () => { + beforeEach(() => { + registryMock.setup.mockClear(); + registryMock.start.mockClear(); + }); + + describe('setup', () => { + const mockCoreSetup: MockedKeys = coreMock.createSetup(); + + test('wires up and returns registerTutorial and addScopedTutorialContextFactory', () => { + const setup = new HomePlugin().setup(mockCoreSetup); + expect(setup).toHaveProperty('tutorials'); + expect(setup.tutorials).toHaveProperty('registerTutorial'); + expect(setup.tutorials).toHaveProperty('addScopedTutorialContextFactory'); + }); + }); + + describe('start', () => { + test('is defined', () => { + const start = new HomePlugin().start(); + expect(start).toBeDefined(); + expect(start).toHaveProperty('tutorials'); + }); + }); +}); diff --git a/src/plugins/home/server/plugin.ts b/src/plugins/home/server/plugin.ts new file mode 100644 index 0000000000000..d5a3f235f8490 --- /dev/null +++ b/src/plugins/home/server/plugin.ts @@ -0,0 +1,46 @@ +/* + * 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, Plugin } from 'src/core/server'; +import { TutorialsRegistry, TutorialsRegistrySetup, TutorialsRegistryStart } from './services'; + +export class HomePlugin implements Plugin { + private readonly tutorialsRegistry = new TutorialsRegistry(); + + public setup(core: CoreSetup) { + return { + tutorials: { ...this.tutorialsRegistry.setup(core) }, + }; + } + + public start() { + return { + tutorials: { ...this.tutorialsRegistry.start() }, + }; + } +} + +/** @public */ +export interface HomePluginSetup { + tutorials: TutorialsRegistrySetup; +} + +/** @public */ +export interface HomePluginStart { + tutorials: TutorialsRegistryStart; +} diff --git a/src/plugins/home/server/services/index.ts b/src/plugins/home/server/services/index.ts new file mode 100644 index 0000000000000..5fe5cb0ba4760 --- /dev/null +++ b/src/plugins/home/server/services/index.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. + */ +// provided to other plugins as APIs +// should model the plugin lifecycle + +export { + TutorialsRegistry, + TutorialsRegistrySetup, + TutorialsRegistryStart, +} from './tutorials_registry'; +export * from '../lib/tutorials_registry_types'; diff --git a/src/plugins/home/server/services/tutorials_registry.mock.ts b/src/plugins/home/server/services/tutorials_registry.mock.ts new file mode 100644 index 0000000000000..b54b0be4ea2b7 --- /dev/null +++ b/src/plugins/home/server/services/tutorials_registry.mock.ts @@ -0,0 +1,53 @@ +/* + * 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 { + TutorialsRegistrySetup, + TutorialsRegistryStart, + TutorialsRegistry, +} from './tutorials_registry'; + +const createSetupMock = (): jest.Mocked => { + const setup = { + registerTutorial: jest.fn(), + addScopedTutorialContextFactory: jest.fn(), + }; + return setup; +}; + +const createStartMock = (): jest.Mocked => { + const start = {}; + return start; +}; + +const createMock = (): jest.Mocked> => { + const service = { + setup: jest.fn(), + start: jest.fn(), + }; + service.setup.mockImplementation(createSetupMock); + service.start.mockImplementation(createStartMock); + return service; +}; + +export const tutorialsRegistryMock = { + createSetup: createSetupMock, + createStart: createStartMock, + create: createMock, +}; diff --git a/src/plugins/home/server/services/tutorials_registry.test.ts b/src/plugins/home/server/services/tutorials_registry.test.ts new file mode 100644 index 0000000000000..04c26bab1f065 --- /dev/null +++ b/src/plugins/home/server/services/tutorials_registry.test.ts @@ -0,0 +1,139 @@ +/* + * 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 { TutorialsRegistry } from './tutorials_registry'; +import { coreMock } from '../../../../core/server/mocks'; +import { CoreSetup } from '../../../../core/server'; +import { httpServerMock } from '../../../../../src/core/server/mocks'; + +import { + TutorialProvider, + TutorialSchema, + TutorialsCategory, + ScopedTutorialContextFactory, +} from '../lib/tutorials_registry_types'; + +const INVALID_TUTORIAL: TutorialSchema = { + id: 'test', + category: 'logging' as TutorialsCategory, + name: '', + isBeta: false, + shortDescription: 'short description', + euiIconType: 'alert', + longDescription: 'long description with lots of text', + completionTimeMinutes: 10, + previewImagePath: 'path', + onPrem: { instructionSets: [], params: [] }, + elasticCloud: { instructionSets: [], params: [] }, + onPremElasticCloud: { instructionSets: [], params: [] }, + artifacts: { + exportedFields: { documentationUrl: 'url' }, + dashboards: [], + application: { path: 'path', label: 'path' }, + }, + savedObjects: [], + savedObjectsInstallMsg: 'testMsg', +}; +const VALID_TUTORIAL: TutorialSchema = { + id: 'test', + category: 'logging' as TutorialsCategory, + name: 'new tutorial provider', + isBeta: false, + shortDescription: 'short description', + euiIconType: 'alert', + longDescription: 'long description with lots of text', + completionTimeMinutes: 10, + previewImagePath: 'path', + onPrem: { instructionSets: [], params: [] }, + elasticCloud: { instructionSets: [], params: [] }, + onPremElasticCloud: { instructionSets: [], params: [] }, + artifacts: { + exportedFields: { documentationUrl: 'url' }, + dashboards: [], + application: { path: 'path', label: 'path' }, + }, + savedObjects: [], + savedObjectsInstallMsg: 'testMsg', +}; +const invalidTutorialProvider = INVALID_TUTORIAL; +const validTutorialProvider = VALID_TUTORIAL; + +describe('TutorialsRegistry', () => { + let mockCoreSetup: MockedKeys; + let testProvider: TutorialProvider; + let testScopedTutorialContextFactory: ScopedTutorialContextFactory; + + describe('GET /api/kibana/home/tutorials', () => { + beforeEach(() => { + mockCoreSetup = coreMock.createSetup(); + }); + + test('has a router that retrieves registered tutorials', () => { + const mockResponse = httpServerMock.createResponseFactory(); + expect(mockResponse.ok.mock.calls).toMatchInlineSnapshot(`Array []`); + }); + }); + + describe('setup', () => { + test('exposes proper contract', () => { + const setup = new TutorialsRegistry().setup(mockCoreSetup); + expect(setup).toHaveProperty('registerTutorial'); + expect(setup).toHaveProperty('addScopedTutorialContextFactory'); + }); + + test('registerTutorial throws when registering a tutorial with an invalid schema', () => { + const setup = new TutorialsRegistry().setup(mockCoreSetup); + testProvider = ({}) => invalidTutorialProvider; + expect(() => setup.registerTutorial(testProvider)).toThrowErrorMatchingInlineSnapshot( + `"Unable to register tutorial spec because its invalid. ValidationError: child \\"name\\" fails because [\\"name\\" is not allowed to be empty]"` + ); + }); + + test('registerTutorial registers a tutorial with a valid schema', () => { + const setup = new TutorialsRegistry().setup(mockCoreSetup); + testProvider = ({}) => validTutorialProvider; + expect(() => setup.registerTutorial(testProvider)).not.toThrowError(); + }); + + test('addScopedTutorialContextFactory throws when given a scopedTutorialContextFactory that is not a function', () => { + const setup = new TutorialsRegistry().setup(mockCoreSetup); + const testItem = {} as TutorialProvider; + expect(() => + setup.addScopedTutorialContextFactory(testItem) + ).toThrowErrorMatchingInlineSnapshot( + `"Unable to add scoped(request) context factory because you did not provide a function"` + ); + }); + + test('addScopedTutorialContextFactory adds a scopedTutorialContextFactory when given a function', () => { + const setup = new TutorialsRegistry().setup(mockCoreSetup); + testScopedTutorialContextFactory = ({}) => 'string'; + expect(() => + setup.addScopedTutorialContextFactory(testScopedTutorialContextFactory) + ).not.toThrowError(); + }); + }); + + describe('start', () => { + test('exposes proper contract', () => { + const start = new TutorialsRegistry().start(); + expect(start).toBeDefined(); + }); + }); +}); diff --git a/src/plugins/home/server/services/tutorials_registry.ts b/src/plugins/home/server/services/tutorials_registry.ts new file mode 100644 index 0000000000000..40692d8558656 --- /dev/null +++ b/src/plugins/home/server/services/tutorials_registry.ts @@ -0,0 +1,88 @@ +/* + * 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 Joi from 'joi'; +import { CoreSetup } from 'src/core/server'; +import { + TutorialProvider, + TutorialContextFactory, + ScopedTutorialContextFactory, +} from '../lib/tutorials_registry_types'; +import { tutorialSchema } from '../lib/tutorial_schema'; + +export class TutorialsRegistry { + private readonly tutorialProviders: TutorialProvider[] = []; // pre-register all the tutorials we know we want in here + private readonly scopedTutorialContextFactories: TutorialContextFactory[] = []; + + public setup(core: CoreSetup) { + const router = core.http.createRouter(); + router.get( + { path: '/api/kibana/home/tutorials', validate: false }, + async (context, req, res) => { + const initialContext = {}; + const scopedContext = this.scopedTutorialContextFactories.reduce( + (accumulatedContext, contextFactory) => { + return { ...accumulatedContext, ...contextFactory(req) }; + }, + initialContext + ); + + return res.ok({ + body: this.tutorialProviders.map(tutorialProvider => { + return tutorialProvider(scopedContext); // All the tutorialProviders need to be refactored so that they don't need the server. + }), + }); + } + ); + return { + registerTutorial: (specProvider: TutorialProvider) => { + const emptyContext = {}; + const { error } = Joi.validate(specProvider(emptyContext), tutorialSchema); + + if (error) { + throw new Error(`Unable to register tutorial spec because its invalid. ${error}`); + } + + this.tutorialProviders.push(specProvider); + }, + + addScopedTutorialContextFactory: ( + scopedTutorialContextFactory: ScopedTutorialContextFactory + ) => { + if (typeof scopedTutorialContextFactory !== 'function') { + throw new Error( + `Unable to add scoped(request) context factory because you did not provide a function` + ); + } + + this.scopedTutorialContextFactories.push(scopedTutorialContextFactory); + }, + }; + } + + public start() { + return {}; + } +} + +/** @public */ +export type TutorialsRegistrySetup = ReturnType; + +/** @public */ +export type TutorialsRegistryStart = ReturnType; diff --git a/x-pack/plugins/spaces/kibana.json b/x-pack/plugins/spaces/kibana.json index ae121e299cc55..313e4415a8e7c 100644 --- a/x-pack/plugins/spaces/kibana.json +++ b/x-pack/plugins/spaces/kibana.json @@ -4,7 +4,7 @@ "kibanaVersion": "kibana", "configPath": ["xpack", "spaces"], "requiredPlugins": ["features", "licensing"], - "optionalPlugins": ["security"], + "optionalPlugins": ["security", "home"], "server": true, "ui": false } diff --git a/x-pack/plugins/spaces/server/plugin.ts b/x-pack/plugins/spaces/server/plugin.ts index aabdc5bcb97e8..21120ab37b06a 100644 --- a/x-pack/plugins/spaces/server/plugin.ts +++ b/x-pack/plugins/spaces/server/plugin.ts @@ -31,7 +31,7 @@ import { ConfigType } from './config'; import { toggleUICapabilities } from './lib/toggle_ui_capabilities'; import { initSpacesRequestInterceptors } from './lib/request_interceptors'; import { initExternalSpacesApi } from './routes/api/external'; - +import { HomePluginSetup } from '../../../../src/plugins/home/server'; /** * Describes a set of APIs that is available in the legacy platform only and required by this plugin * to function properly. @@ -62,6 +62,7 @@ export interface PluginsSetup { features: FeaturesPluginSetup; licensing: LicensingPluginSetup; security?: SecurityPluginSetup; + home?: HomePluginSetup; } export interface SpacesPluginSetup { @@ -138,6 +139,12 @@ export class Plugin { plugins.security.registerSpacesService(spacesService); } + if (plugins.home) { + plugins.home.tutorials.addScopedTutorialContextFactory( + createSpacesTutorialContextFactory(spacesService) + ); + } + return { spacesService, __legacyCompat: {