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

[APM] Serverless Onboarding with Custom Tutorials #158228

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0e3333d
Add first version of custom tutorials
achyutjhunjhunwala May 22, 2023
bfe6d2b
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 23, 2023
780db1b
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 23, 2023
c4ad1c3
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala May 23, 2023
571af0e
Add more unit tests and fix checktypes for i18n
achyutjhunjhunwala May 23, 2023
47baf75
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala May 23, 2023
e56825b
Fix custom integrations typings for start and setup dependencies
achyutjhunjhunwala May 23, 2023
7c8e483
Add logic to display ManagedService URL by reading from yml file
achyutjhunjhunwala May 23, 2023
1937fc5
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 23, 2023
e2f0604
Add logic to handle API key generation
achyutjhunjhunwala May 25, 2023
e541750
Simplifying code hints with code comments
achyutjhunjhunwala May 25, 2023
18ed23e
Fix broken build
achyutjhunjhunwala May 25, 2023
d58041c
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala May 25, 2023
c123407
Adding versioning to API call
achyutjhunjhunwala May 25, 2023
4a06886
Make boilerplate serviceName and Environment hardcoded in Instructions
achyutjhunjhunwala May 25, 2023
670ac50
Fix unit tests around commands
achyutjhunjhunwala May 25, 2023
af5bb19
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala May 25, 2023
d0ee71d
Fix config issues with build
achyutjhunjhunwala May 26, 2023
3e21f89
Add logic to handle no data scenario
achyutjhunjhunwala May 26, 2023
edb4015
Fix encoding issue with Mustache
achyutjhunjhunwala May 26, 2023
4fad374
Fix FTR test for exposed configs
achyutjhunjhunwala May 26, 2023
98f7c98
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala May 26, 2023
c53686f
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala May 30, 2023
ae224a7
Add success and error callouts for Create API Keys and fix exposeToBr…
achyutjhunjhunwala May 30, 2023
8d3e818
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 30, 2023
0326e92
Fix checktype issue with message
achyutjhunjhunwala May 30, 2023
7deb11d
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala May 30, 2023
ef94de5
Add warning callout for missing privileges
achyutjhunjhunwala May 30, 2023
d520409
Keyboard typo
achyutjhunjhunwala May 30, 2023
09923e2
Move create API Key button inside the table
achyutjhunjhunwala May 31, 2023
90f5a9a
Remove default message for API Key
achyutjhunjhunwala May 31, 2023
647cbdc
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala May 31, 2023
6490db9
Fix typo error
achyutjhunjhunwala May 31, 2023
3c7f933
Fix checktypes issues with apiKey
achyutjhunjhunwala May 31, 2023
49d3e80
Change routes logic to handle additional error data
achyutjhunjhunwala Jun 2, 2023
1ec6b2e
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 2, 2023
b72efbd
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 2, 2023
457766f
Fix checktype issues
achyutjhunjhunwala Jun 5, 2023
ec0f3d1
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 5, 2023
8d8a640
Fix API Test
achyutjhunjhunwala Jun 5, 2023
4e8aac5
Gate serverless configs and change the error message
achyutjhunjhunwala Jun 6, 2023
e49df74
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 6, 2023
aece6d2
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 6, 2023
c575f4f
Expose serverlessOnboarding to browser
achyutjhunjhunwala Jun 6, 2023
671124e
Fix rendering tests with exposeToBrowser
achyutjhunjhunwala Jun 6, 2023
9d5e9bb
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 6, 2023
a3ce70e
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 6, 2023
9d2e19d
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 6, 2023
6440b6a
Rename tutorial to onboarding
achyutjhunjhunwala Jun 7, 2023
7011da3
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 7, 2023
ee42cf0
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 7, 2023
dd89f06
Chore no data config
achyutjhunjhunwala Jun 7, 2023
673aa18
Merge branch 'main' into serverless-onboarding-with-custom-tutorials
achyutjhunjhunwala Jun 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/serverless.oblt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ xpack.serverless.plugin.developer.projectSwitcher.currentType: 'observability'

## Disable adding the component template `.fleet_agent_id_verification-1` to every index template for each datastream for each integration
xpack.fleet.agentIdVerificationEnabled: false

## APM Serverless Onboarding flow
xpack.apm.serverlessOnboarding: true

## Required for force installation of APM Package
xpack.fleet.packages:
- name: apm
version: latest
achyutjhunjhunwala marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'xpack.apm.serviceMapEnabled (boolean)',
'xpack.apm.ui.enabled (boolean)',
'xpack.apm.ui.maxTraceItems (number)',
'xpack.apm.managedServiceUrl (any)',
'xpack.apm.serverlessOnboarding (any)',
'xpack.apm.latestAgentVersionsUrl (string)',
'xpack.cases.files.allowedMimeTypes (array)',
'xpack.cases.files.maxSize (number)',
Expand Down
32 changes: 32 additions & 0 deletions x-pack/plugins/apm/common/tutorial/tutorials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 { CustomIntegration } from '@kbn/custom-integrations-plugin/common';

const APM_INTEGRATION_CATEGORIES = ['observability', 'apm'];

export const apmTutorialCustomIntegration: Omit<CustomIntegration, 'type'> = {
id: 'apm',
title: i18n.translate('xpack.apm.tutorial.specProvider.name', {
defaultMessage: 'APM',
}),
categories: APM_INTEGRATION_CATEGORIES,
uiInternalPath: '/app/apm/onboarding',
description: i18n.translate('xpack.apm.tutorial.introduction', {
defaultMessage:
'Collect performance metrics from your applications with Elastic APM.',
}),
icons: [
{
type: 'eui',
src: 'apmApp',
},
],
shipper: 'tutorial',
isBeta: false,
};
1 change: 1 addition & 0 deletions x-pack/plugins/apm/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"spaces",
"taskManager",
"usageCollection",
"customIntegrations", // Move this to requiredPlugins after completely migrating from the Tutorials Home App
"licenseManagement"
],
"requiredBundles": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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 React from 'react';
import { EuiCodeBlock, EuiSpacer } from '@elastic/eui';
import {
getApmAgentCommands,
getApmAgentVariables,
getApmAgentLineNumbers,
getApmAgentHighlightLang,
} from './commands/get_apm_agent_commands';
import { AgentConfigurationTable } from './agent_config_table';

export function AgentConfigInstructions({
variantId,
apmServerUrl,
secretToken,
apiKey,
createApiKey,
createApiKeyLoading,
}: {
variantId: string;
apmServerUrl: string;
secretToken?: string;
apiKey?: string | null;
createApiKey?: () => void;
createApiKeyLoading?: boolean;
}) {
const commands = getApmAgentCommands({
variantId,
apmServerUrl,
secretToken,
apiKey,
});

const variables = getApmAgentVariables(variantId, secretToken);
const lineNumbers = getApmAgentLineNumbers(variantId, apiKey);
const highlightLang = getApmAgentHighlightLang(variantId);

return (
<>
<EuiSpacer />
<AgentConfigurationTable
variables={variables}
data={{ apmServerUrl, secretToken, apiKey }}
createApiKey={createApiKey}
createApiKeyLoading={createApiKeyLoading}
/>
<EuiSpacer />

<EuiCodeBlock
isCopyable
language={highlightLang || 'bash'}
data-test-subj="commands"
lineNumbers={lineNumbers}
whiteSpace="pre"
>
{commands}
</EuiCodeBlock>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* 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 React from 'react';
import type { ValuesType } from 'utility-types';
import { get } from 'lodash';
import {
EuiBasicTable,
EuiText,
EuiBasicTableColumn,
EuiButton,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';

function ConfigurationValueColumn({
columnKey,
value,
createApiKey,
createApiKeyLoading,
}: {
columnKey: string;
value: string | null;
createApiKey?: () => void;
createApiKeyLoading?: boolean;
}) {
const shouldRenderCreateApiKeyButton =
columnKey === 'apiKey' && value === null;

if (shouldRenderCreateApiKeyButton) {
return (
<EuiButton
data-test-subj="createApiKeyAndId"
fill
onClick={createApiKey}
isLoading={createApiKeyLoading}
>
{i18n.translate('xpack.apm.tutorial.apiKey.create', {
defaultMessage: 'Create API Key',
})}
</EuiButton>
);
}

return (
<EuiText size="s" color="accent">
{value}
</EuiText>
);
}

export function AgentConfigurationTable({
variables,
data,
createApiKey,
createApiKeyLoading,
}: {
variables: { [key: string]: string };
data: {
apmServerUrl?: string;
secretToken?: string;
apiKey?: string | null;
};
createApiKey?: () => void;
createApiKeyLoading?: boolean;
}) {
if (!variables) return null;

const defaultValues = {
apmServiceName: 'my-service-name',
apmEnvironment: 'my-environment',
};

const columns: Array<EuiBasicTableColumn<ValuesType<typeof items>>> = [
{
field: 'setting',
name: i18n.translate('xpack.apm.onboarding.agent.column.configSettings', {
defaultMessage: 'Configuration setting',
}),
},
{
field: 'value',
name: i18n.translate('xpack.apm.onboarding.agent.column.configValue', {
defaultMessage: 'Configuration value',
}),
render: (_, { value, key }) => (
<ConfigurationValueColumn
columnKey={key}
value={value}
createApiKey={createApiKey}
createApiKeyLoading={createApiKeyLoading}
/>
),
},
];

const items = Object.entries(variables).map(([key, value]) => ({
setting: value,
value: get({ ...data, ...defaultValues }, key),
key,
}));
return <EuiBasicTable items={items} columns={columns} />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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';

export const djangoVariables = (secretToken?: string) => ({
apmServiceName: 'SERVICE_NAME',
...(secretToken && { secretToken: 'SECRET_TOKEN' }),
...(!secretToken && { apiKey: 'API_KEY' }),
apmServerUrl: 'SERVER_URL',
apmEnvironment: 'ENVIRONMENT',
});

export const djangoHighlightLang = 'py';

export const djangoLineNumbers = () => ({
start: 1,
highlight: '1, 3, 5, 7, 9, 12, 15, 18-19, 21, 23, 25',
});

export const django = `INSTALLED_APPS = (
# ${i18n.translate(
'xpack.apm.onboarding.djangoClient.configure.commands.addAgentComment',
{
defaultMessage: 'Add the agent to installed apps',
}
)}
'elasticapm.contrib.django',
# ...
)

ELASTIC_APM = {
# {{serviceNameHint}}
'SERVICE_NAME': 'my-service-name',

{{^secretToken}}
# {{apiKeyHint}}
'API_KEY': '{{{apiKey}}}',
{{/secretToken}}
{{#secretToken}}
# {{secretTokenHint}}
'SECRET_TOKEN': '{{{secretToken}}}',
{{/secretToken}}

# {{{serverUrlHint}}}
'SERVER_URL': '{{{apmServerUrl}}}',

# {{{serviceEnvironmentHint}}}
'ENVIRONMENT': 'my-environment',
}

MIDDLEWARE = (
# ${i18n.translate(
'xpack.apm.onboarding.djangoClient.configure.commands.addTracingMiddlewareComment',
{
defaultMessage: 'Add our tracing middleware to send performance metrics',
}
)}
'elasticapm.contrib.django.middleware.TracingMiddleware',
#...
)`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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';

export const dotnetVariables = (secretToken?: string) => ({
apmServiceName: 'ServiceName',
...(secretToken && { secretToken: 'SecretToken' }),
...(!secretToken && { apiKey: 'ApiKey' }),
apmServerUrl: 'ServerUrl',
apmEnvironment: 'Environment',
});

export const dotnetHighlightLang = 'dotnet';

export const dotnetLineNumbers = () => ({
start: 1,
highlight: '1-2, 4, 6, 8, 10-12',
});

export const dotnet = `{
"ElasticApm": {
/// {{serviceNameHint}} ${i18n.translate(
'xpack.apm.onboarding.dotnetClient.createConfig.commands.defaultServiceName',
{
defaultMessage: 'Default is the entry assembly of the application.',
}
)}
"ServiceName": "my-service-name",
{{^secretToken}}
/// {{apiKeyHint}}
"ApiKey": "{{{apiKey}}}",
{{/secretToken}}
{{#secretToken}}
/// {{secretTokenHint}}
"SecretToken": "{{{secretToken}}}",
{{/secretToken}}
/// {{{serverUrlHint}}}
"ServerUrl": "{{{apmServerUrl}}}",
/// {{{serviceEnvironmentHint}}}
"Environment": "my-environment",
}
}`;
Loading