Skip to content

Commit

Permalink
Register tutorial on APM plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed May 26, 2021
1 parent e49db71 commit 515c1c9
Show file tree
Hide file tree
Showing 8 changed files with 1,487 additions and 27 deletions.
8 changes: 8 additions & 0 deletions x-pack/plugins/apm/common/index_pattern_constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const APM_STATIC_INDEX_PATTERN_ID = 'apm_static_index_pattern_id';
39 changes: 15 additions & 24 deletions x-pack/plugins/apm/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import { i18n } from '@kbn/i18n';
import { combineLatest } from 'rxjs';
import { map, take } from 'rxjs/operators';
import {
Expand All @@ -32,7 +31,6 @@ import { createApmAgentConfigurationIndex } from './lib/settings/agent_configura
import { getApmIndices } from './lib/settings/apm_indices/get_apm_indices';
import { createApmCustomLinkIndex } from './lib/settings/custom_link/create_custom_link_index';
import { apmIndices, apmTelemetry } from './saved_objects';
import { createElasticCloudInstructions } from './tutorial/elastic_cloud';
import { uiSettings } from './ui_settings';
import type {
ApmPluginRequestHandlerContext,
Expand All @@ -51,6 +49,7 @@ import {
SERVICE_NAME,
TRANSACTION_TYPE,
} from '../common/elasticsearch_fieldnames';
import { tutorialProvider } from './tutorial';

export class APMPlugin
implements
Expand Down Expand Up @@ -103,28 +102,20 @@ export class APMPlugin
});
}

const ossTutorialProvider = plugins.apmOss.getRegisteredTutorialProvider();
plugins.home?.tutorials.unregisterTutorial(ossTutorialProvider);
plugins.home?.tutorials.registerTutorial(() => {
const ossPart = ossTutorialProvider({});
if (this.currentConfig!['xpack.apm.ui.enabled'] && ossPart.artifacts) {
// @ts-expect-error ossPart.artifacts.application is readonly
ossPart.artifacts.application = {
path: '/app/apm',
label: i18n.translate(
'xpack.apm.tutorial.specProvider.artifacts.application.label',
{
defaultMessage: 'Launch APM',
}
),
};
}

return {
...ossPart,
elasticCloud: createElasticCloudInstructions(plugins.cloud),
};
});
plugins.home?.tutorials.registerTutorial(
tutorialProvider({
isEnabled: this.currentConfig['xpack.apm.ui.enabled'],
indexPatternTitle: this.currentConfig['apm_oss.indexPattern'],
cloud: plugins.cloud,
indices: {
errorIndices: this.currentConfig['apm_oss.errorIndices'],
metricsIndices: this.currentConfig['apm_oss.metricsIndices'],
onboardingIndices: this.currentConfig['apm_oss.onboardingIndices'],
sourcemapIndices: this.currentConfig['apm_oss.sourcemapIndices'],
transactionIndices: this.currentConfig['apm_oss.transactionIndices'],
},
})
);

plugins.features.registerKibanaFeature(APM_FEATURE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { INSTRUCTION_VARIANT } from '../../../../../src/plugins/home/server';
import { INSTRUCTION_VARIANT } from '../../../../../../src/plugins/home/server';

import {
createNodeAgentInstructions,
Expand All @@ -19,8 +19,8 @@ import {
createJavaAgentInstructions,
createDotNetAgentInstructions,
createPhpAgentInstructions,
} from '../../../../../src/plugins/apm_oss/server';
import { CloudSetup } from '../../../cloud/server';
} from '../../../../../../src/plugins/apm_oss/server';
import { CloudSetup } from '../../../../cloud/server';

export function createElasticCloudInstructions(cloudSetup?: CloudSetup) {
const apmServerUrl = cloudSetup?.apm.url;
Expand Down
252 changes: 252 additions & 0 deletions x-pack/plugins/apm/server/tutorial/envs/on_prem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { i18n } from '@kbn/i18n';
import { INSTRUCTION_VARIANT } from '../../../../../../src/plugins/home/server';
import {
createWindowsServerInstructions,
createEditConfig,
createStartServerUnixSysv,
createStartServerUnix,
createDownloadServerRpm,
createDownloadServerDeb,
createDownloadServerOsx,
} from '../instructions/apm_server_instructions';
import {
createNodeAgentInstructions,
createDjangoAgentInstructions,
createFlaskAgentInstructions,
createRailsAgentInstructions,
createRackAgentInstructions,
createJsAgentInstructions,
createGoAgentInstructions,
createJavaAgentInstructions,
createDotNetAgentInstructions,
createPhpAgentInstructions,
} from '../instructions/apm_agent_instructions';

export function onPremInstructions({
errorIndices,
transactionIndices,
metricsIndices,
sourcemapIndices,
onboardingIndices,
}: {
errorIndices: string;
transactionIndices: string;
metricsIndices: string;
sourcemapIndices: string;
onboardingIndices: string;
}) {
const EDIT_CONFIG = createEditConfig();
const START_SERVER_UNIX = createStartServerUnix();
const START_SERVER_UNIX_SYSV = createStartServerUnixSysv();

return {
instructionSets: [
{
title: i18n.translate('xpack.apm.tutorial.apmServer.title', {
defaultMessage: 'APM Server',
}),
callOut: {
title: i18n.translate('xpack.apm.tutorial.apmServer.callOut.title', {
defaultMessage: 'Important: Updating to 7.0 or higher',
}),
message: i18n.translate(
'xpack.apm.tutorial.apmServer.callOut.message',
{
defaultMessage: `Please make sure your APM Server is updated to 7.0 or higher. \
You can also migrate your 6.x data with the migration assistant found in Kibana's management section.`,
}
),
iconType: 'alert',
},
instructionVariants: [
{
id: INSTRUCTION_VARIANT.OSX,
instructions: [
createDownloadServerOsx(),
EDIT_CONFIG,
START_SERVER_UNIX,
],
},
{
id: INSTRUCTION_VARIANT.DEB,
instructions: [
createDownloadServerDeb(),
EDIT_CONFIG,
START_SERVER_UNIX_SYSV,
],
},
{
id: INSTRUCTION_VARIANT.RPM,
instructions: [
createDownloadServerRpm(),
EDIT_CONFIG,
START_SERVER_UNIX_SYSV,
],
},
{
id: INSTRUCTION_VARIANT.WINDOWS,
instructions: createWindowsServerInstructions(),
},
],
statusCheck: {
title: i18n.translate(
'xpack.apm.tutorial.apmServer.statusCheck.title',
{
defaultMessage: 'APM Server status',
}
),
text: i18n.translate(
'xpack.apm.tutorial.apmServer.statusCheck.text',
{
defaultMessage:
'Make sure APM Server is running before you start implementing the APM agents.',
}
),
btnLabel: i18n.translate(
'apmOss.tutorial.apmServer.statusCheck.btnLabel',
{
defaultMessage: 'Check APM Server status',
}
),
success: i18n.translate(
'apmOss.tutorial.apmServer.statusCheck.successMessage',
{
defaultMessage: 'You have correctly setup APM Server',
}
),
error: i18n.translate(
'apmOss.tutorial.apmServer.statusCheck.errorMessage',
{
defaultMessage:
'No APM Server detected. Please make sure it is running and you have updated to 7.0 or higher.',
}
),
esHitsCheck: {
index: onboardingIndices,
query: {
bool: {
filter: [
{ term: { 'processor.event': 'onboarding' } },
{ range: { 'observer.version_major': { gte: 7 } } },
],
},
},
},
},
},
{
title: i18n.translate('xpack.apm.tutorial.apmAgents.title', {
defaultMessage: 'APM Agents',
}),
instructionVariants: [
{
id: INSTRUCTION_VARIANT.JAVA,
instructions: createJavaAgentInstructions(),
},
{
id: INSTRUCTION_VARIANT.JS,
instructions: createJsAgentInstructions(),
},
{
id: INSTRUCTION_VARIANT.NODE,
instructions: createNodeAgentInstructions(),
},
{
id: INSTRUCTION_VARIANT.DJANGO,
instructions: createDjangoAgentInstructions(),
},
{
id: INSTRUCTION_VARIANT.FLASK,
instructions: createFlaskAgentInstructions(),
},
{
id: INSTRUCTION_VARIANT.RAILS,
instructions: createRailsAgentInstructions(),
},
{
id: INSTRUCTION_VARIANT.RACK,
instructions: createRackAgentInstructions(),
},
{
id: INSTRUCTION_VARIANT.GO,
instructions: createGoAgentInstructions(),
},
{
id: INSTRUCTION_VARIANT.DOTNET,
instructions: createDotNetAgentInstructions(),
},
{
id: INSTRUCTION_VARIANT.PHP,
instructions: createPhpAgentInstructions(),
},
],
statusCheck: {
title: i18n.translate(
'xpack.apm.tutorial.apmAgents.statusCheck.title',
{
defaultMessage: 'Agent status',
}
),
text: i18n.translate(
'xpack.apm.tutorial.apmAgents.statusCheck.text',
{
defaultMessage:
'Make sure your application is running and the agents are sending data.',
}
),
btnLabel: i18n.translate(
'apmOss.tutorial.apmAgents.statusCheck.btnLabel',
{
defaultMessage: 'Check agent status',
}
),
success: i18n.translate(
'apmOss.tutorial.apmAgents.statusCheck.successMessage',
{
defaultMessage:
'Data successfully received from one or more agents',
}
),
error: i18n.translate(
'apmOss.tutorial.apmAgents.statusCheck.errorMessage',
{
defaultMessage: 'No data has been received from agents yet',
}
),
esHitsCheck: {
index: [
errorIndices,
transactionIndices,
metricsIndices,
sourcemapIndices,
],
query: {
bool: {
filter: [
{
terms: {
'processor.event': [
'error',
'transaction',
'metric',
'sourcemap',
],
},
},
{ range: { 'observer.version_major': { gte: 7 } } },
],
},
},
},
},
},
],
};
}
Loading

0 comments on commit 515c1c9

Please sign in to comment.