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..894f6bda64b4f 100644 --- a/src/legacy/core_plugins/kibana/public/home/load_tutorials.js +++ b/src/legacy/core_plugins/kibana/public/home/load_tutorials.js @@ -22,28 +22,43 @@ import { getServices } from './kibana_services'; import { i18n } from '@kbn/i18n'; const baseUrl = getServices().addBasePath('/api/kibana/home/tutorials'); +const baseUrlNP = getServices().addBasePath('/api/kibana/home/NP_tutorials'); const headers = new Headers(); headers.append('Accept', 'application/json'); 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(baseUrl, { method: 'get', credentials: 'include', headers: headers, }); - if (response.status >= 300) { + const responseNewPlatform = await fetch(baseUrlNP, { + method: 'get', + credentials: 'include', + headers: headers, + }); + if (responseLegacyPlatform.status >= 300) { + throw new Error(i18n.translate('kbn.home.loadTutorials.requestFailedErrorMessage', { + defaultMessage: 'Request failed with status code: {status}', values: { status: responseLegacyPlatform.status } } + )); + } + if (responseNewPlatform.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: 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/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/cockroachdb_metrics/index.js b/src/legacy/core_plugins/kibana/server/tutorials/cockroachdb_metrics/index.js index e05be3bda145f..865ddb47bbe5f 100644 --- a/src/legacy/core_plugins/kibana/server/tutorials/cockroachdb_metrics/index.js +++ b/src/legacy/core_plugins/kibana/server/tutorials/cockroachdb_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 cockroachdbMetricsSpecProvider(server, context) { +export function cockroachdbMetricsSpecProvider(context) { const moduleName = 'cockroachdb'; return { id: 'cockroachdbMetrics', 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 badaa338bff43..9da1787d9742f 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 53f7dd531cbbd..f3be55ccbc904 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 a95baad4ccb65..f1e60ae57311c 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'; @@ -81,66 +80,66 @@ import { consulMetricsSpecProvider } from './consul_metrics'; import { cockroachdbMetricsSpecProvider } from './cockroachdb_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.tutorials.registerTutorial(systemLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(systemMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(apacheLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(apacheMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(elasticsearchLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(iisLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(kafkaLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(logstashLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(nginxLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(nginxMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(mysqlLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(mysqlMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(mongodbMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(osqueryLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(phpfpmMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(postgresqlMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(postgresqlLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(rabbitmqMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(redisLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(redisMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(suricataLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(dockerMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(kubernetesMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(uwsgiMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(netflowSpecProvider); + server.newPlatform.setup.plugins.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(natsMetricsSpecProvider); - server.registerTutorial(natsLogsSpecProvider); - server.registerTutorial(zeekLogsSpecProvider); - 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.tutorials.registerTutorial(cephMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(aerospikeMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(couchbaseMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(dropwizardMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(elasticsearchMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(etcdMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(haproxyMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(kafkaMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(kibanaMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(memcachedMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(muninMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(vSphereMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(windowsMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(windowsEventLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(golangMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(logstashMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(prometheusMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(zookeeperMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(uptimeMonitorsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(cloudwatchLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(awsMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(mssqlMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(natsMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(natsLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(zeekLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(corednsMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(corednsLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(auditbeatSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(iptablesLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(ciscoLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(envoyproxyLogsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(couchdbMetricsSpecProvider); server.registerTutorial(emsBoundariesSpecProvider); - server.registerTutorial(consulMetricsSpecProvider); - server.registerTutorial(cockroachdbMetricsSpecProvider); + server.newPlatform.setup.plugins.tutorials.registerTutorial(consulMetricsSpecProvider); + server.newPlatform.setup.plugins.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..6e11db51e1b67 100644 --- a/src/legacy/ui/tutorials_mixin.js +++ b/src/legacy/ui/tutorials_mixin.js @@ -19,6 +19,38 @@ import Joi from 'joi'; import { tutorialSchema } from '../core_plugins/kibana/common/tutorials/tutorial_schema'; +// import { schema } from '@kbn/config-schema'; + +class TutorialsPlugin { + setup(core) { + const tutorialProviders = []; + const scopedTutorialContextFactories = []; + + core.http.registerRouteHandlerContext('getTutorials', (request) => { + const initialContext = {}; + const scopedContext = scopedTutorialContextFactories.reduce((accumulatedContext, contextFactory) => { + return { ...accumulatedContext, ...contextFactory(request) }; + }, initialContext); + + return tutorialProviders.map((tutorialProvider) => { + return tutorialProvider(server, scopedContext); + }); + }); + + return { + registerTutorial(specProvider) { + const emptyContext = {}; + const { error } = Joi.validate(specProvider(server, emptyContext), tutorialSchema); + + if (error) { + throw new Error(`Unable to register tutorial spec because its invalid. ${error}`); + } + + tutorialProviders.push(specProvider); + } + }; + } +} export function tutorialsMixin(kbnServer, server) { const tutorialProviders = []; @@ -36,6 +68,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 +80,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/tutorials/kibana.json b/src/plugins/tutorials/kibana.json new file mode 100644 index 0000000000000..0b931ccfb1514 --- /dev/null +++ b/src/plugins/tutorials/kibana.json @@ -0,0 +1,6 @@ +{ + "id": "tutorials", + "version": "kibana", + "server": true, + "ui": false +} diff --git a/src/plugins/tutorials/server/index.ts b/src/plugins/tutorials/server/index.ts new file mode 100644 index 0000000000000..5a2b4789badbb --- /dev/null +++ b/src/plugins/tutorials/server/index.ts @@ -0,0 +1,25 @@ +/* + * 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 { TutorialsSetup, TutorialsStart } from './plugin'; // types +import { TutorialsPlugin } from './plugin'; // the actual plugin class +// also export other relevant subtypes + +export const plugin = () => new TutorialsPlugin(); +// export const config = () => new TutorialsConfig(); optional, only if needed diff --git a/src/plugins/tutorials/server/plugin.ts b/src/plugins/tutorials/server/plugin.ts new file mode 100644 index 0000000000000..6c7c17f73dbbc --- /dev/null +++ b/src/plugins/tutorials/server/plugin.ts @@ -0,0 +1,134 @@ +/* + * 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, Plugin, KibanaRequest } from 'src/core/server'; +import { tutorialSchema } from './tutorial_schema'; +import { + TutorialsRegistrySetup, + TutorialsRegistryStart, + TutorialsRegistry, + TutorialSchema, +} from './services'; + +type TutorialProvider = (context: { [key: string]: unknown }) => TutorialSchema; +type TutorialContextFactory = ( + req: KibanaRequest< + Readonly<{ + [x: string]: any; + }>, + Readonly<{ + [x: string]: any; + }>, + Readonly<{ + [x: string]: any; + }> + > +) => { [key: string]: unknown }; +type ScopedTutorialContextFactory = (...args: any[]) => any; +type AddScopedTutorialContextFactory = (arg0: ScopedTutorialContextFactory) => void; +// following similar signature to the features_catalogue plugin +export class TutorialsPlugin implements Plugin { + private readonly tutorialProviders: TutorialProvider[] = []; + private readonly scopedTutorialContextFactories: TutorialContextFactory[] = []; + + public async setup(core: CoreSetup) { + /* + core.http.registerRouterHandlerContext is used to provide a specific value for this request (as the route context) + This context is available in route handlers + + Otherwise, we return an object containing `registerTutorial` and `addScopedTutorialContextFactory` + Question: is the way the `addScopedTutorialContextFactory` implemented correct? + */ + // core.http.registerRouteHandlerContext('getTutorials', (request: any) => { + // const initialContext = {}; + // const scopedContext = this.scopedTutorialContextFactories.reduce( + // (accumulatedContext, contextFactory) => { + // return { ...accumulatedContext, ...contextFactory(request) }; + // }, + // initialContext + // ); + // return this.tutorialProviders.map(tutorialProvider => { + // return tutorialProvider(scopedContext); // All the tutorial providers need to be refactored so that they only accept the sscopedContext. + // }); + // }); + + // const router = core.http.createRouter(); + // router.get( + // { path: '/api/kibana/home/NP_tutorials', validate: false }, + // async (context, req, res) => { + // return res.ok({ body: context.getTutorials }); + // } + // ); + + // The following handler implementation is pretty much the same as using the code from above. + const router = core.http.createRouter(); + router.get( + { path: '/api/kibana/home/NP_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 async start() { + return {}; + } +} + +/** @public */ +export type TutorialsSetup = TutorialsRegistrySetup; + +/** @public */ +export type TutorialsStart = TutorialsRegistryStart; diff --git a/src/plugins/tutorials/server/routes/index.ts b/src/plugins/tutorials/server/routes/index.ts new file mode 100644 index 0000000000000..cb4f1d79a3ee9 --- /dev/null +++ b/src/plugins/tutorials/server/routes/index.ts @@ -0,0 +1,19 @@ +/* + * 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. + */ +// HTTP routes diff --git a/src/plugins/tutorials/server/services/index.ts b/src/plugins/tutorials/server/services/index.ts new file mode 100644 index 0000000000000..b588274577981 --- /dev/null +++ b/src/plugins/tutorials/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, + TutorialSchema, +} from './tutorials_registry'; diff --git a/src/plugins/tutorials/server/services/tutorials_registry.ts b/src/plugins/tutorials/server/services/tutorials_registry.ts new file mode 100644 index 0000000000000..7178e4b3f0adb --- /dev/null +++ b/src/plugins/tutorials/server/services/tutorials_registry.ts @@ -0,0 +1,161 @@ +/* + * 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 { CoreSetup } 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 class TutorialsRegistry { + public setup(core: CoreSetup) { + const tutorialProviders: Array<(tutorialProvider: TutorialSchema) => void> = []; + const scopedTutorialContextFactories: Array<(scopedTutorialContextFactory: any) => void> = []; + core.http.registerRouteHandlerContext('getTutorials', (request: any) => { + const intitialContext = new Map(); + const scopedContext = scopedTutorialContextFactories.reduce( + (accumulatedContext, contextFactory) => { + return { ...accumulatedContext, ...contextFactory(request) }; + }, + intitialContext + ); + return tutorialProviders.map(tutorialProvider => { + return tutorialProvider(scopedContext); + }); + }); + + return { + register: () => {}, + }; + } + + public start() { + return { + get: () => {}, + }; + } +} + +export type TutorialsRegistrySetup = ReturnType; +export type TutorialsRegistryStart = ReturnType; + +// from Josh Dover: (this should actually be the TutorialsRegistry) +/* +class TutorialsPlugin { + setup(core) { + const tutorialProviders = []; + const scopedTutorialContextFactories = []; + + core.http.registerRouteHandlerContext('getTutorials', (request) => { + const initialContext = {}; + const scopedContext = scopedTutorialContextFactories.reduce((accumulatedContext, contextFactory) => { + return { ...accumulatedContext, ...contextFactory(request) }; + }, initialContext); + + return tutorialProviders.map((tutorialProvider) => { + return tutorialProvider(server, scopedContext); + }); + }); + + return { + registerTutorial(specProvider) { // specProvider should implement TutorialSchema + const emptyContext = {}; + const { error } = Joi.validate(specProvider(server, emptyContext), tutorialSchema); // the tutorialSchema's been typed in TutorialSchema + + if (error) { + throw new Error(`Unable to register tutorial spec because its invalid. ${error}`); + } + + tutorialProviders.push(specProvider); + } + }; + } +} +*/ diff --git a/src/plugins/tutorials/server/tutorial_schema.ts b/src/plugins/tutorials/server/tutorial_schema.ts new file mode 100644 index 0000000000000..eb001ac96cceb --- /dev/null +++ b/src/plugins/tutorials/server/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(), +};