From 7f0d95b4d272209bc531a4164e7301ce2e21a16d Mon Sep 17 00:00:00 2001 From: eyalkoren <41850454+eyalkoren@users.noreply.github.com> Date: Tue, 1 Dec 2020 18:10:23 +0200 Subject: [PATCH 1/5] [APM] Add APM agent config options --- .../setting_definitions/general_settings.ts | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts index e777e1fd09d0b..4aba5d1d372ee 100644 --- a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts +++ b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts @@ -91,7 +91,7 @@ export const generalSettings: RawSettingDefinition[] = [ // LOG_LEVEL { key: 'log_level', - type: 'text', + type: 'select', defaultValue: 'info', label: i18n.translate('xpack.apm.agentConfig.logLevel.label', { defaultMessage: 'Log level', @@ -99,7 +99,16 @@ export const generalSettings: RawSettingDefinition[] = [ description: i18n.translate('xpack.apm.agentConfig.logLevel.description', { defaultMessage: 'Sets the logging level for the agent', }), - includeAgents: ['dotnet', 'ruby'], + options: [ + { text: 'trace', value: 'trace' }, + { text: 'debug', value: 'debug' }, + { text: 'info', value: 'info' }, + { text: 'warning', value: 'warning' }, + { text: 'error', value: 'error' }, + { text: 'critical', value: 'critical' }, + { text: 'off', value: 'off' }, + ], + includeAgents: ['dotnet', 'ruby', 'java'], }, // Recording @@ -207,4 +216,42 @@ export const generalSettings: RawSettingDefinition[] = [ } ), }, + + // Sanitize field names + { + key: 'sanitize_field_names', + type: 'text', + defaultValue: + 'password, passwd, pwd, secret, *key, *token*, *session*, *credit*, *card*, authorization, set-cookie', + label: i18n.translate('xpack.apm.agentConfig.transactionSampleRate.label', { + defaultMessage: 'Sanitize field names', + }), + description: i18n.translate( + 'xpack.apm.agentConfig.transactionSampleRate.description', + { + defaultMessage: + 'Sometimes it is necessary to sanitize, i.e., remove, sensitive data sent to Elastic APM. This config accepts a list of wildcard patterns of field names which should be sanitized. These apply to HTTP headers (including cookies) and `application/x-www-form-urlencoded` data (POST form fields). The query string and the captured request body (such as `application/json` data) will not get sanitized.', + } + ), + includeAgents: ['java'], + }, + + // Ignore transactions based on URLs + { + key: 'transaction_ignore_urls', + type: 'text', + defaultValue: + 'Agent specific - check out the documentation of this config option in the corresponding agent documentation.', + label: i18n.translate('xpack.apm.agentConfig.transactionSampleRate.label', { + defaultMessage: 'Ignore transactions based on URLs', + }), + description: i18n.translate( + 'xpack.apm.agentConfig.transactionSampleRate.description', + { + defaultMessage: + 'Used to restrict requests to certain URLs from being instrumented. This config accepts a comma-separated list of wildcard patterns of URL paths that should be ignored. When an incoming HTTP request is detected, its request path will be tested against each element in this list. For example, adding `/home/index` to this list would match and remove instrumentation from `http://localhost/home/index` as well as `http://whatever.com/home/index?value1=123`', + } + ), + includeAgents: ['java'], + }, ]; From 22987b7d35052688b7eea1d7b6b8ed5c0892144e Mon Sep 17 00:00:00 2001 From: eyalkoren <41850454+eyalkoren@users.noreply.github.com> Date: Tue, 1 Dec 2020 18:56:09 +0200 Subject: [PATCH 2/5] Fix i18n labels --- .../setting_definitions/general_settings.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts index 4aba5d1d372ee..481ce46b424e0 100644 --- a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts +++ b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts @@ -223,11 +223,11 @@ export const generalSettings: RawSettingDefinition[] = [ type: 'text', defaultValue: 'password, passwd, pwd, secret, *key, *token*, *session*, *credit*, *card*, authorization, set-cookie', - label: i18n.translate('xpack.apm.agentConfig.transactionSampleRate.label', { + label: i18n.translate('xpack.apm.agentConfig.sanitizeFiledNames.label', { defaultMessage: 'Sanitize field names', }), description: i18n.translate( - 'xpack.apm.agentConfig.transactionSampleRate.description', + 'xpack.apm.agentConfig.sanitizeFiledNames.description', { defaultMessage: 'Sometimes it is necessary to sanitize, i.e., remove, sensitive data sent to Elastic APM. This config accepts a list of wildcard patterns of field names which should be sanitized. These apply to HTTP headers (including cookies) and `application/x-www-form-urlencoded` data (POST form fields). The query string and the captured request body (such as `application/json` data) will not get sanitized.', @@ -242,11 +242,11 @@ export const generalSettings: RawSettingDefinition[] = [ type: 'text', defaultValue: 'Agent specific - check out the documentation of this config option in the corresponding agent documentation.', - label: i18n.translate('xpack.apm.agentConfig.transactionSampleRate.label', { + label: i18n.translate('xpack.apm.agentConfig.transactionIgnoreUrl.label', { defaultMessage: 'Ignore transactions based on URLs', }), description: i18n.translate( - 'xpack.apm.agentConfig.transactionSampleRate.description', + 'xpack.apm.agentConfig.transactionIgnoreUrl.description', { defaultMessage: 'Used to restrict requests to certain URLs from being instrumented. This config accepts a comma-separated list of wildcard patterns of URL paths that should be ignored. When an incoming HTTP request is detected, its request path will be tested against each element in this list. For example, adding `/home/index` to this list would match and remove instrumentation from `http://localhost/home/index` as well as `http://whatever.com/home/index?value1=123`', From 96b130292cfd943efe80547646a7fffd9b1c2b27 Mon Sep 17 00:00:00 2001 From: eyalkoren <41850454+eyalkoren@users.noreply.github.com> Date: Tue, 1 Dec 2020 19:00:31 +0200 Subject: [PATCH 3/5] Update test --- .../agent_configuration/setting_definitions/index.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts index 1f247813104ec..6c0a16443b22f 100644 --- a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts +++ b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts @@ -77,6 +77,9 @@ describe('filterByAgent', () => { 'stress_monitor_system_cpu_stress_threshold', 'transaction_max_spans', 'transaction_sample_rate', + 'log_level', + 'sanitize_field_names', + 'transaction_ignore_urls', ]); }); From ce8c4e3b6c73ac000cc7f39310c4cee38ad1a8c6 Mon Sep 17 00:00:00 2001 From: eyalkoren <41850454+eyalkoren@users.noreply.github.com> Date: Tue, 1 Dec 2020 21:22:04 +0200 Subject: [PATCH 4/5] Fix test --- .../agent_configuration/setting_definitions/index.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts index 6c0a16443b22f..a00f1ab5bb4d1 100644 --- a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts +++ b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/index.test.ts @@ -61,12 +61,14 @@ describe('filterByAgent', () => { 'capture_headers', 'circuit_breaker_enabled', 'enable_log_correlation', + 'log_level', 'profiling_inferred_spans_enabled', 'profiling_inferred_spans_excluded_classes', 'profiling_inferred_spans_included_classes', 'profiling_inferred_spans_min_duration', 'profiling_inferred_spans_sampling_interval', 'recording', + 'sanitize_field_names', 'server_timeout', 'span_frames_min_duration', 'stack_trace_limit', @@ -75,11 +77,9 @@ describe('filterByAgent', () => { 'stress_monitor_gc_stress_threshold', 'stress_monitor_system_cpu_relief_threshold', 'stress_monitor_system_cpu_stress_threshold', + 'transaction_ignore_urls', 'transaction_max_spans', 'transaction_sample_rate', - 'log_level', - 'sanitize_field_names', - 'transaction_ignore_urls', ]); }); From a7792a4eefc7783378a67191e8e41ee676d2fabf Mon Sep 17 00:00:00 2001 From: eyalkoren <41850454+eyalkoren@users.noreply.github.com> Date: Wed, 2 Dec 2020 07:07:24 +0200 Subject: [PATCH 5/5] Add runtime type and fix anther test --- .../runtime_types/log_level_rt.ts | 17 +++++++ .../__snapshots__/index.test.ts.snap | 44 ++++++++++++++++++- .../setting_definitions/general_settings.ts | 2 + 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugins/apm/common/agent_configuration/runtime_types/log_level_rt.ts diff --git a/x-pack/plugins/apm/common/agent_configuration/runtime_types/log_level_rt.ts b/x-pack/plugins/apm/common/agent_configuration/runtime_types/log_level_rt.ts new file mode 100644 index 0000000000000..b488faa8e8fdc --- /dev/null +++ b/x-pack/plugins/apm/common/agent_configuration/runtime_types/log_level_rt.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import * as t from 'io-ts'; + +export const logLevelRt = t.union([ + t.literal('trace'), + t.literal('debug'), + t.literal('info'), + t.literal('warning'), + t.literal('error'), + t.literal('critical'), + t.literal('off'), +]); diff --git a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/__snapshots__/index.test.ts.snap b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/__snapshots__/index.test.ts.snap index 2962a5fd2df3b..fc42af5ff7724 100644 --- a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/__snapshots__/index.test.ts.snap +++ b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/__snapshots__/index.test.ts.snap @@ -64,8 +64,38 @@ Array [ }, Object { "key": "log_level", - "type": "text", - "validationName": "string", + "options": Array [ + Object { + "text": "trace", + "value": "trace", + }, + Object { + "text": "debug", + "value": "debug", + }, + Object { + "text": "info", + "value": "info", + }, + Object { + "text": "warning", + "value": "warning", + }, + Object { + "text": "error", + "value": "error", + }, + Object { + "text": "critical", + "value": "critical", + }, + Object { + "text": "off", + "value": "off", + }, + ], + "type": "select", + "validationName": "(\\"trace\\" | \\"debug\\" | \\"info\\" | \\"warning\\" | \\"error\\" | \\"critical\\" | \\"off\\")", }, Object { "key": "profiling_inferred_spans_enabled", @@ -110,6 +140,11 @@ Array [ "type": "boolean", "validationName": "(\\"true\\" | \\"false\\")", }, + Object { + "key": "sanitize_field_names", + "type": "text", + "validationName": "string", + }, Object { "key": "server_timeout", "min": "1ms", @@ -170,6 +205,11 @@ Array [ "type": "float", "validationName": "floatRt", }, + Object { + "key": "transaction_ignore_urls", + "type": "text", + "validationName": "string", + }, Object { "key": "transaction_max_spans", "max": undefined, diff --git a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts index 481ce46b424e0..59a315830aec5 100644 --- a/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts +++ b/x-pack/plugins/apm/common/agent_configuration/setting_definitions/general_settings.ts @@ -6,6 +6,7 @@ import { i18n } from '@kbn/i18n'; import { captureBodyRt } from '../runtime_types/capture_body_rt'; +import { logLevelRt } from '../runtime_types/log_level_rt'; import { RawSettingDefinition } from './types'; export const generalSettings: RawSettingDefinition[] = [ @@ -91,6 +92,7 @@ export const generalSettings: RawSettingDefinition[] = [ // LOG_LEVEL { key: 'log_level', + validation: logLevelRt, type: 'select', defaultValue: 'info', label: i18n.translate('xpack.apm.agentConfig.logLevel.label', {