From 3f484a78179db0f869320fab54702b1896391dfd Mon Sep 17 00:00:00 2001 From: cauemarcondes Date: Thu, 27 May 2021 14:51:32 -0400 Subject: [PATCH] adding fleet section --- .../home/common/instruction_variant.ts | 2 + src/plugins/home/server/index.ts | 2 +- x-pack/plugins/apm/server/plugin.ts | 2 +- .../apm/server/tutorial/envs/elastic_cloud.ts | 18 +++++++-- .../apm/server/tutorial/envs/on_prem.ts | 37 ++++++++++++++++++- x-pack/plugins/apm/server/tutorial/index.ts | 8 +++- 6 files changed, 59 insertions(+), 10 deletions(-) diff --git a/src/plugins/home/common/instruction_variant.ts b/src/plugins/home/common/instruction_variant.ts index 310ee23460a08..2d288fa1d2068 100644 --- a/src/plugins/home/common/instruction_variant.ts +++ b/src/plugins/home/common/instruction_variant.ts @@ -24,6 +24,7 @@ export const INSTRUCTION_VARIANT = { DOTNET: 'dotnet', LINUX: 'linux', PHP: 'php', + FLEET: 'fleet', }; const DISPLAY_MAP = { @@ -44,6 +45,7 @@ const DISPLAY_MAP = { [INSTRUCTION_VARIANT.DOTNET]: '.NET', [INSTRUCTION_VARIANT.LINUX]: 'Linux', [INSTRUCTION_VARIANT.PHP]: 'PHP', + [INSTRUCTION_VARIANT.FLEET]: 'Elastic APM (beta) in Fleet', }; /** diff --git a/src/plugins/home/server/index.ts b/src/plugins/home/server/index.ts index 840a5944a1343..b412d96afeafb 100644 --- a/src/plugins/home/server/index.ts +++ b/src/plugins/home/server/index.ts @@ -27,4 +27,4 @@ export const plugin = (initContext: PluginInitializerContext) => new HomeServerP export { INSTRUCTION_VARIANT } from '../common/instruction_variant'; export { TutorialsCategory } from './services/tutorials'; -export type { ArtifactsSchema } from './services/tutorials'; +export type { ArtifactsSchema, TutorialSchema, InstructionSetSchema } from './services/tutorials'; diff --git a/x-pack/plugins/apm/server/plugin.ts b/x-pack/plugins/apm/server/plugin.ts index 824eba9bce0b0..ddfd1368385d3 100644 --- a/x-pack/plugins/apm/server/plugin.ts +++ b/x-pack/plugins/apm/server/plugin.ts @@ -101,7 +101,6 @@ export class APMPlugin kibanaVersion: this.initContext.env.packageInfo.version, }); } - plugins.home?.tutorials.registerTutorial( tutorialProvider({ isEnabled: this.currentConfig['xpack.apm.ui.enabled'], @@ -114,6 +113,7 @@ export class APMPlugin sourcemapIndices: this.currentConfig['apm_oss.sourcemapIndices'], transactionIndices: this.currentConfig['apm_oss.transactionIndices'], }, + basePath: core.http.basePath, }) ); diff --git a/x-pack/plugins/apm/server/tutorial/envs/elastic_cloud.ts b/x-pack/plugins/apm/server/tutorial/envs/elastic_cloud.ts index c6afd6a592fff..55adc756f31af 100644 --- a/x-pack/plugins/apm/server/tutorial/envs/elastic_cloud.ts +++ b/x-pack/plugins/apm/server/tutorial/envs/elastic_cloud.ts @@ -6,7 +6,11 @@ */ import { i18n } from '@kbn/i18n'; -import { INSTRUCTION_VARIANT } from '../../../../../../src/plugins/home/server'; +import { + INSTRUCTION_VARIANT, + TutorialSchema, + InstructionSetSchema, +} from '../../../../../../src/plugins/home/server'; import { createNodeAgentInstructions, @@ -22,7 +26,9 @@ import { } from '../instructions/apm_agent_instructions'; import { CloudSetup } from '../../../../cloud/server'; -export function createElasticCloudInstructions(cloudSetup?: CloudSetup) { +export function createElasticCloudInstructions( + cloudSetup?: CloudSetup +): TutorialSchema['elasticCloud'] { const apmServerUrl = cloudSetup?.apm.url; const instructionSets = []; @@ -37,7 +43,9 @@ export function createElasticCloudInstructions(cloudSetup?: CloudSetup) { }; } -function getApmServerInstructionSet(cloudSetup?: CloudSetup) { +function getApmServerInstructionSet( + cloudSetup?: CloudSetup +): InstructionSetSchema { const cloudId = cloudSetup?.cloudId; return { title: i18n.translate('xpack.apm.tutorial.apmServer.title', { @@ -61,7 +69,9 @@ function getApmServerInstructionSet(cloudSetup?: CloudSetup) { }; } -function getApmAgentInstructionSet(cloudSetup?: CloudSetup) { +function getApmAgentInstructionSet( + cloudSetup?: CloudSetup +): InstructionSetSchema { const apmServerUrl = cloudSetup?.apm.url; const secretToken = cloudSetup?.apm.secretToken; diff --git a/x-pack/plugins/apm/server/tutorial/envs/on_prem.ts b/x-pack/plugins/apm/server/tutorial/envs/on_prem.ts index a0e96f563381c..a3fc13b7ad656 100644 --- a/x-pack/plugins/apm/server/tutorial/envs/on_prem.ts +++ b/x-pack/plugins/apm/server/tutorial/envs/on_prem.ts @@ -6,7 +6,12 @@ */ import { i18n } from '@kbn/i18n'; -import { INSTRUCTION_VARIANT } from '../../../../../../src/plugins/home/server'; +import { IBasePath } from 'kibana/server'; +import url from 'url'; +import { + INSTRUCTION_VARIANT, + TutorialSchema, +} from '../../../../../../src/plugins/home/server'; import { createWindowsServerInstructions, createEditConfig, @@ -35,13 +40,15 @@ export function onPremInstructions({ metricsIndices, sourcemapIndices, onboardingIndices, + basePath, }: { errorIndices: string; transactionIndices: string; metricsIndices: string; sourcemapIndices: string; onboardingIndices: string; -}) { + basePath: IBasePath; +}): TutorialSchema['onPrem'] { const EDIT_CONFIG = createEditConfig(); const START_SERVER_UNIX = createStartServerUnix(); const START_SERVER_UNIX_SYSV = createStartServerUnixSysv(); @@ -66,6 +73,32 @@ export function onPremInstructions({ iconType: 'alert', }, instructionVariants: [ + { + id: INSTRUCTION_VARIANT.FLEET, + instructions: [ + { + title: i18n.translate( + 'xpack.apm.tutorial.apmServer.fleet.title', + { + defaultMessage: + 'Elastic APM (beta) now available in Fleet!', + } + ), + textPre: i18n.translate( + 'xpack.apm.tutorial.apmServer.fleet.message', + { + defaultMessage: + 'The [APM integration]({apmIntegrationTest}) installs Elasticsearch templates and Ingest Node pipelines for APM data.', + values: { + apmIntegrationTest: `${url.format( + basePath.prepend('/app/fleet#/policies') + )}`, + }, + } + ), + }, + ], + }, { id: INSTRUCTION_VARIANT.OSX, instructions: [ diff --git a/x-pack/plugins/apm/server/tutorial/index.ts b/x-pack/plugins/apm/server/tutorial/index.ts index d678677a4b751..47e1e3901581b 100644 --- a/x-pack/plugins/apm/server/tutorial/index.ts +++ b/x-pack/plugins/apm/server/tutorial/index.ts @@ -6,6 +6,7 @@ */ import { i18n } from '@kbn/i18n'; +import { IBasePath } from 'kibana/server'; import { onPremInstructions } from './envs/on_prem'; import { createElasticCloudInstructions } from './envs/elastic_cloud'; import apmIndexPattern from './index_pattern.json'; @@ -13,6 +14,7 @@ import { CloudSetup } from '../../../cloud/server'; import { ArtifactsSchema, TutorialsCategory, + TutorialSchema, } from '../../../../../src/plugins/home/server'; import { APM_STATIC_INDEX_PATTERN_ID } from '../../common/index_pattern_constants'; @@ -27,6 +29,7 @@ export const tutorialProvider = ({ indexPatternTitle, indices, cloud, + basePath, }: { isEnabled: boolean; indexPatternTitle: string; @@ -38,6 +41,7 @@ export const tutorialProvider = ({ sourcemapIndices: string; onboardingIndices: string; }; + basePath: IBasePath; }) => () => { const savedObjects = [ { @@ -102,7 +106,7 @@ It allows you to monitor the performance of thousands of applications in real ti ), euiIconType: 'apmApp', artifacts, - onPrem: onPremInstructions(indices), + onPrem: onPremInstructions({ ...indices, basePath }), elasticCloud: createElasticCloudInstructions(cloud), previewImagePath: '/plugins/apm/assets/apm.png', savedObjects, @@ -113,5 +117,5 @@ It allows you to monitor the performance of thousands of applications in real ti 'An APM index pattern is required for some features in the APM UI.', } ), - }; + } as TutorialSchema; };