Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move apm tutorial from apm plugin into apm_oss plugin #66432

Merged
merged 8 commits into from
May 20, 2020
20 changes: 20 additions & 0 deletions src/plugins/apm_oss/common/index_pattern_constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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 const APM_STATIC_INDEX_PATTERN_ID = 'apm_static_index_pattern_id';
4 changes: 2 additions & 2 deletions src/plugins/apm_oss/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"configPath": [
"apm_oss"
],
"ui": false,
"requiredPlugins": []
"ui": true,
"requiredPlugins": ["home"]
}
27 changes: 27 additions & 0 deletions src/plugins/apm_oss/public/index.ts
Original file line number Diff line number Diff line change
@@ -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.
*/

import { ApmOssPlugin } from './plugin';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add the public plugin boilerplate? It looks like this is just a server side thing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flash1293 I think it's ok cause we have one asset here: src/plugins/apm_oss/public/assets/apm.png

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point, missed that.


// This exports static code and TypeScript types,
// as well as, Kibana Platform `plugin()` initializer.
export function plugin() {
return new ApmOssPlugin();
}
export { ApmOssPluginSetup, ApmOssPluginStart } from './types';
33 changes: 33 additions & 0 deletions src/plugins/apm_oss/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { ApmOssPluginSetup, ApmOssPluginStart } from './types';

export class ApmOssPlugin implements Plugin<ApmOssPluginSetup, ApmOssPluginStart> {
public setup(core: CoreSetup): ApmOssPluginSetup {
return {};
}

public start(core: CoreStart): ApmOssPluginStart {
return {};
}

public stop() {}
}
27 changes: 27 additions & 0 deletions src/plugins/apm_oss/public/types.ts
Original file line number Diff line number Diff line change
@@ -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.
*/

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ApmOssPluginSetup {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ApmOssPluginStart {}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AppPluginStartDependencies {}
2 changes: 2 additions & 0 deletions src/plugins/apm_oss/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ export function plugin(initializerContext: PluginInitializerContext) {
export type APMOSSConfig = TypeOf<typeof config.schema>;

export { APMOSSPluginSetup } from './plugin';

export { apmIndexPattern } from './tutorial/index_pattern.json';
22 changes: 19 additions & 3 deletions src/plugins/apm_oss/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,41 @@
*/
import { Plugin, CoreSetup, PluginInitializerContext } from 'src/core/server';
import { Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import { APMOSSConfig } from './';
import { HomeServerPluginSetup } from '../../home/server';
import { tutorialProvider } from './tutorial';

export class APMOSSPlugin implements Plugin<APMOSSPluginSetup> {
constructor(private readonly initContext: PluginInitializerContext) {
this.initContext = initContext;
}

public setup(core: CoreSetup) {
public async setup(core: CoreSetup, plugins: { home: HomeServerPluginSetup }) {
const config$ = this.initContext.config.create<APMOSSConfig>();

const config = await config$.pipe(take(1)).toPromise();

const apmTutorialProvider = tutorialProvider({
indexPatternTitle: config.indexPattern,
indices: {
errorIndices: config.errorIndices,
metricsIndices: config.metricsIndices,
onboardingIndices: config.onboardingIndices,
sourcemapIndices: config.sourcemapIndices,
transactionIndices: config.transactionIndices,
},
});
plugins.home.tutorials.registerTutorial(apmTutorialProvider);

return {
config$,
getRegisteredTutorialProvider: () => apmTutorialProvider,
};
}

start() {}
stop() {}
}

export interface APMOSSPluginSetup {
config$: Observable<APMOSSConfig>;
}
203 changes: 203 additions & 0 deletions src/plugins/apm_oss/server/tutorial/envs/on_prem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { INSTRUCTION_VARIANT } from '../../../../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,
} 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('apm.tutorial.apmServer.title', {
defaultMessage: 'APM Server',
}),
callOut: {
title: i18n.translate('apm.tutorial.apmServer.callOut.title', {
defaultMessage: 'Important: Updating to 7.0 or higher',
}),
message: i18n.translate('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('apm.tutorial.apmServer.statusCheck.title', {
defaultMessage: 'APM Server status',
}),
text: i18n.translate('apm.tutorial.apmServer.statusCheck.text', {
defaultMessage:
'Make sure APM Server is running before you start implementing the APM agents.',
}),
btnLabel: i18n.translate('apm.tutorial.apmServer.statusCheck.btnLabel', {
defaultMessage: 'Check APM Server status',
}),
success: i18n.translate('apm.tutorial.apmServer.statusCheck.successMessage', {
defaultMessage: 'You have correctly setup APM Server',
}),
error: i18n.translate('apm.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('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(),
},
],
statusCheck: {
title: i18n.translate('apm.tutorial.apmAgents.statusCheck.title', {
defaultMessage: 'Agent status',
}),
text: i18n.translate('apm.tutorial.apmAgents.statusCheck.text', {
defaultMessage:
'Make sure your application is running and the agents are sending data.',
}),
btnLabel: i18n.translate('apm.tutorial.apmAgents.statusCheck.btnLabel', {
defaultMessage: 'Check agent status',
}),
success: i18n.translate('apm.tutorial.apmAgents.statusCheck.successMessage', {
defaultMessage: 'Data successfully received from one or more agents',
}),
error: i18n.translate('apm.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