[APM] remove default service name and environment (#159901)

## Summary

Closes https://github.com/elastic/kibana/issues/159900


This PR removed the default Service Name and Environment and add
CopyToClipboard feature for Managed Service Url and API Key

<img width="970" alt="image"
src="dc3d2548-1219-40c3-858c-280f87a6bf19">
This commit is contained in:
Achyut Jhunjhunwala 2023-06-19 14:17:35 +02:00 committed by GitHub
parent 3a27239fbe
commit b0604a833f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 94 additions and 112 deletions

View file

@ -13,9 +13,10 @@ import {
EuiText,
EuiBasicTableColumn,
EuiButton,
EuiButtonIcon,
copyToClipboard,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
function ConfigurationValueColumn({
columnKey,
value,
@ -46,9 +47,19 @@ function ConfigurationValueColumn({
}
return (
<EuiText size="s" color="accent">
{value}
</EuiText>
<>
<EuiText size="s" color="accent">
{value}
</EuiText>
{value && (
<EuiButtonIcon
aria-label="Copy to clipboard"
color="text"
iconType="copy"
onClick={() => copyToClipboard(value)}
/>
)}
</>
);
}

View file

@ -8,18 +8,16 @@
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',
highlight: '1, 3, 5, 7, 9, 12, 15, 18-19, 21, 23, 25',
});
export const django = `INSTALLED_APPS = (
@ -35,7 +33,7 @@ export const django = `INSTALLED_APPS = (
ELASTIC_APM = {
# {{serviceNameHint}}
'SERVICE_NAME': 'my-service-name',
'SERVICE_NAME': '<your-service-name>',
{{^secretToken}}
# {{apiKeyHint}}
@ -50,7 +48,7 @@ ELASTIC_APM = {
'SERVER_URL': '{{{apmServerUrl}}}',
# {{{serviceEnvironmentHint}}}
'ENVIRONMENT': 'my-environment',
'ENVIRONMENT': '<your-environment>',
}
MIDDLEWARE = (

View file

@ -4,15 +4,12 @@
* 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';
@ -30,7 +27,7 @@ export const dotnet = `{
defaultMessage: 'Default is the entry assembly of the application.',
}
)}
"ServiceName": "my-service-name",
"ServiceName": "<your-service-name>",
{{^secretToken}}
/// {{apiKeyHint}}
"ApiKey": "{{{apiKey}}}",
@ -42,6 +39,6 @@ export const dotnet = `{
/// {{{serverUrlHint}}}
"ServerUrl": "{{{apmServerUrl}}}",
/// {{{serviceEnvironmentHint}}}
"Environment": "my-environment",
"Environment": "<your-environment>",
}
}`;

View file

@ -8,18 +8,16 @@
import { i18n } from '@kbn/i18n';
export const flaskVariables = (secretToken?: string) => ({
apmServiceName: 'SERVICE_NAME',
...(secretToken && { secretToken: 'SECRET_TOKEN' }),
...(!secretToken && { apiKey: 'API_KEY' }),
apmServerUrl: 'SERVER_URL',
apmEnvironment: 'ENVIRONMENT',
});
export const flaskHighlightLang = 'py';
export const flaskLineNumbers = () => ({
start: 1,
highlight: '2-4, 7-8, 10, 13, 16, 19-22',
highlight: '2-4, 7-8, 10, 12, 15, 18-21',
});
export const flask = `# ${i18n.translate(
@ -41,8 +39,7 @@ apm = ElasticAPM(app)
from elasticapm.contrib.flask import ElasticAPM
app.config['ELASTIC_APM'] = {
# {{serviceNameHint}}
'SERVICE_NAME': 'my-service-name',
'SERVICE_NAME': '<your-service-name>',
{{^secretToken}}
# {{apiKeyHint}}
'API_KEY': '{{{apiKey}}}',
@ -55,8 +52,8 @@ app.config['ELASTIC_APM'] = {
# {{{serverUrlHint}}}
'SERVER_URL': '{{{apmServerUrl}}}',
{{{serviceEnvironmentHint}}}
'ENVIRONMENT': 'my-environment',
# {{{serviceEnvironmentHint}}}
'ENVIRONMENT': '<your-environment>',
}
apm = ElasticAPM(app)`;

View file

@ -25,10 +25,10 @@ describe('getCommands', () => {
});
expect(commands).toMatchInlineSnapshot(`
"java -javaagent:/path/to/elastic-apm-agent-<version>.jar \\\\
-Delastic.apm.service_name=my-service-name \\\\
-Delastic.apm.service_name=<your-service-name> \\\\\\\\
-Delastic.apm.api_key= \\\\
-Delastic.apm.server_url= \\\\
-Delastic.apm.environment=my-environment \\\\
-Delastic.apm.environment=<your-environment> \\\\\\\\
-Delastic.apm.application_packages=org.example \\\\
-jar my-service-name.jar"
`);
@ -42,10 +42,10 @@ describe('getCommands', () => {
expect(commands).not.toBe('');
expect(commands).toMatchInlineSnapshot(`
"java -javaagent:/path/to/elastic-apm-agent-<version>.jar \\\\
-Delastic.apm.service_name=my-service-name \\\\
-Delastic.apm.service_name=<your-service-name> \\\\\\\\
-Delastic.apm.secret_token=foobar \\\\
-Delastic.apm.server_url=localhost:8220 \\\\
-Delastic.apm.environment=my-environment \\\\
-Delastic.apm.environment=<your-environment> \\\\\\\\
-Delastic.apm.application_packages=org.example \\\\
-jar my-service-name.jar"
`);
@ -60,10 +60,10 @@ describe('getCommands', () => {
expect(commands).not.toBe('');
expect(commands).toMatchInlineSnapshot(`
"java -javaagent:/path/to/elastic-apm-agent-<version>.jar \\\\
-Delastic.apm.service_name=my-service-name \\\\
-Delastic.apm.service_name=<your-service-name> \\\\\\\\
-Delastic.apm.secret_token=foobar \\\\
-Delastic.apm.server_url=localhost:8220 \\\\
-Delastic.apm.environment=my-environment \\\\
-Delastic.apm.environment=<your-environment> \\\\\\\\
-Delastic.apm.application_packages=org.example \\\\
-jar my-service-name.jar"
`);
@ -79,9 +79,8 @@ describe('getCommands', () => {
expect(commands).toMatchInlineSnapshot(`
"// Add this to the very top of the first file loaded in your app
var apm = require('elastic-apm-node').start({
// The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Overrides the service name in package.json.
serviceName: 'my-service-name',
serviceName: '<your-service-name>',
// Use if APM Server requires an API Key. This is used to ensure that only your agents can send data to your APM server. Agents can use API keys as a replacement of secret token, APM server can have multiple API keys. When both secret token and API key are used, API key has priority and secret token is ignored.
apiKey: '',
@ -90,7 +89,7 @@ describe('getCommands', () => {
serverUrl: '',
// The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
environment: 'my-environment'
environment: '<your-environment>'
})"
`);
});
@ -104,9 +103,8 @@ describe('getCommands', () => {
expect(commands).toMatchInlineSnapshot(`
"// Add this to the very top of the first file loaded in your app
var apm = require('elastic-apm-node').start({
// The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Overrides the service name in package.json.
serviceName: 'my-service-name',
serviceName: '<your-service-name>',
// Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
secretToken: 'foobar',
@ -115,7 +113,7 @@ describe('getCommands', () => {
serverUrl: 'localhost:8220',
// The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
environment: 'my-environment'
environment: '<your-environment>'
})"
`);
});
@ -130,9 +128,8 @@ describe('getCommands', () => {
expect(commands).toMatchInlineSnapshot(`
"// Add this to the very top of the first file loaded in your app
var apm = require('elastic-apm-node').start({
// The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Overrides the service name in package.json.
serviceName: 'my-service-name',
serviceName: '<your-service-name>',
// Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
secretToken: 'foobar',
@ -141,7 +138,7 @@ describe('getCommands', () => {
serverUrl: 'localhost:8220',
// The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
environment: 'my-environment'
environment: '<your-environment>'
})"
`);
});
@ -161,7 +158,7 @@ describe('getCommands', () => {
ELASTIC_APM = {
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space.
'SERVICE_NAME': 'my-service-name',
'SERVICE_NAME': '<your-service-name>',
# Use if APM Server requires an API Key. This is used to ensure that only your agents can send data to your APM server. Agents can use API keys as a replacement of secret token, APM server can have multiple API keys. When both secret token and API key are used, API key has priority and secret token is ignored.
'API_KEY': '',
@ -170,7 +167,7 @@ describe('getCommands', () => {
'SERVER_URL': '',
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
'ENVIRONMENT': 'my-environment',
'ENVIRONMENT': '<your-environment>',
}
MIDDLEWARE = (
@ -196,7 +193,7 @@ describe('getCommands', () => {
ELASTIC_APM = {
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space.
'SERVICE_NAME': 'my-service-name',
'SERVICE_NAME': '<your-service-name>',
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
'SECRET_TOKEN': 'foobar',
@ -205,7 +202,7 @@ describe('getCommands', () => {
'SERVER_URL': 'localhost:8220',
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
'ENVIRONMENT': 'my-environment',
'ENVIRONMENT': '<your-environment>',
}
MIDDLEWARE = (
@ -232,7 +229,7 @@ describe('getCommands', () => {
ELASTIC_APM = {
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space.
'SERVICE_NAME': 'my-service-name',
'SERVICE_NAME': '<your-service-name>',
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
'SECRET_TOKEN': 'foobar',
@ -241,7 +238,7 @@ describe('getCommands', () => {
'SERVER_URL': 'localhost:8220',
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
'ENVIRONMENT': 'my-environment',
'ENVIRONMENT': '<your-environment>',
}
MIDDLEWARE = (
@ -268,16 +265,15 @@ describe('getCommands', () => {
from elasticapm.contrib.flask import ElasticAPM
app.config['ELASTIC_APM'] = {
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space.
'SERVICE_NAME': 'my-service-name',
'SERVICE_NAME': '<your-service-name>',
# Use if APM Server requires an API Key. This is used to ensure that only your agents can send data to your APM server. Agents can use API keys as a replacement of secret token, APM server can have multiple API keys. When both secret token and API key are used, API key has priority and secret token is ignored.
'API_KEY': '',
# Set the custom APM Server URL (default: http://localhost:8200). The URL must be fully qualified, including protocol (http or https) and port.
'SERVER_URL': '',
The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
'ENVIRONMENT': 'my-environment',
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
'ENVIRONMENT': '<your-environment>',
}
apm = ElasticAPM(app)"
@ -300,16 +296,15 @@ describe('getCommands', () => {
from elasticapm.contrib.flask import ElasticAPM
app.config['ELASTIC_APM'] = {
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space.
'SERVICE_NAME': 'my-service-name',
'SERVICE_NAME': '<your-service-name>',
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
'SECRET_TOKEN': 'foobar',
# Set the custom APM Server URL (default: http://localhost:8200). The URL must be fully qualified, including protocol (http or https) and port.
'SERVER_URL': 'localhost:8220',
The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
'ENVIRONMENT': 'my-environment',
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
'ENVIRONMENT': '<your-environment>',
}
apm = ElasticAPM(app)"
@ -333,16 +328,15 @@ describe('getCommands', () => {
from elasticapm.contrib.flask import ElasticAPM
app.config['ELASTIC_APM'] = {
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space.
'SERVICE_NAME': 'my-service-name',
'SERVICE_NAME': '<your-service-name>',
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
'SECRET_TOKEN': 'foobar',
# Set the custom APM Server URL (default: http://localhost:8200). The URL must be fully qualified, including protocol (http or https) and port.
'SERVER_URL': 'localhost:8220',
The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
'ENVIRONMENT': 'my-environment',
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
'ENVIRONMENT': '<your-environment>',
}
apm = ElasticAPM(app)"
@ -359,7 +353,7 @@ describe('getCommands', () => {
"# config/elastic_apm.yml:
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Defaults to the name of your Rails app.
service_name: 'my-service-name'
service_name: '<your-service-name>'
# Use if APM Server requires an API Key. This is used to ensure that only your agents can send data to your APM server. Agents can use API keys as a replacement of secret token, APM server can have multiple API keys. When both secret token and API key are used, API key has priority and secret token is ignored.
api_key: ''
@ -368,7 +362,7 @@ describe('getCommands', () => {
server_url: ''
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
environment: 'my-environment'"
environment: '<your-environment>'"
`);
});
it('renders with secret token and url', () => {
@ -382,7 +376,7 @@ describe('getCommands', () => {
"# config/elastic_apm.yml:
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Defaults to the name of your Rails app.
service_name: 'my-service-name'
service_name: '<your-service-name>'
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
secret_token: 'foobar'
@ -391,7 +385,7 @@ describe('getCommands', () => {
server_url: 'localhost:8220'
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
environment: 'my-environment'"
environment: '<your-environment>'"
`);
});
it('renders with api key even though secret token is present', () => {
@ -406,7 +400,7 @@ describe('getCommands', () => {
"# config/elastic_apm.yml:
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Defaults to the name of your Rails app.
service_name: 'my-service-name'
service_name: '<your-service-name>'
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
secret_token: 'foobar'
@ -415,7 +409,7 @@ describe('getCommands', () => {
server_url: 'localhost:8220'
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
environment: 'my-environment'"
environment: '<your-environment>'"
`);
});
});
@ -429,7 +423,7 @@ describe('getCommands', () => {
"# config/elastic_apm.yml:
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Defaults to the name of your Rack app's class.
service_name: 'my-service-name'
service_name: '<your-service-name>'
# Use if APM Server requires an API Key. This is used to ensure that only your agents can send data to your APM server. Agents can use API keys as a replacement of secret token, APM server can have multiple API keys. When both secret token and API key are used, API key has priority and secret token is ignored.
api_key: ''
@ -438,7 +432,7 @@ describe('getCommands', () => {
server_url: ''
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
environment: 'my-environment'"
environment: '<your-environment>'"
`);
});
it('renders with secret token and url', () => {
@ -452,7 +446,7 @@ describe('getCommands', () => {
"# config/elastic_apm.yml:
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Defaults to the name of your Rack app's class.
service_name: 'my-service-name'
service_name: '<your-service-name>'
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
secret_token: 'foobar'
@ -461,7 +455,7 @@ describe('getCommands', () => {
server_url: 'localhost:8220'
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
environment: 'my-environment'"
environment: '<your-environment>'"
`);
});
it('renders with api key even though secret token is present', () => {
@ -476,7 +470,7 @@ describe('getCommands', () => {
"# config/elastic_apm.yml:
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Defaults to the name of your Rack app's class.
service_name: 'my-service-name'
service_name: '<your-service-name>'
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
secret_token: 'foobar'
@ -485,7 +479,7 @@ describe('getCommands', () => {
server_url: 'localhost:8220'
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
environment: 'my-environment'"
environment: '<your-environment>'"
`);
});
});
@ -499,7 +493,7 @@ describe('getCommands', () => {
"# Initialize using environment variables:
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. If not specified, the executable name will be used.
export ELASTIC_APM_SERVICE_NAME=my-service-name
export ELASTIC_APM_SERVICE_NAME=<your-service-name>
# Use if APM Server requires an API Key. This is used to ensure that only your agents can send data to your APM server. Agents can use API keys as a replacement of secret token, APM server can have multiple API keys. When both secret token and API key are used, API key has priority and secret token is ignored.
export ELASTIC_APM_API_KEY=
@ -508,7 +502,7 @@ describe('getCommands', () => {
export ELASTIC_APM_SERVER_URL=
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
export ELASTIC_APM_ENVIRONMENT=my-environment
export ELASTIC_APM_ENVIRONMENT=<your-environment>
"
`);
});
@ -523,7 +517,7 @@ describe('getCommands', () => {
"# Initialize using environment variables:
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. If not specified, the executable name will be used.
export ELASTIC_APM_SERVICE_NAME=my-service-name
export ELASTIC_APM_SERVICE_NAME=<your-service-name>
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
export ELASTIC_APM_SECRET_TOKEN=foobar
@ -532,7 +526,7 @@ describe('getCommands', () => {
export ELASTIC_APM_SERVER_URL=localhost:8220
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
export ELASTIC_APM_ENVIRONMENT=my-environment
export ELASTIC_APM_ENVIRONMENT=<your-environment>
"
`);
});
@ -548,7 +542,7 @@ describe('getCommands', () => {
"# Initialize using environment variables:
# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. If not specified, the executable name will be used.
export ELASTIC_APM_SERVICE_NAME=my-service-name
export ELASTIC_APM_SERVICE_NAME=<your-service-name>
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
export ELASTIC_APM_SECRET_TOKEN=foobar
@ -557,7 +551,7 @@ describe('getCommands', () => {
export ELASTIC_APM_SERVER_URL=localhost:8220
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
export ELASTIC_APM_ENVIRONMENT=my-environment
export ELASTIC_APM_ENVIRONMENT=<your-environment>
"
`);
});
@ -572,13 +566,13 @@ describe('getCommands', () => {
"{
\\"ElasticApm\\": {
/// The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Default is the entry assembly of the application.
\\"ServiceName\\": \\"my-service-name\\",
\\"ServiceName\\": \\"<your-service-name>\\",
/// Use if APM Server requires an API Key. This is used to ensure that only your agents can send data to your APM server. Agents can use API keys as a replacement of secret token, APM server can have multiple API keys. When both secret token and API key are used, API key has priority and secret token is ignored.
\\"ApiKey\\": \\"\\",
/// Set the custom APM Server URL (default: http://localhost:8200). The URL must be fully qualified, including protocol (http or https) and port.
\\"ServerUrl\\": \\"\\",
/// The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
\\"Environment\\": \\"my-environment\\",
\\"Environment\\": \\"<your-environment>\\",
}
}"
`);
@ -594,13 +588,13 @@ describe('getCommands', () => {
"{
\\"ElasticApm\\": {
/// The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Default is the entry assembly of the application.
\\"ServiceName\\": \\"my-service-name\\",
\\"ServiceName\\": \\"<your-service-name>\\",
/// Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
\\"SecretToken\\": \\"foobar\\",
/// Set the custom APM Server URL (default: http://localhost:8200). The URL must be fully qualified, including protocol (http or https) and port.
\\"ServerUrl\\": \\"localhost:8220\\",
/// The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
\\"Environment\\": \\"my-environment\\",
\\"Environment\\": \\"<your-environment>\\",
}
}"
`);
@ -617,13 +611,13 @@ describe('getCommands', () => {
"{
\\"ElasticApm\\": {
/// The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space. Default is the entry assembly of the application.
\\"ServiceName\\": \\"my-service-name\\",
\\"ServiceName\\": \\"<your-service-name>\\",
/// Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
\\"SecretToken\\": \\"foobar\\",
/// Set the custom APM Server URL (default: http://localhost:8200). The URL must be fully qualified, including protocol (http or https) and port.
\\"ServerUrl\\": \\"localhost:8220\\",
/// The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
\\"Environment\\": \\"my-environment\\",
\\"Environment\\": \\"<your-environment>\\",
}
}"
`);
@ -637,7 +631,7 @@ describe('getCommands', () => {
expect(commands).not.toBe('');
expect(commands).toMatchInlineSnapshot(`
"# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space.
elastic_apm.service_name=\\"my-service-name\\"
elastic_apm.service_name=\\"<your-service-name>\\"
# Use if APM Server requires an API Key. This is used to ensure that only your agents can send data to your APM server. Agents can use API keys as a replacement of secret token, APM server can have multiple API keys. When both secret token and API key are used, API key has priority and secret token is ignored.
elastic_apm.api_key=\\"\\"
@ -646,7 +640,7 @@ describe('getCommands', () => {
elastic_apm.server_url=\\"\\"
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
elastic_apm.environment=\\"my-environment\\""
elastic_apm.environment=\\"<your-environment>\\""
`);
});
it('renders with secret token and url', () => {
@ -658,7 +652,7 @@ describe('getCommands', () => {
expect(commands).not.toBe('');
expect(commands).toMatchInlineSnapshot(`
"# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space.
elastic_apm.service_name=\\"my-service-name\\"
elastic_apm.service_name=\\"<your-service-name>\\"
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
elastic_apm.secret_token=\\"foobar\\"
@ -667,7 +661,7 @@ describe('getCommands', () => {
elastic_apm.server_url=\\"localhost:8220\\"
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
elastic_apm.environment=\\"my-environment\\""
elastic_apm.environment=\\"<your-environment>\\""
`);
});
it('renders with api key even though secret token is present', () => {
@ -680,7 +674,7 @@ describe('getCommands', () => {
expect(commands).not.toBe('');
expect(commands).toMatchInlineSnapshot(`
"# The service name is the primary filter in the APM UI and is used to group errors and trace data together. Allowed characters are a-z, A-Z, 0-9, -, _, and space.
elastic_apm.service_name=\\"my-service-name\\"
elastic_apm.service_name=\\"<your-service-name>\\"
# Use if APM Server requires a secret token. Both the agent and APM Server must be configured with the same token. This ensures that only your agents can send data to your APM server.
elastic_apm.secret_token=\\"foobar\\"
@ -689,7 +683,7 @@ describe('getCommands', () => {
elastic_apm.server_url=\\"localhost:8220\\"
# The name of the environment this service is deployed in, e.g., \\"production\\" or \\"staging\\". Environments allow you to easily filter data on a global level in the APM UI. It's important to be consistent when naming environments across agents.
elastic_apm.environment=\\"my-environment\\""
elastic_apm.environment=\\"<your-environment>\\""
`);
});
});

View file

@ -8,11 +8,9 @@
import { i18n } from '@kbn/i18n';
export const goVariables = (secretToken?: string) => ({
apmServiceName: 'ELASTIC_APM_SERVICE_NAME',
...(secretToken && { secretToken: 'ELASTIC_APM_SECRET_TOKEN' }),
...(!secretToken && { apiKey: 'ELASTIC_APM_API_KEY' }),
apmServerUrl: 'ELASTIC_APM_SERVER_URL',
apmEnvironment: 'ELASTIC_APM_ENVIRONMENT',
});
export const goHighlightLang = 'go';
@ -35,7 +33,7 @@ export const go = `# ${i18n.translate(
defaultMessage: 'If not specified, the executable name will be used.',
}
)}
export ELASTIC_APM_SERVICE_NAME=my-service-name
export ELASTIC_APM_SERVICE_NAME=<your-service-name>
{{^secretToken}}
# {{apiKeyHint}}
@ -50,5 +48,5 @@ export ELASTIC_APM_SECRET_TOKEN={{{secretToken}}}
export ELASTIC_APM_SERVER_URL={{{apmServerUrl}}}
# {{{serviceEnvironmentHint}}}
export ELASTIC_APM_ENVIRONMENT=my-environment
export ELASTIC_APM_ENVIRONMENT=<your-environment>
`;

View file

@ -14,11 +14,9 @@ import {
} from './shared_hints';
export const javaVariables = (secretToken?: string) => ({
apmServiceName: 'Delastic.apm.service_name',
...(secretToken && { secretToken: 'Delastic.apm.secret_token' }),
...(!secretToken && { apiKey: 'Delastic.apm.api_key' }),
apmServerUrl: 'Delastic.apm.server_url',
apmEnvironment: 'Delastic.apm.environment',
});
export const javaHighlightLang = 'java';
@ -34,7 +32,7 @@ export const javaLineNumbers = (apiKey?: string | null) => ({
},
});
export const java = `java -javaagent:/path/to/elastic-apm-agent-<version>.jar \\
-Delastic.apm.service_name=my-service-name \\
-Delastic.apm.service_name=<your-service-name> \\\\
{{^secretToken}}
-Delastic.apm.api_key={{{apiKey}}} \\
{{/secretToken}}
@ -42,6 +40,6 @@ export const java = `java -javaagent:/path/to/elastic-apm-agent-<version>.jar \\
-Delastic.apm.secret_token={{{secretToken}}} \\
{{/secretToken}}
-Delastic.apm.server_url={{{apmServerUrl}}} \\
-Delastic.apm.environment=my-environment \\
-Delastic.apm.environment=<your-environment> \\\\
-Delastic.apm.application_packages=org.example \\
-jar my-service-name.jar`;

View file

@ -7,18 +7,16 @@
import { i18n } from '@kbn/i18n';
export const nodeVariables = (secretToken?: string) => ({
apmServiceName: 'serviceName',
...(secretToken && { secretToken: 'secretToken' }),
...(!secretToken && { apiKey: 'apiKey' }),
apmServerUrl: 'serverUrl',
apmEnvironment: 'environment',
});
export const nodeHighlightLang = 'js';
export const nodeLineNumbers = () => ({
start: 1,
highlight: '2, 5, 8, 11, 14-15',
highlight: '2, 4, 7, 10, 13-14',
});
export const node = `// ${i18n.translate(
@ -29,14 +27,13 @@ export const node = `// ${i18n.translate(
}
)}
var apm = require('elastic-apm-node').start({
// {{serviceNameHint}} ${i18n.translate(
'xpack.apm.onboarding.nodeClient.createConfig.commands.serviceName',
{
defaultMessage: 'Overrides the service name in package.json.',
}
)}
serviceName: 'my-service-name',
serviceName: '<your-service-name>',
{{^secretToken}}
// {{apiKeyHint}}
@ -51,5 +48,5 @@ var apm = require('elastic-apm-node').start({
serverUrl: '{{{apmServerUrl}}}',
// {{{serviceEnvironmentHint}}}
environment: 'my-environment'
environment: '<your-environment>'
})`;

View file

@ -5,11 +5,9 @@
* 2.0.
*/
export const phpVariables = (secretToken?: string) => ({
apmServiceName: 'elastic_apm.service_name',
...(secretToken && { secretToken: 'elastic_apm.secret_token' }),
...(!secretToken && { apiKey: 'elastic_apm.api_key' }),
apmServerUrl: 'elastic_apm.server_url',
apmEnvironment: 'elastic_apm.environment',
});
export const phpHighlightLang = 'php';
@ -20,7 +18,7 @@ export const phpLineNumbers = () => ({
});
export const php = `# {{serviceNameHint}}
elastic_apm.service_name="my-service-name"
elastic_apm.service_name="<your-service-name>"
{{^secretToken}}
# {{apiKeyHint}}
@ -35,4 +33,4 @@ elastic_apm.secret_token="{{{secretToken}}}"
elastic_apm.server_url="{{{apmServerUrl}}}"
# {{{serviceEnvironmentHint}}}
elastic_apm.environment="my-environment"`;
elastic_apm.environment="<your-environment>"`;

View file

@ -4,15 +4,12 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { i18n } from '@kbn/i18n';
export const rackVariables = (secretToken?: string) => ({
apmServiceName: 'service_name',
...(secretToken && { secretToken: 'secret_token' }),
...(!secretToken && { apiKey: 'api_key' }),
apmServerUrl: 'server_url',
apmEnvironment: 'environment',
});
export const rackHighlightLang = 'rb';
@ -30,7 +27,7 @@ export const rack = `# config/elastic_apm.yml:
defaultMessage: "Defaults to the name of your Rack app's class.",
}
)}
service_name: 'my-service-name'
service_name: '<your-service-name>'
{{^secretToken}}
# {{apiKeyHint}}
@ -45,4 +42,4 @@ secret_token: '{{{secretToken}}}'
server_url: '{{{apmServerUrl}}}'
# {{{serviceEnvironmentHint}}}
environment: 'my-environment'`;
environment: '<your-environment>'`;

View file

@ -4,15 +4,12 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { i18n } from '@kbn/i18n';
export const railsVariables = (secretToken?: string) => ({
apmServiceName: 'service_name',
...(secretToken && { secretToken: 'secret_token' }),
...(!secretToken && { apiKey: 'api_key' }),
apmServerUrl: 'server_url',
apmEnvironment: 'environment',
});
export const railsHighlightLang = 'rb';
@ -30,7 +27,7 @@ export const rails = `# config/elastic_apm.yml:
defaultMessage: 'Defaults to the name of your Rails app.',
}
)}
service_name: 'my-service-name'
service_name: '<your-service-name>'
{{^secretToken}}
# {{apiKeyHint}}
@ -45,4 +42,4 @@ secret_token: '{{{secretToken}}}'
server_url: '{{{apmServerUrl}}}'
# {{{serviceEnvironmentHint}}}
environment: 'my-environment'`;
environment: '<your-environment>'`;