Skip to content

Commit

Permalink
adding fleet information on APM tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Jun 2, 2021
1 parent 2f81e72 commit 66b9351
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 41 deletions.
7 changes: 6 additions & 1 deletion src/plugins/home/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ export const plugin = (initContext: PluginInitializerContext) => new HomeServerP

export { INSTRUCTION_VARIANT } from '../common/instruction_variant';
export { TutorialsCategory } from './services/tutorials';
export type { ArtifactsSchema, TutorialSchema, InstructionSetSchema } from './services/tutorials';
export type {
ArtifactsSchema,
TutorialSchema,
InstructionSetSchema,
InstructionsSchema,
} from './services/tutorials';
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const instructionsSchema = schema.object({
instructionSets: schema.arrayOf(instructionSetSchema),
params: schema.maybe(schema.arrayOf(paramSchema)),
});
export type InstructionsSchema = TypeOf<typeof instructionSchema>;
export type InstructionsSchema = TypeOf<typeof instructionsSchema>;

const tutorialIdRegExp = /^[a-zA-Z0-9-]+$/;
export const tutorialSchema = schema.object({
Expand Down
59 changes: 22 additions & 37 deletions x-pack/plugins/apm/server/tutorial/envs/elastic_cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ export function createElasticCloudInstructions(
const apmServerUrl = cloudSetup?.apm.url;
const instructionSets = [];

instructionSets.push(
getApmServerInstructionSet({
cloudSetup,
isApmServerEnabled: !!apmServerUrl,
})
);
if (!apmServerUrl) {
instructionSets.push(getApmServerInstructionSet(cloudSetup));
}

instructionSets.push(getApmAgentInstructionSet(cloudSetup));

Expand All @@ -46,41 +43,29 @@ export function createElasticCloudInstructions(
};
}

function getApmServerInstructionSet({
cloudSetup,
isApmServerEnabled,
}: {
cloudSetup?: CloudSetup;
isApmServerEnabled: boolean;
}): InstructionSetSchema {
const instructionVariants: InstructionSetSchema['instructionVariants'] = [
{
id: INSTRUCTION_VARIANT.FLEET,
instructions: [{ customComponent: 'apm_fleet' }],
},
];

if (!isApmServerEnabled) {
instructionVariants.push({
id: INSTRUCTION_VARIANT.ESC,
instructions: [
{
title: 'Enable the APM Server in the ESS console',
textPre: i18n.translate('xpack.apm.tutorial.elasticCloud.textPre', {
defaultMessage:
'To enable the APM Server go to [the Elastic Cloud console](https://cloud.elastic.co/deployments?q={cloudId}) and enable APM in the deployment settings. Once enabled, refresh this page.',
values: { cloudId: cloudSetup?.cloudId },
}),
},
],
});
}

function getApmServerInstructionSet(
cloudSetup?: CloudSetup
): InstructionSetSchema {
const cloudId = cloudSetup?.cloudId;
return {
title: i18n.translate('xpack.apm.tutorial.apmServer.title', {
defaultMessage: 'APM Server',
}),
instructionVariants,
instructionVariants: [
{
id: INSTRUCTION_VARIANT.ESC,
instructions: [
{
title: 'Enable the APM Server in the ESS console',
textPre: i18n.translate('xpack.apm.tutorial.elasticCloud.textPre', {
defaultMessage:
'To enable the APM Server go to [the Elastic Cloud console](https://cloud.elastic.co/deployments?q={cloudId}) and enable APM in the deployment settings. Once enabled, refresh this page.',
values: { cloudId },
}),
},
],
},
],
};
}

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/apm/server/tutorial/envs/on_prem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';
import {
INSTRUCTION_VARIANT,
TutorialSchema,
InstructionsSchema,
} from '../../../../../../src/plugins/home/server';
import {
createDjangoAgentInstructions,
Expand Down Expand Up @@ -44,7 +44,7 @@ export function onPremInstructions({
metricsIndices: string;
sourcemapIndices: string;
onboardingIndices: string;
}): TutorialSchema['onPrem'] {
}): InstructionsSchema {
const EDIT_CONFIG = createEditConfig();
const START_SERVER_UNIX = createStartServerUnix();
const START_SERVER_UNIX_SYSV = createStartServerUnixSysv();
Expand Down

0 comments on commit 66b9351

Please sign in to comment.